Skip to content

Commit 7354ebe

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 ec19ba1 commit 7354ebe

File tree

3 files changed

+447
-0
lines changed

3 files changed

+447
-0
lines changed

lightning/src/chain/channelmonitor.rs

+10
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};
@@ -1614,6 +1615,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
16141615
self.inner.lock().unwrap().channel_id()
16151616
}
16161617

1618+
/// Gets the channel type of the corresponding channel.
1619+
pub fn channel_type_features(&self) -> ChannelTypeFeatures {
1620+
self.inner.lock().unwrap().channel_type_features()
1621+
}
1622+
16171623
/// Gets a list of txids, with their output scripts (in the order they appear in the
16181624
/// transaction), which we must learn about spends of via block_connected().
16191625
pub fn get_outputs_to_watch(&self) -> Vec<(Txid, Vec<(u32, ScriptBuf)>)> {
@@ -4809,6 +4815,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
48094815
self.onchain_events_awaiting_threshold_conf.push(entry);
48104816
}
48114817
}
4818+
4819+
fn channel_type_features(&self) -> ChannelTypeFeatures {
4820+
self.onchain_tx_handler.channel_type_features().clone()
4821+
}
48124822
}
48134823

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

0 commit comments

Comments
 (0)