Skip to content

Commit b650bf8

Browse files
author
Antoine Riard
committed
-f fix matt/val comments
1 parent fe35561 commit b650bf8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lightning/src/ln/channel.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2953,11 +2953,12 @@ impl<Signer: Sign> Channel<Signer> {
29532953
panic!("Cannot update fee while peer is disconnected/we're awaiting a monitor update (ChannelManager should have caught this)");
29542954
}
29552955

2956-
// Before to propose a feerate update, check that we can actually afford the new fee compare to the holder balance.
2956+
// Before proposing a feerate update, check that we can actually afford the new fee.
29572957
let inbound_stats = self.get_inbound_pending_htlc_stats(Some(feerate_per_kw));
29582958
let outbound_stats = self.get_outbound_pending_htlc_stats(Some(feerate_per_kw));
29592959
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;
2960-
if self.value_to_self_msat / 1000 - total_fee - outbound_stats.pending_htlcs_value_msat < self.counterparty_selected_channel_reserve_satoshis.unwrap() {
2960+
let holder_balance_after_fee_sub = (self.value_to_self_msat / 1000).checked_sub(total_fee).map(|a| a.checked_sub(outbound_stats.pending_htlcs_value_msat / 1000)).unwrap_or(None).unwrap_or(u64::max_value());
2961+
if holder_balance_after_fee_sub < self.counterparty_selected_channel_reserve_satoshis.unwrap() {
29612962
log_debug!(logger, "Cannot afford to send new feerate at {}", feerate_per_kw);
29622963
return None;
29632964
}

0 commit comments

Comments
 (0)