From: Matt Corallo Date: Tue, 14 Aug 2018 20:40:40 +0000 (-0400) Subject: Err from get_route if the requested value is more than 21m BTC X-Git-Tag: v0.0.12~351^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=0e6f028c3b6f9ce96e4abd3958923903b0ba6e65;p=rust-lightning Err from get_route if the requested value is more than 21m BTC This fixes a potential overflow panic. --- diff --git a/src/ln/router.rs b/src/ln/router.rs index 727a58587..5aaea4f67 100644 --- a/src/ln/router.rs +++ b/src/ln/router.rs @@ -387,6 +387,10 @@ impl Router { return Err(HandleError{err: "Cannot generate a route to ourselves", action: None}); } + if final_value_msat > 21_000_000 * 1_0000_0000 * 1000 { + return Err(HandleError{err: "Cannot generate a route of more value than all existing satoshis", action: None}); + } + // We do a dest-to-source Dijkstra's sorting by each node's distance from the destination // plus the minimum per-HTLC fee to get from it to another node (aka "shitty A*"). // TODO: There are a few tweaks we could do, including possibly pre-calculating more stuff