@@ -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 }
@@ -4946,11 +4954,18 @@ where
49464954 // and the answer will in turn change the amount itself — making it a circular
49474955 // dependency.
49484956 // This complicates the computation around dust-values, up to the one-htlc-value.
4957+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4958+ None
4959+ } else {
4960+ Some(())
4961+ };
4962+
49494963 let real_dust_limit_timeout_sat = real_htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
49504964 let htlc_above_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000, HTLCInitiator::LocalOffered);
4951- let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_above_dust, Some(()) );
4965+ let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(& funding, htlc_above_dust, fee_spike_buffer_htlc );
49524966 let htlc_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000 - 1, HTLCInitiator::LocalOffered);
4953- let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_dust, Some(()));
4967+ let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, fee_spike_buffer_htlc);
4968+
49544969 if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
49554970 max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
49564971 min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -5068,6 +5083,7 @@ where
50685083
50695084 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
50705085 debug_assert_eq!(context.feerate_per_kw, 0);
5086+ debug_assert!(fee_spike_buffer_htlc.is_none());
50715087 return 0;
50725088 }
50735089
@@ -5177,6 +5193,7 @@ where
51775193
51785194 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
51795195 debug_assert_eq!(context.feerate_per_kw, 0);
5196+ debug_assert!(fee_spike_buffer_htlc.is_none());
51805197 return 0
51815198 }
51825199
0 commit comments