routing: swap out final hop blinded route pub keys

If multiple blinded paths are provided, they will each have a different
pub key for the destination node. This makes using our existing
pathfinding logic tricky since it depends on having a single destination
node (characterised by a single pub key). We want to re-use this logic.
So what we do is swap out the pub keys of the destinaion hop with a
pseudo target pub key. This will then be used during pathfinding. Later
on once a path is found, we will swap the real destination keys back in
so that onion creation can be done.
This commit is contained in:
Elle Mouton
2024-05-15 15:52:17 +02:00
parent 4a22ec8413
commit 8df03de3e9
6 changed files with 99 additions and 42 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/stretchr/testify/require"
@ -128,7 +129,7 @@ func TestBlindedPaymentToHints(t *testing.T) {
HtlcMaximum: htlcMax,
Features: features,
}
hints, err := blindedPayment.toRouteHints()
hints, err := blindedPayment.toRouteHints(fn.None[*btcec.PublicKey]())
require.NoError(t, err)
require.Nil(t, hints)
@ -183,7 +184,7 @@ func TestBlindedPaymentToHints(t *testing.T) {
},
}
actual, err := blindedPayment.toRouteHints()
actual, err := blindedPayment.toRouteHints(fn.None[*btcec.PublicKey]())
require.NoError(t, err)
require.Equal(t, len(expected), len(actual))