routing: Fix possible infinite loop on first hop misleading hint

Add ignore condition to additional edges that connect to self. These
edges are already known and avoiding these hints protect the payment
from malformed channel ids which could lead to infinite loop.

Fixes lightningnetwork#6169.

Co-authored-by: lsunsi <lsunsi@pm.me>
This commit is contained in:
andreihod
2022-09-12 20:58:58 -03:00
parent bcdf24b15e
commit befa1b7cf0
6 changed files with 176 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"testing"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwire"
@@ -13,7 +14,12 @@ import (
// createPubkey return a new test pubkey.
func createPubkey(id byte) route.Vertex {
pubkey := route.Vertex{id}
_, secpPub := btcec.PrivKeyFromBytes([]byte{id})
var bytes [33]byte
copy(bytes[:], secpPub.SerializeCompressed()[:33])
pubkey := route.Vertex(bytes)
return pubkey
}