Skip to content

Commit bd710b4

Browse files
author
Antoine Riard
committed
-f use helpers
1 parent 28c124f commit bd710b4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lightning/src/ln/channel.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2954,17 +2954,16 @@ impl<Signer: Sign> Channel<Signer> {
29542954
}
29552955

29562956
// Before to propose a feerate update, check that we can actually afford the new fee compare to the holder balance.
2957-
let num_htlcs = self.pending_inbound_htlcs.len() + self.pending_outbound_htlcs.len();
2958-
let total_fee = feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + (num_htlcs as u64) * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
2957+
let inbound_stats = self.get_inbound_pending_htlc_stats(Some(feerate_per_kw));
2958+
let outbound_stats = self.get_outbound_pending_htlc_stats(Some(feerate_per_kw));
2959+
let total_fee = feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + (inbound_stats.pending_htlcs as u64 + outbound_stats.pending_htlcs as u64) * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
29592960
if self.value_to_self_msat / 1000 - total_fee < self.counterparty_selected_channel_reserve_satoshis.unwrap() {
29602961
log_debug!(logger, "Cannot afford to send new feerate at {}", feerate_per_kw);
29612962
return None;
29622963
}
29632964

29642965
if feerate_per_kw > self.get_dust_buffer_feerate(None) {
29652966
// Note, we evaluate pending htlc "preemptive" trimmed-to-dust threshold at the proposed `feerate_per_kw`.
2966-
let inbound_stats = self.get_inbound_pending_htlc_stats(Some(feerate_per_kw));
2967-
let outbound_stats = self.get_outbound_pending_htlc_stats(Some(feerate_per_kw));
29682967
let holder_tx_dust_exposure = inbound_stats.on_holder_tx_dust_exposure_msat + outbound_stats.on_holder_tx_dust_exposure_msat;
29692968
let counterparty_tx_dust_exposure = inbound_stats.on_counterparty_tx_dust_exposure_msat + outbound_stats.on_counterparty_tx_dust_exposure_msat;
29702969
if holder_tx_dust_exposure > self.get_max_dust_htlc_exposure_msat() {

0 commit comments

Comments
 (0)