@@ -635,25 +635,33 @@ pub enum Balance {
635635 /// [`Balance::MaybeTimeoutClaimableHTLC`] with their
636636 /// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
637637 /// HTLCs which would otherwise be represented the same.
638+ ///
639+ /// XXX: Talk about how this is included in the overall balance
638640 outbound_payment_htlc_rounded_msat : u64 ,
639641 /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
640642 /// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
641643 /// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
642644 /// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
643645 /// well as any dust HTLCs which would otherwise be represented the same.
646+ ///
647+ /// XXX: Talk about how this is included in the overall balance
644648 outbound_forwarded_htlc_rounded_msat : u64 ,
645649 /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
646650 /// to us and for which we know the preimage. This is the sum of the millisatoshis part of
647651 /// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
648652 /// close, but who's current value is included in
649653 /// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
650654 /// would otherwise be represented the same.
655+ ///
656+ /// XXX: Talk about how this is included in the overall balance
651657 inbound_claiming_htlc_rounded_msat : u64 ,
652658 /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
653659 /// to us and for which we do not know the preimage. This is the sum of the millisatoshis
654660 /// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
655661 /// on channel close, as well as any dust HTLCs which would otherwise be represented the
656662 /// same.
663+ ///
664+ /// XXX: Talk about how this is included in the overall balance
657665 inbound_htlc_rounded_msat : u64 ,
658666 } ,
659667 /// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2338,6 +2346,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
23382346 }
23392347 }
23402348 } else {
2349+ let mut expected_tx_value_sats = if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2350+ us. channel_value_satoshis
2351+ } else { 0 } ;
23412352 let mut claimable_inbound_htlc_value_sat = 0 ;
23422353 let mut nondust_htlc_count = 0 ;
23432354 let mut outbound_payment_htlc_rounded_msat = 0 ;
@@ -2365,6 +2376,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
23652376 } else {
23662377 outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
23672378 }
2379+ expected_tx_value_sats = expected_tx_value_sats. saturating_sub ( ( htlc. amount_msat + 999 ) / 1000 ) ;
23682380 if htlc. transaction_output_index . is_some ( ) {
23692381 res. push ( Balance :: MaybeTimeoutClaimableHTLC {
23702382 amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2391,12 +2403,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
23912403 }
23922404 }
23932405 }
2406+ let tx_fee_satoshis = chan_utils:: commit_tx_fee_sat (
2407+ us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2408+ us. onchain_tx_handler . channel_type_features ( ) ) ;
2409+ //XXX: Debug assert that we're able to rebuild the amount_satoshis amount from other
2410+ //information we provide here (and provide such other information)
23942411 res. push ( Balance :: ClaimableOnChannelClose {
23952412 amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
23962413 transaction_fee_satoshis : if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2397- chan_utils:: commit_tx_fee_sat (
2398- us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2399- us. onchain_tx_handler . channel_type_features ( ) )
2414+ tx_fee_satoshis
24002415 } else { 0 } ,
24012416 outbound_payment_htlc_rounded_msat,
24022417 outbound_forwarded_htlc_rounded_msat,
0 commit comments