From: Matt Corallo Date: Fri, 29 Sep 2023 17:54:24 +0000 (+0000) Subject: Add tx fee information to `Balance::ClaimableOnChannelClose` X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b5ad3c91e81f3d47b9afdd004f38689448647bfb;p=rust-lightning Add tx fee information to `Balance::ClaimableOnChannelClose` `Balance::ClaimableOnChannelClose` excludes the commitment transaction fee, which makes it hard to use for current balance calculation. Here we add it, setting the value to zero for inbound channels (i.e. ones for which we don't pay the fee). --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 3845328cd..7f9d40b50 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -578,6 +578,13 @@ pub enum Balance { /// The amount available to claim, in satoshis, excluding the on-chain fees which will be /// required to do so. amount_satoshis: u64, + /// The transaction fee we pay for the closing commitment transaction. This amount is not + /// included in the [`Balance::ClaimableOnChannelClose::amount_satoshis`] value. + /// + /// Note that if this channel is inbound (and thus our counterparty pays the commitment + /// transaction fee) this value will be zero. For [`ChannelMonitor`]s created prior to LDK + /// 0.0.117, the channel is always treated as outbound (and thus this value is never zero). + transaction_fee_satoshis: u64, }, /// The channel has been closed, and the given balance is ours but awaiting confirmations until /// we consider it spendable. @@ -861,6 +868,10 @@ pub(crate) struct ChannelMonitorImpl { // of block connection between ChannelMonitors and the ChannelManager. funding_spend_seen: bool, + /// True if the commitment transaction fee is paid by us. + /// Added in 0.0.117. + holder_pays_commitment_tx_fee: Option, + /// Set to `Some` of the confirmed transaction spending the funding input of the channel after /// reaching `ANTI_REORG_DELAY` confirmations. funding_spend_confirmed: Option, @@ -1086,6 +1097,7 @@ impl Writeable for ChannelMonitorImpl ChannelMonitor { pub(crate) fn new(secp_ctx: Secp256k1, keys: Signer, shutdown_script: Option