Skip to content

Commit 133e661

Browse files
committed
Add excess fees, not total fees, to the htlc dust exposure
We previously added all the fees of the candidate incoming htlc to the htlc dust exposure. In-line with the documentation, only add the fees in excess of our local fee estimates.
1 parent 35dd3a8 commit 133e661

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7333,14 +7333,17 @@ impl<SP: Deref> FundedChannel<SP> where
73337333
return Err(("Exceeded our dust exposure limit on counterparty commitment tx", 0x1000|7))
73347334
}
73357335
} else {
7336-
let htlc_dust_exposure_msat =
7337-
per_outbound_htlc_counterparty_commit_tx_fee_msat(self.context.feerate_per_kw, &self.context.channel_type);
7338-
let counterparty_tx_dust_exposure =
7339-
htlc_stats.on_counterparty_tx_dust_exposure_msat.saturating_add(htlc_dust_exposure_msat);
7340-
if counterparty_tx_dust_exposure > max_dust_htlc_exposure_msat {
7341-
log_info!(logger, "Cannot accept value that would put our exposure to tx fee dust at {} over the limit {} on counterparty commitment tx",
7342-
counterparty_tx_dust_exposure, max_dust_htlc_exposure_msat);
7343-
return Err(("Exceeded our tx fee dust exposure limit on counterparty commitment tx", 0x1000|7))
7336+
let excess_feerate_opt = self.context.feerate_per_kw.checked_sub(dust_exposure_limiting_feerate);
7337+
if let Some(excess_feerate) = excess_feerate_opt {
7338+
let htlc_dust_exposure_msat =
7339+
per_outbound_htlc_counterparty_commit_tx_fee_msat(excess_feerate, &self.context.channel_type);
7340+
let counterparty_tx_dust_exposure =
7341+
htlc_stats.on_counterparty_tx_dust_exposure_msat.saturating_add(htlc_dust_exposure_msat);
7342+
if counterparty_tx_dust_exposure > max_dust_htlc_exposure_msat {
7343+
log_info!(logger, "Cannot accept value that would put our exposure to tx fee dust at {} over the limit {} on counterparty commitment tx",
7344+
counterparty_tx_dust_exposure, max_dust_htlc_exposure_msat);
7345+
return Err(("Exceeded our tx fee dust exposure limit on counterparty commitment tx", 0x1000|7))
7346+
}
73447347
}
73457348
}
73467349

0 commit comments

Comments
 (0)