lnd icon indicating copy to clipboard operation
lnd copied to clipboard

addinvoice: refacor hint hop selection algorithm

Open positiveblue opened this issue 3 years ago • 1 comments

In order to reduce the number of calls to the db we try to process as few channels as we can + try to not do extra work for each of them.

  • First fetch all the channels. Then, filter all the public ones and sort the potential candidates by remote balance.

  • Filter out each potential candidate as soon as possible.

  • Only check the alias if the channel supports scid aliases.

  • Because we sort the channels by remote balance, we will hit the target amount, if possible, as soon as we can.

We do not want to leak extra information about our remote balances, so we shuffle the hop hints (the forced ones go always first) so the invoice receiver does not know which channels have more balance than others.

Steps to Test

cd lnrpc/invoicesrpc
go test ./...

Fixes #6898

positiveblue avatar Sep 13 '22 21:09 positiveblue

Related ish: https://github.com/lightningnetwork/lnd/pull/4679

Roasbeef avatar Sep 14 '22 00:09 Roasbeef

@roasbeef: review reminder

lightninglabs-deploy avatar Sep 26 '22 00:09 lightninglabs-deploy