Skip to content

Commit de9fba8

Browse files
authored
Merge pull request #1072 from TheBlueMatt/2021-09-tighter-max_fee-constant
Reduce our stated max closing-transaction fee to be the true value
2 parents ce3a04b + b348d9c commit de9fba8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lightning/src/ln/channel.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ pub(super) struct Channel<Signer: Sign> {
454454
/// closing_signed message and handling it in `maybe_propose_closing_signed`.
455455
pending_counterparty_closing_signed: Option<msgs::ClosingSigned>,
456456

457-
/// The minimum and maximum absolute fee we are willing to place on the closing transaction.
458-
/// These are set once we reach `closing_negotiation_ready`.
457+
/// The minimum and maximum absolute fee, in satoshis, we are willing to place on the closing
458+
/// transaction. These are set once we reach `closing_negotiation_ready`.
459459
#[cfg(test)]
460460
pub(crate) closing_fee_limits: Option<(u64, u64)>,
461461
#[cfg(not(test))]
@@ -3414,7 +3414,7 @@ impl<Signer: Sign> Channel<Signer> {
34143414
cmp::max(normal_feerate as u64 * tx_weight / 1000 + self.config.force_close_avoidance_max_fee_satoshis,
34153415
proposed_max_feerate as u64 * tx_weight / 1000)
34163416
} else {
3417-
u64::max_value()
3417+
self.channel_value_satoshis - (self.value_to_self_msat + 999) / 1000
34183418
};
34193419

34203420
self.closing_fee_limits = Some((proposed_total_fee_satoshis, proposed_max_total_fee_satoshis));
@@ -3701,7 +3701,8 @@ impl<Signer: Sign> Channel<Signer> {
37013701

37023702
if !self.is_outbound() {
37033703
// They have to pay, so pick the highest fee in the overlapping range.
3704-
debug_assert_eq!(our_max_fee, u64::max_value()); // We should never set an upper bound
3704+
// We should never set an upper bound aside from their full balance
3705+
debug_assert_eq!(our_max_fee, self.channel_value_satoshis - (self.value_to_self_msat + 999) / 1000);
37053706
propose_fee!(cmp::min(max_fee_satoshis, our_max_fee));
37063707
} else {
37073708
if msg.fee_satoshis < our_min_fee || msg.fee_satoshis > our_max_fee {

0 commit comments

Comments
 (0)