@@ -635,25 +635,37 @@ 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
+ /// This value will not be included in `amount_satoshis` and any representable (quotient
640
+ /// when divided by 1000 without the remainder) value will go toward fees
638
641
outbound_payment_htlc_rounded_msat : u64 ,
639
642
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
640
643
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
641
644
/// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
642
645
/// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
643
646
/// well as any dust HTLCs which would otherwise be represented the same.
647
+ ///
648
+ /// This value will not be included in `amount_satoshis` and any representable (quotient
649
+ /// when divided by 1000 without the remainder) value will go toward fees
644
650
outbound_forwarded_htlc_rounded_msat : u64 ,
645
651
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
646
652
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
647
653
/// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
648
654
/// close, but who's current value is included in
649
655
/// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
650
656
/// would otherwise be represented the same.
657
+ ///
658
+ /// This value will not be included in `amount_satoshis` and any representable (quotient
659
+ /// when divided by 1000 without the remainder) value will go toward fees
651
660
inbound_claiming_htlc_rounded_msat : u64 ,
652
661
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
653
662
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
654
663
/// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
655
664
/// on channel close, as well as any dust HTLCs which would otherwise be represented the
656
665
/// same.
666
+ ///
667
+ /// This value will not be included in `amount_satoshis` and any representable (quotient
668
+ /// when divided by 1000 without the remainder) value will go toward fees
657
669
inbound_htlc_rounded_msat : u64 ,
658
670
} ,
659
671
/// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2338,6 +2350,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2338
2350
}
2339
2351
}
2340
2352
} else {
2353
+ let mut expected_tx_value_sats = if us. holder_pays_commitment_tx_fee . unwrap_or ( true ) {
2354
+ us. channel_value_satoshis
2355
+ } else { 0 } ;
2341
2356
let mut claimable_inbound_htlc_value_sat = 0 ;
2342
2357
let mut nondust_htlc_count = 0 ;
2343
2358
let mut outbound_payment_htlc_rounded_msat = 0 ;
@@ -2365,6 +2380,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2365
2380
} else {
2366
2381
outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
2367
2382
}
2383
+ expected_tx_value_sats = expected_tx_value_sats. saturating_sub ( ( htlc. amount_msat + 999 ) / 1000 ) ;
2368
2384
if htlc. transaction_output_index . is_some ( ) {
2369
2385
res. push ( Balance :: MaybeTimeoutClaimableHTLC {
2370
2386
amount_satoshis : htlc. amount_msat / 1000 ,
@@ -2391,12 +2407,13 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2391
2407
}
2392
2408
}
2393
2409
}
2410
+ let tx_fee_satoshis = chan_utils:: commit_tx_fee_sat (
2411
+ us. current_holder_commitment_tx . feerate_per_kw , nondust_htlc_count,
2412
+ us. onchain_tx_handler . channel_type_features ( ) ) ;
2394
2413
res. push ( Balance :: ClaimableOnChannelClose {
2395
2414
amount_satoshis : us. current_holder_commitment_tx . to_self_value_sat + claimable_inbound_htlc_value_sat,
2396
2415
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 ( ) )
2416
+ tx_fee_satoshis
2400
2417
} else { 0 } ,
2401
2418
outbound_payment_htlc_rounded_msat,
2402
2419
outbound_forwarded_htlc_rounded_msat,
0 commit comments