]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Use `saturating_add` when adding inflight HTLCs values
authorElias Rohrer <dev@tnull.de>
Thu, 14 Sep 2023 12:14:03 +0000 (14:14 +0200)
committerElias Rohrer <dev@tnull.de>
Thu, 28 Sep 2023 08:14:35 +0000 (10:14 +0200)
Previously this calculation could overflow, leading to panicking in `debug`.

lightning/src/routing/router.rs

index 09d83bb785cdfe1d9ac2786cce278311a6279648..0e3bc96ea00635a44becbda9f2d1bd3ff9c3bbe6 100644 (file)
@@ -139,7 +139,7 @@ impl<'a, SP: Sized, Sc: 'a + ScoreLookUp<ScoreParams = SP>, S: Deref<Target = Sc
                        source, target, short_channel_id
                ) {
                        let usage = ChannelUsage {
-                               inflight_htlc_msat: usage.inflight_htlc_msat + used_liquidity,
+                               inflight_htlc_msat: usage.inflight_htlc_msat.saturating_add(used_liquidity),
                                ..usage
                        };