@@ -4396,14 +4396,22 @@ where
43964396 funding.get_channel_type()
43974397 );
43984398
4399- // `Some(())` is for the fee spike buffer we keep for the remote. This deviates from
4400- // the spec because the fee spike buffer requirement doesn't exist on the receiver's
4401- // side, only on the sender's. Note that with anchor outputs we are no longer as
4402- // sensitive to fee spikes, so we need to account for them.
4399+ // `Some(())` is for the fee spike buffer we keep for the remote if the channel is
4400+ // not zero fee. This deviates from the spec because the fee spike buffer requirement
4401+ // doesn't exist on the receiver's side, only on the sender's. Note that with anchor
4402+ // outputs we are no longer as sensitive to fee spikes, so we need to account for them.
44034403 //
44044404 // A `None` `HTLCCandidate` is used as in this case because we're already accounting for
44054405 // the incoming HTLC as it has been fully committed by both sides.
4406- let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(funding, None, Some(()));
4406+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4407+ None
4408+ } else {
4409+ Some(())
4410+ };
4411+
4412+ let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(
4413+ funding, None, fee_spike_buffer_htlc,
4414+ );
44074415 if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
44084416 remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
44094417 }
@@ -4929,11 +4937,18 @@ where
49294937 // and the answer will in turn change the amount itself — making it a circular
49304938 // dependency.
49314939 // This complicates the computation around dust-values, up to the one-htlc-value.
4940+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4941+ None
4942+ } else {
4943+ Some(())
4944+ };
4945+
49324946 let real_dust_limit_timeout_sat = real_htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
49334947 let htlc_above_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000, HTLCInitiator::LocalOffered);
4934- let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_above_dust, Some(()) );
4948+ let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(& funding, htlc_above_dust, fee_spike_buffer_htlc );
49354949 let htlc_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000 - 1, HTLCInitiator::LocalOffered);
4936- let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(funding, htlc_dust, Some(()));
4950+ let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, fee_spike_buffer_htlc);
4951+
49374952 if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
49384953 max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
49394954 min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -5051,6 +5066,7 @@ where
50515066
50525067 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
50535068 debug_assert_eq!(context.feerate_per_kw, 0);
5069+ debug_assert!(fee_spike_buffer_htlc.is_none());
50545070 return 0;
50555071 }
50565072
@@ -5160,6 +5176,7 @@ where
51605176
51615177 if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
51625178 debug_assert_eq!(context.feerate_per_kw, 0);
5179+ debug_assert!(fee_spike_buffer_htlc.is_none());
51635180 return 0
51645181 }
51655182
0 commit comments