Skip to content

Commit 034df60

Browse files
committed
routing: assume TLV payloads everywhere
This commit removes another check for TLV payload support of the destination node. We assume TLV payloads as the default everywhere else, so we just remove two checks that were previously forgotten.
1 parent a460d68 commit 034df60

File tree

2 files changed

+4
-62
lines changed

2 files changed

+4
-62
lines changed

routing/pathfind.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -551,34 +551,16 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
551551
return nil, 0, errMissingDependentFeature
552552
}
553553

554-
// Now that we know the feature vector is well formed, we'll proceed in
555-
// checking that it supports the features we need, given our
556-
// restrictions on the final hop.
557-
558-
// If the caller needs to send custom records, check that our
559-
// destination feature vector supports TLV.
560-
if len(r.DestCustomRecords) > 0 &&
561-
!features.HasFeature(lnwire.TLVOnionPayloadOptional) {
562-
563-
return nil, 0, errNoTlvPayload
564-
}
565-
566-
// If the caller has a payment address to attach, check that our
567-
// destination feature vector supports them.
554+
// Now that we know the feature vector is well-formed, we'll proceed in
555+
// checking that it supports the features we need. If the caller has a
556+
// payment address to attach, check that our destination feature vector
557+
// supports them.
568558
if r.PaymentAddr != nil &&
569559
!features.HasFeature(lnwire.PaymentAddrOptional) {
570560

571561
return nil, 0, errNoPaymentAddr
572562
}
573563

574-
// If the caller needs to send custom records, check that our
575-
// destination feature vector supports TLV.
576-
if r.Metadata != nil &&
577-
!features.HasFeature(lnwire.TLVOnionPayloadOptional) {
578-
579-
return nil, 0, errNoTlvPayload
580-
}
581-
582564
// Set up outgoing channel map for quicker access.
583565
var outgoingChanMap map[uint64]struct{}
584566
if len(r.OutgoingChannelIDs) > 0 {

routing/pathfind_test.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,6 @@ func runFindPathWithMetadata(t *testing.T, useCache bool) {
882882

883883
_, err = ctx.findPath(target, paymentAmt)
884884
require.ErrorIs(t, errNoPathFound, err)
885-
886-
// Assert that tlv payload support takes precedence over metadata
887-
// issues.
888-
ctx.restrictParams.DestFeatures = lnwire.EmptyFeatureVector()
889-
890-
_, err = ctx.findPath(target, paymentAmt)
891-
require.ErrorIs(t, errNoTlvPayload, err)
892885
}
893886

894887
// runFindLowestFeePath tests that out of two routes with identical total
@@ -1261,20 +1254,6 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
12611254
restrictions := *noRestrictions
12621255
restrictions.DestCustomRecords = record.CustomSet{70000: []byte{}}
12631256

1264-
_, err = find(&restrictions)
1265-
if err != errNoTlvPayload {
1266-
t.Fatalf("path shouldn't have been found: %v", err)
1267-
}
1268-
1269-
// Set empty dest features so we don't try the fallback. We should still
1270-
// fail since the tlv feature isn't set.
1271-
restrictions.DestFeatures = lnwire.EmptyFeatureVector()
1272-
1273-
_, err = find(&restrictions)
1274-
if err != errNoTlvPayload {
1275-
t.Fatalf("path shouldn't have been found: %v", err)
1276-
}
1277-
12781257
// Finally, set the tlv feature in the payload and assert we found the
12791258
// same path as before.
12801259
restrictions.DestFeatures = tlvFeatures
@@ -1775,31 +1754,12 @@ func runDestTLVGraphFallback(t *testing.T, useCache bool) {
17751754
// Add custom records w/o any dest features.
17761755
restrictions.DestCustomRecords = record.CustomSet{70000: []byte{}}
17771756

1778-
// Path to luoji should fail because his node ann features are empty.
1779-
_, err = find(&restrictions, luoji)
1780-
if err != errNoTlvPayload {
1781-
t.Fatalf("path shouldn't have been found: %v", err)
1782-
}
1783-
17841757
// However, path to satoshi should succeed via the fallback because his
17851758
// node ann features have the TLV bit.
17861759
path, err := find(&restrictions, satoshi)
17871760
require.NoError(t, err, "path should have been found")
17881761
assertExpectedPath(t, ctx.testGraphInstance.aliasMap, path, "satoshi")
17891762

1790-
// Add empty destination features. This should cause both paths to fail,
1791-
// since this override anything in the graph.
1792-
restrictions.DestFeatures = lnwire.EmptyFeatureVector()
1793-
1794-
_, err = find(&restrictions, luoji)
1795-
if err != errNoTlvPayload {
1796-
t.Fatalf("path shouldn't have been found: %v", err)
1797-
}
1798-
_, err = find(&restrictions, satoshi)
1799-
if err != errNoTlvPayload {
1800-
t.Fatalf("path shouldn't have been found: %v", err)
1801-
}
1802-
18031763
// Finally, set the TLV dest feature. We should succeed in finding a
18041764
// path to luoji.
18051765
restrictions.DestFeatures = tlvFeatures

0 commit comments

Comments
 (0)