You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stop including dust values in feerate affordability checks
When we or our counterparty are updating the fees on the channel,
we currently check that the resulting balance is sufficient not
only to meet the reserve threshold, but also not push it below
dust. This isn't required in the BOLTs and may lead to spurious
force-closures (which would be a bit safer, but reserve should
always exceed the dust threshold).
Worse, the current logic is broken - it compares the output value
in *billionths of satoshis* to the dust limit in satoshis. Thus,
the code is borderline dead anyway, but can overflow for channels
with several million Bitcoin, causing the fuzzer to get mad (and
lead to spurious force-closures for few-billion-dollar channels).
Copy file name to clipboardExpand all lines: lightning/src/ln/channel.rs
+4-8Lines changed: 4 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -732,8 +732,8 @@ struct CommitmentStats<'a> {
732
732
total_fee_sat: u64, // the total fee included in the transaction
733
733
num_nondust_htlcs: usize, // the number of HTLC outputs (dust HTLCs *non*-included)
734
734
htlcs_included: Vec<(HTLCOutputInCommitment, Option<&'a HTLCSource>)>, // the list of HTLCs (dust HTLCs *included*) which were not ignored when building the transaction
735
-
local_balance_msat: u64, // local balance before fees but considering dust limits
736
-
remote_balance_msat: u64, // remote balance before fees but considering dust limits
735
+
local_balance_msat: u64, // local balance before fees *not* considering dust limits
let mut value_to_self_msat: i64 = (self.value_to_self_msat - local_htlc_total_msat) as i64 + value_to_self_msat_offset;
1731
+
let value_to_self_msat: i64 = (self.value_to_self_msat - local_htlc_total_msat) as i64 + value_to_self_msat_offset;
1732
1732
assert!(value_to_self_msat >= 0);
1733
1733
// Note that in case they have several just-awaiting-last-RAA fulfills in-progress (ie
1734
1734
// AwaitingRemoteRevokeToRemove or AwaitingRemovedRemoteRevoke) we may have allowed them to
1735
1735
// "violate" their reserve value by couting those against it. Thus, we have to convert
1736
1736
// everything to i64 before subtracting as otherwise we can overflow.
1737
-
let mut value_to_remote_msat: i64 = (self.channel_value_satoshis * 1000) as i64 - (self.value_to_self_msat as i64) - (remote_htlc_total_msat as i64) - value_to_self_msat_offset;
1737
+
let value_to_remote_msat: i64 = (self.channel_value_satoshis * 1000) as i64 - (self.value_to_self_msat as i64) - (remote_htlc_total_msat as i64) - value_to_self_msat_offset;
0 commit comments