routing: add handling for blinded errors from final node

We do not expect blinding errors from the final node:
1. If the introduction is the recipient, they should use regular errors.
2. Otherwise, nodes have no business sending this error when they are
   not part of a blinded route.
This commit is contained in:
Carla Kirk-Cohen committed 2023-12-18 12:07:56 -05:00
1 parent 7ce3a152a1
commit 4071db77b5
2 files changed
+65

No files matched your search

+50
View File
@@ -106,6 +106,21 @@ var (
{PubKeyBytes: hops[3], AmtToForward: 58},
},
}
// blindedIntroReceiver is a blinded path where the introduction node
// is the recipient.
blindedIntroReceiver = route.Route{
SourcePubKey: hops[0],
TotalAmount: 100,
Hops: []*route.Hop{
{PubKeyBytes: hops[1], AmtToForward: 95},
{
PubKeyBytes: hops[2],
AmtToForward: 90,
BlindingPoint: blindingPoint,
},
},
}
)
func getTestPair(from, to int) DirectedNodePair {
@@ -574,6 +589,41 @@ var resultTestCases = []resultTestCase{
nodeFailure: &hops[1],
},
},
// A node in a non-blinded route returns a blinding related error.
{
name: "final node unexpected blinding",
route: &routeThreeHop,
failureSrcIdx: 3,
failure: &lnwire.FailInvalidBlinding{},
expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): successPairResult(100),
getTestPair(1, 2): successPairResult(99),
getTestPair(2, 3): failPairResult(0),
getTestPair(3, 2): failPairResult(0),
},
nodeFailure: &hops[3],
finalFailureReason: &reasonError,
},
},
// Introduction node returns invalid blinding erroneously.
{
name: "final node intro blinding",
route: &blindedIntroReceiver,
failureSrcIdx: 2,
failure: &lnwire.FailInvalidBlinding{},
expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): successPairResult(100),
getTestPair(1, 2): failPairResult(0),
getTestPair(2, 1): failPairResult(0),
},
nodeFailure: &hops[2],
finalFailureReason: &reasonError,
},
},
}
// TestResultInterpretation executes a list of test cases that test the result