routing: let BlindedPaymentPathSet handle FinalCLTV logic

Instead of needing to remember how to handle the FinalCLTV value of a
blinded payment path at various points in the code base, we hide the
logic behind a unified FinalCLTVDelta method on the blinded path.
This commit is contained in:
Elle Mouton
2024-05-15 15:59:43 +02:00
parent 8df03de3e9
commit daaa24b69c
3 changed files with 42 additions and 29 deletions

View File

@@ -210,21 +210,12 @@ func newRoute(sourceVertex route.Vertex,
// reporting through RPC. Set to zero for the final hop.
fee = 0
// Only include the final hop CLTV delta in the total
// time lock value if this is not a route to a blinded
// path. For blinded paths, the total time-lock from the
// whole path will be deduced from the introduction
// node's CLTV delta. The exception is for the case
// where the final hop is the blinded path introduction
// node.
if blindedPathSet == nil ||
len(blindedPathSet.GetPath().BlindedPath.
BlindedHops) == 1 {
// As this is the last hop, we'll use the
// specified final CLTV delta value instead of
// the value from the last link in the route.
if blindedPathSet == nil {
totalTimeLock += uint32(finalHop.cltvDelta)
} else {
totalTimeLock += uint32(
blindedPathSet.FinalCLTVDelta(),
)
}
outgoingTimeLock = totalTimeLock