@@ -57,21 +57,20 @@ pub(crate) struct NextCommitmentStats {
57
57
#[ rustfmt:: skip]
58
58
fn excess_fees_on_counterparty_tx_dust_exposure_msat (
59
59
next_commitment_htlcs : & [ HTLCAmountDirection ] , dust_buffer_feerate : u32 ,
60
- excess_feerate : u32 , broadcaster_dust_limit_satoshis : u64 , mut on_counterparty_tx_dust_exposure_msat : u64 ,
60
+ excess_feerate : u32 , broadcaster_dust_limit_satoshis : u64 , dust_htlc_exposure_msat : u64 ,
61
61
channel_type : & ChannelTypeFeatures ,
62
62
) -> ( u64 , u64 ) {
63
63
64
64
let on_counterparty_tx_accepted_nondust_htlcs = next_commitment_htlcs. iter ( ) . filter ( |htlc| !htlc. is_dust ( false , dust_buffer_feerate, broadcaster_dust_limit_satoshis, channel_type) && htlc. outbound ) . count ( ) ;
65
65
let on_counterparty_tx_offered_nondust_htlcs = next_commitment_htlcs. iter ( ) . filter ( |htlc| !htlc. is_dust ( false , dust_buffer_feerate, broadcaster_dust_limit_satoshis, channel_type) && !htlc. outbound ) . count ( ) ;
66
66
67
- let extra_htlc_commit_tx_fee_sat = commit_tx_fee_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1 + on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
68
- let extra_htlc_htlc_tx_fees_sat = htlc_tx_fees_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1 , on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
67
+ let commitment_fee_sat = commit_tx_fee_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
68
+ let second_stage_fees_sat = htlc_tx_fees_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs, on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
69
+ let on_counterparty_tx_dust_exposure_msat = dust_htlc_exposure_msat + ( commitment_fee_sat + second_stage_fees_sat) * 1000 ;
69
70
70
- let commit_tx_fee_sat = commit_tx_fee_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
71
- let htlc_tx_fees_sat = htlc_tx_fees_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs, on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
72
-
73
- let extra_htlc_dust_exposure_msat = on_counterparty_tx_dust_exposure_msat + ( extra_htlc_commit_tx_fee_sat + extra_htlc_htlc_tx_fees_sat) * 1000 ;
74
- on_counterparty_tx_dust_exposure_msat += ( commit_tx_fee_sat + htlc_tx_fees_sat) * 1000 ;
71
+ let extra_htlc_commitment_fee_sat = commit_tx_fee_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1 + on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
72
+ let extra_htlc_second_stage_fees_sat = htlc_tx_fees_sat ( excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1 , on_counterparty_tx_offered_nondust_htlcs, channel_type) ;
73
+ let extra_htlc_dust_exposure_msat = dust_htlc_exposure_msat + ( extra_htlc_commitment_fee_sat + extra_htlc_second_stage_fees_sat) * 1000 ;
75
74
76
75
(
77
76
on_counterparty_tx_dust_exposure_msat,
0 commit comments