@@ -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
@@ -2097,7 +2105,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2097
2105
}
2098
2106
}
2099
2107
} else {
2108
+ let mut expected_tx_value_sats = if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2109
+ us. channel_value_satoshis
2110
+ } else { 0 } ;
2100
2111
let mut claimable_inbound_htlc_value_sat = 0 ;
2112
+ let mut claimable_inbound_htlc_value_msat = 0 ;
2101
2113
let mut nondust_htlc_count = 0 ;
2102
2114
let mut outbound_payment_htlc_rounded_msat = 0 ;
2103
2115
let mut outbound_forwarded_htlc_rounded_msat = 0 ;
@@ -2124,6 +2136,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2124
2136
} else {
2125
2137
outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
2126
2138
}
2139
+ expectex_tx_value_sats -= ( htlc. amount_msat + 999 ) / 1000 ;
2127
2140
if htlc. transaction_output_index . is_some ( ) {
2128
2141
res. push ( Balance :: MaybeTimeoutClaimableHTLC {
2129
2142
amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2150,12 +2163,15 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2150
2163
}
2151
2164
}
2152
2165
}
2166
+ let tx_fee_satoshis = chan_utils:: commit_tx_fee_sat (
2167
+ us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2168
+ us. onchain_tx_handler . channel_type_features ( ) ) ;
2169
+ //XXX: Debug assert that we're able to rebuild the amount_satoshis amount from other
2170
+ //information we provide here (and provide such other information)
2153
2171
res. push ( Balance :: ClaimableOnChannelClose {
2154
2172
amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
2155
2173
transaction_fee_satoshis : if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2156
- chan_utils:: commit_tx_fee_sat (
2157
- us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2158
- us. onchain_tx_handler . channel_type_features ( ) )
2174
+ tx_fee_satoshis
2159
2175
} else { 0 } ,
2160
2176
outbound_payment_htlc_rounded_msat,
2161
2177
outbound_forwarded_htlc_rounded_msat,
0 commit comments