Skip to content

Commit 607543c

Browse files
committed
f: remove unnecessary branch
1 parent 9bea4ce commit 607543c

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,7 +10460,7 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
1046010460
} else {
1046110461
// Outbound dust balance: 5200 sats
1046210462
nodes[0].logger.assert_log("lightning::ln::channel",
10463-
format!("Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on counterparty commitment tx",
10463+
format!("Cannot accept value that would put our total dust exposure at {} over the limit {} on counterparty commitment tx",
1046410464
dust_htlc_on_counterparty_tx_msat * dust_htlc_on_counterparty_tx + commitment_tx_cost + 4,
1046510465
max_dust_htlc_exposure_msat), 1);
1046610466
}
@@ -10709,7 +10709,7 @@ fn do_test_nondust_htlc_fees_dust_exposure_delta(features: ChannelTypeFeatures)
1070910709
expect_pending_htlcs_forwardable!(nodes[1]);
1071010710
expect_htlc_handling_failed_destinations!(nodes[1].node.get_and_clear_pending_events(), &[HTLCDestination::FailedPayment { payment_hash }]);
1071110711
nodes[1].logger.assert_log("lightning::ln::channel",
10712-
format!("Cannot accept value that would put our exposure to tx fee dust at {} over the limit {} on counterparty commitment tx",
10712+
format!("Cannot accept value that would put our total dust exposure at {} over the limit {} on counterparty commitment tx",
1071310713
expected_dust_exposure_msat, expected_dust_exposure_msat - 1), 1);
1071410714
check_added_monitors!(nodes[1], 1);
1071510715

0 commit comments

Comments
 (0)