@@ -4296,14 +4296,22 @@ where
4296
4296
funding.get_value_satoshis() * 1000 - pending_value_to_self_msat;
4297
4297
4298
4298
if !funding.is_outbound() {
4299
- // `Some(())` is for the fee spike buffer we keep for the remote. This deviates from
4300
- // the spec because the fee spike buffer requirement doesn't exist on the receiver's
4301
- // side, only on the sender's. Note that with anchor outputs we are no longer as
4302
- // sensitive to fee spikes, so we need to account for them.
4299
+ // `Some(())` is for the fee spike buffer we keep for the remote if the channel is not
4300
+ // zero fee. This deviates from the spec because the fee spike buffer requirement
4301
+ // doesn't exist on the receiver's side, only on the sender's. Note that with anchor
4302
+ // outputs we are no longer as sensitive to fee spikes, so we need to account for them.
4303
4303
//
4304
4304
// A `None` `HTLCCandidate` is used as in this case because we're already accounting for
4305
4305
// the incoming HTLC as it has been fully committed by both sides.
4306
- let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(funding, None, Some(()));
4306
+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4307
+ None
4308
+ } else {
4309
+ Some(())
4310
+ };
4311
+
4312
+ let mut remote_fee_cost_incl_stuck_buffer_msat = self.next_remote_commit_tx_fee_msat(
4313
+ funding, None, fee_spike_buffer_htlc,
4314
+ );
4307
4315
if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
4308
4316
remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4309
4317
}
@@ -4845,10 +4853,15 @@ where
4845
4853
// and the answer will in turn change the amount itself — making it a circular
4846
4854
// dependency.
4847
4855
// This complicates the computation around dust-values, up to the one-htlc-value.
4856
+ let fee_spike_buffer_htlc = if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4857
+ None
4858
+ } else {
4859
+ Some(())
4860
+ };
4848
4861
let htlc_above_dust = HTLCCandidate::new(real_htlc_timeout_tx_fee_sat * 1000, HTLCInitiator::LocalOffered);
4849
- let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_above_dust, Some(()) );
4862
+ let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_above_dust, fee_spike_buffer_htlc );
4850
4863
let htlc_dust = HTLCCandidate::new(real_htlc_timeout_tx_fee_sat * 1000 - 1, HTLCInitiator::LocalOffered);
4851
- let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, Some(()) );
4864
+ let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, fee_spike_buffer_htlc );
4852
4865
if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
4853
4866
max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4854
4867
min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -4972,6 +4985,7 @@ where
4972
4985
4973
4986
if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
4974
4987
debug_assert_eq!(context.feerate_per_kw, 0);
4988
+ debug_assert!(fee_spike_buffer_htlc.is_none());
4975
4989
return 0;
4976
4990
}
4977
4991
@@ -5078,6 +5092,7 @@ where
5078
5092
) -> u64 {
5079
5093
if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
5080
5094
debug_assert_eq!(self.feerate_per_kw, 0);
5095
+ debug_assert!(fee_spike_buffer_htlc.is_none());
5081
5096
return 0
5082
5097
}
5083
5098
0 commit comments