@@ -4396,14 +4396,22 @@ where
4396
4396
funding.get_channel_type()
4397
4397
);
4398
4398
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.
4403
4403
//
4404
4404
// A `None` `HTLCCandidate` is used as in this case because we're already accounting for
4405
4405
// 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
+ );
4407
4415
if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
4408
4416
remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4409
4417
}
@@ -4929,11 +4937,18 @@ where
4929
4937
// and the answer will in turn change the amount itself — making it a circular
4930
4938
// dependency.
4931
4939
// 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
+
4932
4946
let real_dust_limit_timeout_sat = real_htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
4933
4947
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 );
4935
4949
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
+
4937
4952
if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
4938
4953
max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4939
4954
min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -5051,6 +5066,7 @@ where
5051
5066
5052
5067
if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
5053
5068
debug_assert_eq!(context.feerate_per_kw, 0);
5069
+ debug_assert!(fee_spike_buffer_htlc.is_none());
5054
5070
return 0;
5055
5071
}
5056
5072
@@ -5160,6 +5176,7 @@ where
5160
5176
5161
5177
if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
5162
5178
debug_assert_eq!(context.feerate_per_kw, 0);
5179
+ debug_assert!(fee_spike_buffer_htlc.is_none());
5163
5180
return 0
5164
5181
}
5165
5182
0 commit comments