Update route hint selection to prefer lowest channel above minimum
authorFred Walker <freddiekrugerrand@protonmail.com>
Sat, 18 Mar 2023 14:11:29 +0000 (10:11 -0400)
committerFred Walker <freddiekrugerrand@protonmail.com>
Thu, 6 Apr 2023 09:04:48 +0000 (11:04 +0200)
commit5b8af341e84bac7d7eb2344b12d4c43918922804
treeb4dc754ebc4f792d60d6378460792435431ea874
parent0e28bcb704446a376f0c9be449de03fbb22a431f
Update route hint selection to prefer lowest channel above minimum

This commit updates the way that we choose our preferred channel per
counterparty when selecting route hints. Previously, we would choose
the largest usable channel above our requested minimum.

This change updates selection to prefer the smallest channel above the
minimum amount (if provided, plus a scaling factor of 10% to allow
some margin for error). This is the off chain version of not "grinding
our change" - we want to supply route hints for channels that have
enough inbound to facilitate the receive, but not overload our high
inbound channels with smaller payments (since we may need this large
chunk of inbound for larger payment later on).

If there is no minimum amount provided, we err on the side of caution
and just select our highest inbound channels so that payments of any
size have a chance of succeeding. Likewise, if we have no channels above
the minimum, we select the largest channel to maximize our changes of
receiving the payment in multiple parts.
lightning-invoice/src/utils.rs