Skip to content

Commit 392c490

Browse files
committed
Define anchor channel reserve requirements
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.
1 parent 8d8b4ea commit 392c490

File tree

3 files changed

+414
-0
lines changed

3 files changed

+414
-0
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use bitcoin::secp256k1::{self, SecretKey, PublicKey, Secp256k1, ecdsa::Signature
3434

3535
use crate::ln::channel::INITIAL_COMMITMENT_NUMBER;
3636
use crate::ln::types::ChannelId;
37+
use crate::types::features::ChannelTypeFeatures;
3738
use crate::types::payment::{PaymentHash, PaymentPreimage};
3839
use crate::ln::msgs::DecodeError;
3940
use crate::ln::channel_keys::{DelayedPaymentKey, DelayedPaymentBasepoint, HtlcBasepoint, HtlcKey, RevocationKey, RevocationBasepoint};
@@ -1583,6 +1584,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
15831584
self.inner.lock().unwrap().channel_id()
15841585
}
15851586

1587+
/// Gets the channel type of the corresponding channel.
1588+
pub fn channel_type_features(&self) -> ChannelTypeFeatures {
1589+
self.inner.lock().unwrap().channel_type_features()
1590+
}
1591+
15861592
/// Gets a list of txids, with their output scripts (in the order they appear in the
15871593
/// transaction), which we must learn about spends of via block_connected().
15881594
pub fn get_outputs_to_watch(&self) -> Vec<(Txid, Vec<(u32, ScriptBuf)>)> {
@@ -4769,6 +4775,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47694775
self.onchain_events_awaiting_threshold_conf.push(entry);
47704776
}
47714777
}
4778+
4779+
fn channel_type_features(&self) -> ChannelTypeFeatures {
4780+
self.onchain_tx_handler.channel_type_features().clone()
4781+
}
47724782
}
47734783

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

0 commit comments

Comments
 (0)