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:
andreihodandlsunsi committed 2022-11-11 04:23:55 -03:00
1 parent bcdf24b15e
commit befa1b7cf0
6 files changed
+176 -1

No files matched your search

+7 -1
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
}