Fix overflow in ProbabilisticScorer
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 24 Mar 2022 23:21:29 +0000 (18:21 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 25 Mar 2022 14:16:22 +0000 (09:16 -0500)
commit4ea18e323292ddee00c84cad8bfdb3bb2bc64306
treeda2cd564784b3179c76c280a0983a19b3342796e
parent5b36449c5950a78ae1857985c8ce309cdf091cc9
Fix overflow in ProbabilisticScorer

When a routing hint is given in an invoice, the effective capacity of
the channel is assumed to be infinite (i.e., u64::max_value) if the hop
is private. Adding 1 to this in the success probability calculation will
cause an overflow and ultimately an `index out of bounds panic` in
log10_times_1024. This was not an issue with using log10 because the use
of f64 would give infinite which casts to 0 for u64.
lightning/src/routing/scoring.rs