mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
routing+refactor: let BlindedEdge carry BlindedPayment
This commit is purely a refactor. In it, we let the `BlindedEdge` struct carry a pointer to the `BlindedPayment` that it was derived from. This is done now because later on in the PR series, we will need more information about the `BlindedPayment` that an edge was derived from. Since we now pass in the whole BlindedPayment, we swap out the `cipherText` member for a `hopIndex` member so that we dont carry around two sources of truth in the same struct.
This commit is contained in:
@ -128,7 +128,9 @@ func TestBlindedPaymentToHints(t *testing.T) {
|
||||
HtlcMaximum: htlcMax,
|
||||
Features: features,
|
||||
}
|
||||
require.Nil(t, blindedPayment.toRouteHints())
|
||||
hints, err := blindedPayment.toRouteHints()
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, hints)
|
||||
|
||||
// Populate the blinded payment with hops.
|
||||
blindedPayment.BlindedPath.BlindedHops = []*sphinx.BlindedHopInfo{
|
||||
@ -146,41 +148,43 @@ func TestBlindedPaymentToHints(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
policy1 := &models.CachedEdgePolicy{
|
||||
TimeLockDelta: cltvDelta,
|
||||
MinHTLC: lnwire.MilliSatoshi(htlcMin),
|
||||
MaxHTLC: lnwire.MilliSatoshi(htlcMax),
|
||||
FeeBaseMSat: lnwire.MilliSatoshi(baseFee),
|
||||
FeeProportionalMillionths: lnwire.MilliSatoshi(
|
||||
ppmFee,
|
||||
),
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return vb2
|
||||
},
|
||||
ToNodeFeatures: features,
|
||||
}
|
||||
policy2 := &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return vb3
|
||||
},
|
||||
ToNodeFeatures: features,
|
||||
}
|
||||
|
||||
blindedEdge1, err := NewBlindedEdge(policy1, blindedPayment, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
blindedEdge2, err := NewBlindedEdge(policy2, blindedPayment, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
expected := RouteHints{
|
||||
v1: {
|
||||
//nolint:lll
|
||||
&BlindedEdge{
|
||||
policy: &models.CachedEdgePolicy{
|
||||
TimeLockDelta: cltvDelta,
|
||||
MinHTLC: lnwire.MilliSatoshi(htlcMin),
|
||||
MaxHTLC: lnwire.MilliSatoshi(htlcMax),
|
||||
FeeBaseMSat: lnwire.MilliSatoshi(baseFee),
|
||||
FeeProportionalMillionths: lnwire.MilliSatoshi(
|
||||
ppmFee,
|
||||
),
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return vb2
|
||||
},
|
||||
ToNodeFeatures: features,
|
||||
},
|
||||
blindingPoint: blindedPoint,
|
||||
cipherText: cipherText,
|
||||
},
|
||||
blindedEdge1,
|
||||
},
|
||||
vb2: {
|
||||
&BlindedEdge{
|
||||
policy: &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return vb3
|
||||
},
|
||||
ToNodeFeatures: features,
|
||||
},
|
||||
cipherText: cipherText,
|
||||
},
|
||||
blindedEdge2,
|
||||
},
|
||||
}
|
||||
|
||||
actual := blindedPayment.toRouteHints()
|
||||
actual, err := blindedPayment.toRouteHints()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(expected), len(actual))
|
||||
for vertex, expectedHint := range expected {
|
||||
|
Reference in New Issue
Block a user