Skip to content

Commit b51e86e

Browse files
committed
Use saturating_add when adding inflight HTLCs values
Previously this calculation could overflow, leading to panicking in `debug`.
1 parent 4bd4c7d commit b51e86e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning/src/routing/router.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'a, SP: Sized, Sc: 'a + ScoreLookUp<ScoreParams = SP>, S: Deref<Target = Sc
139139
source, target, short_channel_id
140140
) {
141141
let usage = ChannelUsage {
142-
inflight_htlc_msat: usage.inflight_htlc_msat + used_liquidity,
142+
inflight_htlc_msat: usage.inflight_htlc_msat.saturating_add(used_liquidity),
143143
..usage
144144
};
145145

0 commit comments

Comments
 (0)