@@ -4414,14 +4414,22 @@ where
44144414 funding.get_channel_type()
44154415 );
44164416
4417- // `Some(())` is for the fee spike buffer we keep for the remote. This deviates from
4418- // the spec because the fee spike buffer requirement doesn't exist on the receiver's
4419- // side, only on the sender's. Note that with anchor outputs we are no longer as
4420- // sensitive to fee spikes, so we need to account for them.
4417+ // `Some(())` is for the fee spike buffer we keep for the remote if the channel is
4418+ // not zero fee.. This deviates from the spec because the fee spike buffer requirement
4419+ // doesn't exist on the receiver's side, only on the sender's. Note that with anchor
4420+ // outputs we are no longer as sensitive to fee spikes, so we need to account for them.
44214421 //
44224422 // A `None` `HTLCCandidate` is used as in this case because we're already accounting for
44234423 // the incoming HTLC as it has been fully committed by both sides.
4424- let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(funding, None, Some(()));
4424+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4425+ None
4426+ } else {
4427+ Some(())
4428+ };
4429+
4430+ let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(
4431+ funding, None, fee_spike_buffer_htlc,
4432+ );
44254433 if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
44264434 remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
44274435 }
@@ -4947,11 +4955,18 @@ where
49474955 // and the answer will in turn change the amount itself — making it a circular
49484956 // dependency.
49494957 // This complicates the computation around dust-values, up to the one-htlc-value.
4958+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4959+ None
4960+ } else {
4961+ Some(())
4962+ };
4963+
49504964 let real_dust_limit_timeout_sat = real_htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
49514965 let htlc_above_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000, HTLCInitiator::LocalOffered);
4952- let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_above_dust, Some(()) );
4966+ let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(& funding, htlc_above_dust, fee_spike_buffer_htlc );
49534967 let htlc_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000 - 1, HTLCInitiator::LocalOffered);
4954- let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_dust, Some(()));
4968+ let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, fee_spike_buffer_htlc);
4969+
49554970 if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
49564971 max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
49574972 min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -5069,6 +5084,7 @@ where
50695084
50705085 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
50715086 debug_assert_eq!(context.feerate_per_kw, 0);
5087+ debug_assert!(fee_spike_buffer_htlc.is_none());
50725088 return 0;
50735089 }
50745090
@@ -5178,6 +5194,7 @@ where
51785194
51795195 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
51805196 debug_assert_eq!(context.feerate_per_kw, 0);
5197+ debug_assert!(fee_spike_buffer_htlc.is_none());
51815198 return 0
51825199 }
51835200
0 commit comments