@@ -591,25 +591,33 @@ pub enum Balance {
591591 /// [`Balance::MaybeTimeoutClaimableHTLC`] with their
592592 /// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
593593 /// HTLCs which would otherwise be represented the same.
594+ ///
595+ /// XXX: Talk about how this is included in the overall balance
594596 outbound_payment_htlc_rounded_msat : u64 ,
595597 /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
596598 /// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
597599 /// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
598600 /// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
599601 /// well as any dust HTLCs which would otherwise be represented the same.
602+ ///
603+ /// XXX: Talk about how this is included in the overall balance
600604 outbound_forwarded_htlc_rounded_msat : u64 ,
601605 /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
602606 /// to us and for which we know the preimage. This is the sum of the millisatoshis part of
603607 /// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
604608 /// close, but who's current value is included in
605609 /// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
606610 /// would otherwise be represented the same.
611+ ///
612+ /// XXX: Talk about how this is included in the overall balance
607613 inbound_claiming_htlc_rounded_msat : u64 ,
608614 /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
609615 /// to us and for which we do not know the preimage. This is the sum of the millisatoshis
610616 /// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
611617 /// on channel close, as well as any dust HTLCs which would otherwise be represented the
612618 /// same.
619+ ///
620+ /// XXX: Talk about how this is included in the overall balance
613621 inbound_htlc_rounded_msat : u64 ,
614622 } ,
615623 /// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2041,7 +2049,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
20412049 }
20422050 }
20432051 } else {
2052+ let mut expected_tx_value_sats = if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2053+ us. channel_value_satoshis
2054+ } else { 0 } ;
20442055 let mut claimable_inbound_htlc_value_sat = 0 ;
2056+ let mut claimable_inbound_htlc_value_msat = 0 ;
20452057 let mut nondust_htlc_count = 0 ;
20462058 let mut outbound_payment_htlc_rounded_msat = 0 ;
20472059 let mut outbound_forwarded_htlc_rounded_msat = 0 ;
@@ -2068,6 +2080,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
20682080 } else {
20692081 outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
20702082 }
2083+ expectex_tx_value_sats -= ( htlc. amount_msat + 999 ) / 1000 ;
20712084 if htlc. transaction_output_index . is_some ( ) {
20722085 res. push ( Balance :: MaybeTimeoutClaimableHTLC {
20732086 amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2095,12 +2108,15 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
20952108 }
20962109 }
20972110 }
2111+ let tx_fee_satoshis = chan_utils:: commit_tx_fee_sat (
2112+ us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2113+ us. onchain_tx_handler . channel_type_features ( ) ) ;
2114+ //XXX: Debug assert that we're able to rebuild the amount_satoshis amount from other
2115+ //information we provide here (and provide such other information)
20982116 res. push ( Balance :: ClaimableOnChannelClose {
20992117 amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
21002118 transaction_fee_satoshis : if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2101- chan_utils:: commit_tx_fee_sat (
2102- us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2103- us. onchain_tx_handler . channel_type_features ( ) )
2119+ tx_fee_satoshis
21042120 } else { 0 } ,
21052121 outbound_payment_htlc_rounded_msat,
21062122 outbound_forwarded_htlc_rounded_msat,
0 commit comments