@@ -635,25 +635,33 @@ pub enum Balance {
635
635
/// [`Balance::MaybeTimeoutClaimableHTLC`] with their
636
636
/// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
637
637
/// HTLCs which would otherwise be represented the same.
638
+ ///
639
+ /// XXX: Talk about how this is included in the overall balance
638
640
outbound_payment_htlc_rounded_msat : u64 ,
639
641
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
640
642
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
641
643
/// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
642
644
/// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
643
645
/// 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
644
648
outbound_forwarded_htlc_rounded_msat : u64 ,
645
649
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
646
650
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
647
651
/// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
648
652
/// close, but who's current value is included in
649
653
/// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
650
654
/// would otherwise be represented the same.
655
+ ///
656
+ /// XXX: Talk about how this is included in the overall balance
651
657
inbound_claiming_htlc_rounded_msat : u64 ,
652
658
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
653
659
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
654
660
/// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
655
661
/// on channel close, as well as any dust HTLCs which would otherwise be represented the
656
662
/// same.
663
+ ///
664
+ /// XXX: Talk about how this is included in the overall balance
657
665
inbound_htlc_rounded_msat : u64 ,
658
666
} ,
659
667
/// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2338,6 +2346,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2338
2346
}
2339
2347
}
2340
2348
} 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 } ;
2341
2352
let mut claimable_inbound_htlc_value_sat = 0 ;
2342
2353
let mut nondust_htlc_count = 0 ;
2343
2354
let mut outbound_payment_htlc_rounded_msat = 0 ;
@@ -2365,6 +2376,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2365
2376
} else {
2366
2377
outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
2367
2378
}
2379
+ expected_tx_value_sats = expected_tx_value_sats. saturating_sub ( ( htlc. amount_msat + 999 ) / 1000 ) ;
2368
2380
if htlc. transaction_output_index . is_some ( ) {
2369
2381
res. push ( Balance :: MaybeTimeoutClaimableHTLC {
2370
2382
amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2391,12 +2403,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2391
2403
}
2392
2404
}
2393
2405
}
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)
2394
2411
res. push ( Balance :: ClaimableOnChannelClose {
2395
2412
amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
2396
2413
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
2400
2415
} else { 0 } ,
2401
2416
outbound_payment_htlc_rounded_msat,
2402
2417
outbound_forwarded_htlc_rounded_msat,
0 commit comments