Skip to content

Commit 3b6a361

Browse files
committed
Fix dust buffer feerate calculation overflow
If a peer provides a feerate which nears `u32::MAX`, we may overflow calculating the dust buffer feerate, leading to spuriously keeping non-anchor channels open when they should be force-closed.
1 parent 5d8cd5a commit 3b6a361

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
18721872
if let Some(feerate) = outbound_feerate_update {
18731873
feerate_per_kw = cmp::max(feerate_per_kw, feerate);
18741874
}
1875-
cmp::max(2530, feerate_per_kw * 1250 / 1000)
1875+
let feerate_plus_quarter = feerate_per_kw.checked_mul(1250).map(|v| v / 1000);
1876+
cmp::max(2530, feerate_plus_quarter.unwrap_or(u32::max_value()))
18761877
}
18771878

18781879
/// Get forwarding information for the counterparty.

0 commit comments

Comments
 (0)