@@ -3831,13 +3831,20 @@ where
38313831 cmp::max(self.config.options.cltv_expiry_delta, MIN_CLTV_EXPIRY_DELTA)
38323832 }
38333833
3834+ /// Returns a maximum "sane" fee rate used to reason about our dust exposure.
3835+ /// Will be Some if the `channel_type`'s dust exposure depends on its commitment fee rate, and
3836+ /// None otherwise.
38343837 fn get_dust_exposure_limiting_feerate<F: Deref>(
3835- &self, fee_estimator: &LowerBoundedFeeEstimator<F>,
3838+ &self, fee_estimator: &LowerBoundedFeeEstimator<F>, channel_type: &ChannelTypeFeatures,
38363839 ) -> Option<u32>
38373840 where
38383841 F::Target: FeeEstimator,
38393842 {
3840- Some(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaximumFeeEstimate))
3843+ if channel_type.supports_anchor_zero_fee_commitments() {
3844+ None
3845+ } else {
3846+ Some(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaximumFeeEstimate))
3847+ }
38413848 }
38423849
38433850 /// Returns the maximum configured dust exposure.
@@ -3974,7 +3981,9 @@ where
39743981 return Err(ChannelError::close("Remote side tried to send more than the total value of the channel".to_owned()));
39753982 }
39763983
3977- let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(&fee_estimator);
3984+ let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(
3985+ &fee_estimator, funding.get_channel_type(),
3986+ );
39783987 let htlc_stats = self.get_pending_htlc_stats(funding, None, dust_exposure_limiting_feerate);
39793988 if htlc_stats.pending_inbound_htlcs + 1 > self.holder_max_accepted_htlcs as usize {
39803989 return Err(ChannelError::close(format!("Remote tried to push more than our max accepted HTLCs ({})", self.holder_max_accepted_htlcs)));
@@ -4058,7 +4067,9 @@ where
40584067 F::Target: FeeEstimator,
40594068 {
40604069 // Check that we won't be pushed over our dust exposure limit by the feerate increase.
4061- let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(&fee_estimator);
4070+ let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(
4071+ &fee_estimator, funding.get_channel_type(),
4072+ );
40624073 let htlc_stats = self.get_pending_htlc_stats(funding, None, dust_exposure_limiting_feerate);
40634074 let max_dust_htlc_exposure_msat = self.get_max_dust_htlc_exposure_msat(dust_exposure_limiting_feerate);
40644075 if htlc_stats.on_holder_tx_dust_exposure_msat > max_dust_htlc_exposure_msat {
@@ -4193,7 +4204,9 @@ where
41934204 L::Target: Logger,
41944205 {
41954206 // Before proposing a feerate update, check that we can actually afford the new fee.
4196- let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(&fee_estimator);
4207+ let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(
4208+ &fee_estimator, funding.get_channel_type(),
4209+ );
41974210 let htlc_stats = self.get_pending_htlc_stats(funding, Some(feerate_per_kw), dust_exposure_limiting_feerate);
41984211 let commitment_data = self.build_commitment_transaction(
41994212 funding, holder_commitment_point.transaction_number(),
@@ -4798,7 +4811,9 @@ where
47984811 // Note that we have to handle overflow due to the case mentioned in the docs in general
47994812 // here.
48004813
4801- let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(&fee_estimator);
4814+ let dust_exposure_limiting_feerate = self.get_dust_exposure_limiting_feerate(
4815+ &fee_estimator, funding.get_channel_type(),
4816+ );
48024817 let htlc_stats = context.get_pending_htlc_stats(funding, None, dust_exposure_limiting_feerate);
48034818
48044819 let outbound_capacity_msat = funding.value_to_self_msat
@@ -8514,7 +8529,9 @@ where
85148529 return Err(LocalHTLCFailureReason::ChannelClosed)
85158530 }
85168531
8517- let dust_exposure_limiting_feerate = self.context.get_dust_exposure_limiting_feerate(&fee_estimator);
8532+ let dust_exposure_limiting_feerate = self.context.get_dust_exposure_limiting_feerate(
8533+ &fee_estimator, self.funding.get_channel_type(),
8534+ );
85188535
85198536 core::iter::once(&self.funding)
85208537 .chain(self.pending_funding.iter())
0 commit comments