multi: use new AdditionalEdge interface.

In the previous commit the AdditionalEdge interface was introduced
with both of its implementations `BlindedEdge` and `PrivateEdge`.
In both cases where we append a route either by a blinded route
section or private route hints we now use these new types. In
addition the `PayloadSizeFunc` type is introduced in the
`unifiedEdge` struct. This is necessary to have the payload size
function at hand when searching for a route hence not overshooting
the max sphinx package size of 1300 bytes.
This commit is contained in:
ziggie committed 2024-02-03 12:10:46 +00:00
1 parent 9d3c0d9e3a
commit c1b91fff14
12 files changed
+318 -98

No files matched your search

+33 -23
View File
@@ -99,7 +99,7 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
hintCount := len(b.BlindedPath.BlindedHops) - 1
hints := make(
map[route.Vertex][]*models.CachedEdgePolicy, hintCount,
RouteHints, hintCount,
)
// Start at the unblinded introduction node, because our pathfinding
@@ -116,25 +116,31 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
// will ensure that pathfinding provides sufficient fees/delay for the
// blinded portion to the introduction node.
firstBlindedHop := b.BlindedPath.BlindedHops[1].BlindedNodePub
hints[fromNode] = []*models.CachedEdgePolicy{
{
TimeLockDelta: b.CltvExpiryDelta,
MinHTLC: lnwire.MilliSatoshi(b.HtlcMinimum),
MaxHTLC: lnwire.MilliSatoshi(b.HtlcMaximum),
FeeBaseMSat: lnwire.MilliSatoshi(b.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(
b.ProportionalFee,
),
ToNodePubKey: func() route.Vertex {
return route.NewVertex(
// The first node in this slice is
// the introduction node, so we start
// at index 1 to get the first blinded
// relaying node.
firstBlindedHop,
)
},
ToNodeFeatures: features,
edgePolicy := &models.CachedEdgePolicy{
TimeLockDelta: b.CltvExpiryDelta,
MinHTLC: lnwire.MilliSatoshi(b.HtlcMinimum),
MaxHTLC: lnwire.MilliSatoshi(b.HtlcMaximum),
FeeBaseMSat: lnwire.MilliSatoshi(b.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(
b.ProportionalFee,
),
ToNodePubKey: func() route.Vertex {
return route.NewVertex(
// The first node in this slice is
// the introduction node, so we start
// at index 1 to get the first blinded
// relaying node.
firstBlindedHop,
)
},
ToNodeFeatures: features,
}
hints[fromNode] = []AdditionalEdge{
&BlindedEdge{
policy: edgePolicy,
cipherText: b.BlindedPath.BlindedHops[0].CipherText,
blindingPoint: b.BlindedPath.BlindingPoint,
},
}
@@ -156,15 +162,19 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
b.BlindedPath.BlindedHops[nextHopIdx].BlindedNodePub,
)
hint := &models.CachedEdgePolicy{
edgePolicy := &models.CachedEdgePolicy{
ToNodePubKey: func() route.Vertex {
return nextNode
},
ToNodeFeatures: features,
}
hints[fromNode] = []*models.CachedEdgePolicy{
hint,
hints[fromNode] = []AdditionalEdge{
&BlindedEdge{
policy: edgePolicy,
cipherText: b.BlindedPath.BlindedHops[i].
CipherText,
},
}
}