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:
6 files changed
+176
-1
No files matched your search
@@ -4,9 +4,11 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -234,6 +236,34 @@ var mppTestCases = []mppSendTestCase{
|
||||
},
|
||||
}
|
||||
|
||||
// TestBadFirstHopHint tests that a payment with a first hop hint with an
|
||||
// invalid channel id still works since the node already knows its channel and
|
||||
// doesn't need hints.
|
||||
func TestBadFirstHopHint(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := newIntegratedRoutingContext(t)
|
||||
|
||||
onePathGraph(ctx.graph)
|
||||
|
||||
sourcePubKey, _ := btcec.ParsePubKey(ctx.source.pubkey[:])
|
||||
|
||||
hopHint := zpay32.HopHint{
|
||||
NodeID: sourcePubKey,
|
||||
ChannelID: 66,
|
||||
FeeBaseMSat: 0,
|
||||
FeeProportionalMillionths: 0,
|
||||
CLTVExpiryDelta: 100,
|
||||
}
|
||||
|
||||
ctx.routeHints = [][]zpay32.HopHint{{hopHint}}
|
||||
|
||||
ctx.amt = lnwire.NewMSatFromSatoshis(100)
|
||||
_, err := ctx.testPayment(1)
|
||||
|
||||
require.NoError(t, err, "payment failed")
|
||||
}
|
||||
|
||||
// TestMppSend tests that a payment can be completed using multiple shards.
|
||||
func TestMppSend(t *testing.T) {
|
||||
for _, testCase := range mppTestCases {
|
||||
|
||||
Reference in new issue
Block a user