@@ -591,25 +591,33 @@ pub enum Balance {
591
591
/// [`Balance::MaybeTimeoutClaimableHTLC`] with their
592
592
/// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
593
593
/// HTLCs which would otherwise be represented the same.
594
+ ///
595
+ /// XXX: Talk about how this is included in the overall balance
594
596
outbound_payment_htlc_rounded_msat : u64 ,
595
597
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
596
598
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
597
599
/// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
598
600
/// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
599
601
/// 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
600
604
outbound_forwarded_htlc_rounded_msat : u64 ,
601
605
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
602
606
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
603
607
/// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
604
608
/// close, but who's current value is included in
605
609
/// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
606
610
/// would otherwise be represented the same.
611
+ ///
612
+ /// XXX: Talk about how this is included in the overall balance
607
613
inbound_claiming_htlc_rounded_msat : u64 ,
608
614
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
609
615
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
610
616
/// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
611
617
/// on channel close, as well as any dust HTLCs which would otherwise be represented the
612
618
/// same.
619
+ ///
620
+ /// XXX: Talk about how this is included in the overall balance
613
621
inbound_htlc_rounded_msat : u64 ,
614
622
} ,
615
623
/// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2041,7 +2049,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2041
2049
}
2042
2050
}
2043
2051
} 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 } ;
2044
2055
let mut claimable_inbound_htlc_value_sat = 0 ;
2056
+ let mut claimable_inbound_htlc_value_msat = 0 ;
2045
2057
let mut nondust_htlc_count = 0 ;
2046
2058
let mut outbound_payment_htlc_rounded_msat = 0 ;
2047
2059
let mut outbound_forwarded_htlc_rounded_msat = 0 ;
@@ -2068,6 +2080,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2068
2080
} else {
2069
2081
outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
2070
2082
}
2083
+ expectex_tx_value_sats -= ( htlc. amount_msat + 999 ) / 1000 ;
2071
2084
if htlc. transaction_output_index . is_some ( ) {
2072
2085
res. push ( Balance :: MaybeTimeoutClaimableHTLC {
2073
2086
amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2095,12 +2108,15 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2095
2108
}
2096
2109
}
2097
2110
}
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)
2098
2116
res. push ( Balance :: ClaimableOnChannelClose {
2099
2117
amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
2100
2118
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
2104
2120
} else { 0 } ,
2105
2121
outbound_payment_htlc_rounded_msat,
2106
2122
outbound_forwarded_htlc_rounded_msat,
0 commit comments