Skip to content

Commit

Permalink
Define anchor channel reserve requirements
Browse files Browse the repository at this point in the history
This change defines anchor reserve requirements by calculating weights
and fees for the transactions that need to be confirmed on-chain in the
event of a unilateral closure. The calculation is given a set of
parameters as input, including the expected fee rate and number of
in-flight HTLCs.
  • Loading branch information
wvanlint committed Dec 17, 2024
1 parent 1a8bf62 commit ec956b7
Show file tree
Hide file tree
Showing 3 changed files with 408 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use bitcoin::secp256k1::{self, SecretKey, PublicKey, Secp256k1, ecdsa::Signature

use crate::ln::channel::INITIAL_COMMITMENT_NUMBER;
use crate::ln::types::ChannelId;
use crate::types::features::ChannelTypeFeatures;
use crate::types::payment::{PaymentHash, PaymentPreimage};
use crate::ln::msgs::DecodeError;
use crate::ln::channel_keys::{DelayedPaymentKey, DelayedPaymentBasepoint, HtlcBasepoint, HtlcKey, RevocationKey, RevocationBasepoint};
Expand Down Expand Up @@ -1571,6 +1572,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
self.inner.lock().unwrap().channel_id()
}

/// Gets the channel type of the corresponding channel.
pub fn channel_type_features(&self) -> ChannelTypeFeatures {
self.inner.lock().unwrap().channel_type_features()
}

/// Gets a list of txids, with their output scripts (in the order they appear in the
/// transaction), which we must learn about spends of via block_connected().
pub fn get_outputs_to_watch(&self) -> Vec<(Txid, Vec<(u32, ScriptBuf)>)> {
Expand Down Expand Up @@ -4692,6 +4698,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
self.onchain_events_awaiting_threshold_conf.push(entry);
}
}

fn channel_type_features(&self) -> ChannelTypeFeatures {
self.onchain_tx_handler.channel_type_features().clone()
}
}

impl<Signer: EcdsaChannelSigner, T: Deref, F: Deref, L: Deref> chain::Listen for (ChannelMonitor<Signer>, T, F, L)
Expand Down
Loading

0 comments on commit ec956b7

Please sign in to comment.