@@ -7319,30 +7319,19 @@ impl<SP: Deref> FundedChannel<SP> where
73197319 let dust_exposure_limiting_feerate = self.context.get_dust_exposure_limiting_feerate(&fee_estimator);
73207320 let htlc_stats = self.context.get_pending_htlc_stats(None, dust_exposure_limiting_feerate);
73217321 let max_dust_htlc_exposure_msat = self.context.get_max_dust_htlc_exposure_msat(dust_exposure_limiting_feerate);
7322- let (htlc_timeout_dust_limit, htlc_success_dust_limit) = if self.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
7323- (0, 0)
7322+ let on_counterparty_tx_dust_htlc_exposure_msat = htlc_stats.on_counterparty_tx_dust_exposure_msat;
7323+ // Note that the total dust exposure includes both the dust HTLCs and the excess mining fees of the counterparty commitment transaction
7324+ if on_counterparty_tx_dust_htlc_exposure_msat > max_dust_htlc_exposure_msat {
7325+ log_info!(logger, "Cannot accept value that would put our total dust exposure at {} over the limit {} on counterparty commitment tx",
7326+ on_counterparty_tx_dust_htlc_exposure_msat, max_dust_htlc_exposure_msat);
7327+ return Err(("Exceeded our total dust exposure limit on counterparty commitment tx", 0x1000|7))
7328+ }
7329+ let htlc_success_dust_limit = if self.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
7330+ 0
73247331 } else {
73257332 let dust_buffer_feerate = self.context.get_dust_buffer_feerate(None) as u64;
7326- (dust_buffer_feerate * htlc_timeout_tx_weight(self.context.get_channel_type()) / 1000,
7327- dust_buffer_feerate * htlc_success_tx_weight(self.context.get_channel_type()) / 1000)
7333+ dust_buffer_feerate * htlc_success_tx_weight(self.context.get_channel_type()) / 1000
73287334 };
7329- let exposure_dust_limit_timeout_sats = htlc_timeout_dust_limit + self.context.counterparty_dust_limit_satoshis;
7330- if msg.amount_msat / 1000 < exposure_dust_limit_timeout_sats {
7331- let on_counterparty_tx_dust_htlc_exposure_msat = htlc_stats.on_counterparty_tx_dust_exposure_msat;
7332- if on_counterparty_tx_dust_htlc_exposure_msat > max_dust_htlc_exposure_msat {
7333- log_info!(logger, "Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on counterparty commitment tx",
7334- on_counterparty_tx_dust_htlc_exposure_msat, max_dust_htlc_exposure_msat);
7335- return Err(("Exceeded our dust exposure limit on counterparty commitment tx", 0x1000|7))
7336- }
7337- } else {
7338- let on_counterparty_tx_dust_htlc_exposure_msat = htlc_stats.on_counterparty_tx_dust_exposure_msat;
7339- if on_counterparty_tx_dust_htlc_exposure_msat > max_dust_htlc_exposure_msat {
7340- log_info!(logger, "Cannot accept value that would put our exposure to tx fee dust at {} over the limit {} on counterparty commitment tx",
7341- on_counterparty_tx_dust_htlc_exposure_msat, max_dust_htlc_exposure_msat);
7342- return Err(("Exceeded our tx fee dust exposure limit on counterparty commitment tx", 0x1000|7))
7343- }
7344- }
7345-
73467335 let exposure_dust_limit_success_sats = htlc_success_dust_limit + self.context.holder_dust_limit_satoshis;
73477336 if msg.amount_msat / 1000 < exposure_dust_limit_success_sats {
73487337 let on_holder_tx_dust_htlc_exposure_msat = htlc_stats.on_holder_tx_dust_exposure_msat;
0 commit comments