@@ -5960,7 +5960,9 @@ impl<SP: SignerProvider> ChannelContext<SP> {
59605960 max_reserved_commit_tx_fee_msat as i64;
59615961 if capacity_minus_commitment_fee_msat < (real_dust_limit_timeout_sat as i64) * 1000 {
59625962 let one_htlc_difference_msat = max_reserved_commit_tx_fee_msat - min_reserved_commit_tx_fee_msat;
5963- debug_assert!(one_htlc_difference_msat != 0);
5963+ if !funding.get_channel_type().supports_anchor_zero_fee_commitments() {
5964+ debug_assert!(one_htlc_difference_msat != 0);
5965+ }
59645966 capacity_minus_commitment_fee_msat += one_htlc_difference_msat as i64;
59655967 capacity_minus_commitment_fee_msat = cmp::min(real_dust_limit_timeout_sat as i64 * 1000 - 1, capacity_minus_commitment_fee_msat);
59665968 available_capacity_msat = cmp::max(0, cmp::min(capacity_minus_commitment_fee_msat, available_capacity_msat as i64)) as u64;
@@ -12720,20 +12722,34 @@ where
1272012722 &self, funding: &FundingScope,
1272112723 ) -> Result<(Amount, Amount), String> {
1272212724 let include_counterparty_unknown_htlcs = true;
12723- // Make sure that that the funder of the channel can pay the transaction fees for an additional
12724- // nondust HTLC on the channel.
12725- let addl_nondust_htlc_count = 1;
1272612725 // We are not interested in dust exposure
1272712726 let dust_exposure_limiting_feerate = None;
1272812727
12728+ let addl_nondust_htlc_count =
12729+ if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
12730+ 0
12731+ } else {
12732+ // Require the channel opener to reserve enough funds to pay the fees for an
12733+ // additional non-dust HTLC in the channel.
12734+ 1
12735+ };
12736+
12737+ let feerate_per_kw = if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
12738+ // Similar to HTLC additions, require the funder to have enough funds reserved for
12739+ // fees such that the feerate can jump without rendering the channel useless.
12740+ self.context.feerate_per_kw * FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE as u32
12741+ } else {
12742+ self.context.feerate_per_kw
12743+ };
12744+
1272912745 let local_commitment_stats = self
1273012746 .context
1273112747 .get_next_local_commitment_stats(
1273212748 funding,
1273312749 None, // htlc_candidate
1273412750 include_counterparty_unknown_htlcs,
1273512751 addl_nondust_htlc_count,
12736- self.context. feerate_per_kw,
12752+ feerate_per_kw,
1273712753 dust_exposure_limiting_feerate,
1273812754 )
1273912755 .map_err(|()| "Balance after HTLCs and anchors exhausted on local commitment")?;
@@ -12749,7 +12765,7 @@ where
1274912765 None, // htlc_candidate
1275012766 include_counterparty_unknown_htlcs,
1275112767 addl_nondust_htlc_count,
12752- self.context. feerate_per_kw,
12768+ feerate_per_kw,
1275312769 dust_exposure_limiting_feerate,
1275412770 )
1275512771 .map_err(|()| "Balance after HTLCs and anchors exhausted on remote commitment")?;
0 commit comments