@@ -1692,9 +1692,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1692
1692
}
1693
1693
1694
1694
let htlc_above_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000, HTLCInitiator::LocalOffered);
1695
- let max_reserved_commit_tx_fee_msat = FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE * context.next_local_commit_tx_fee_msat(htlc_above_dust, Some(()));
1695
+ let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(htlc_above_dust, Some(()));
1696
1696
let htlc_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000 - 1, HTLCInitiator::LocalOffered);
1697
- let min_reserved_commit_tx_fee_msat = FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE * context.next_local_commit_tx_fee_msat(htlc_dust, Some(()));
1697
+ let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(htlc_dust, Some(()));
1698
+ if !context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
1699
+ max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
1700
+ min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
1701
+ }
1698
1702
1699
1703
// We will first subtract the fee as if we were above-dust. Then, if the resulting
1700
1704
// value ends up being below dust, we have this fee available again. In that case,
@@ -2856,16 +2860,15 @@ impl<SP: Deref> Channel<SP> where
2856
2860
0
2857
2861
};
2858
2862
if !self.context.is_outbound() {
2859
- // `2 *` and `Some(())` is for the fee spike buffer we keep for the remote. This deviates from
2860
- // the spec because in the spec, the fee spike buffer requirement doesn't exist on the
2861
- // receiver's side, only on the sender's.
2862
- // Note that when we eventually remove support for fee updates and switch to anchor output
2863
- // fees, we will drop the `2 *`, since we no longer be as sensitive to fee spikes. But, keep
2864
- // the extra htlc when calculating the next remote commitment transaction fee as we should
2865
- // still be able to afford adding this HTLC plus one more future HTLC, regardless of being
2866
- // sensitive to fee spikes.
2863
+ // `Some(())` is for the fee spike buffer we keep for the remote. This deviates from
2864
+ // the spec because the fee spike buffer requirement doesn't exist on the receiver's
2865
+ // side, only on the sender's. Note that with anchor outputs we are no longer as
2866
+ // sensitive to fee spikes, so we need to account for them.
2867
2867
let htlc_candidate = HTLCCandidate::new(msg.amount_msat, HTLCInitiator::RemoteOffered);
2868
- let remote_fee_cost_incl_stuck_buffer_msat = 2 * self.context.next_remote_commit_tx_fee_msat(htlc_candidate, Some(()));
2868
+ let mut remote_fee_cost_incl_stuck_buffer_msat = self.context.next_remote_commit_tx_fee_msat(htlc_candidate, Some(()));
2869
+ if !self.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
2870
+ remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
2871
+ }
2869
2872
if pending_remote_value_msat.saturating_sub(msg.amount_msat).saturating_sub(self.context.holder_selected_channel_reserve_satoshis * 1000).saturating_sub(anchor_outputs_value_msat) < remote_fee_cost_incl_stuck_buffer_msat {
2870
2873
// Note that if the pending_forward_status is not updated here, then it's because we're already failing
2871
2874
// the HTLC, i.e. its status is already set to failing.
0 commit comments