From 6c986864ffb5b3720434b9baa75d5c28d69d1851 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 25 Jun 2018 20:27:46 -0700 Subject: [PATCH] routing: fix bug in newRoute, use time lock delta of prior hop, not current In this commit, we fix an existing bug in the newRoute method. Before this commit we would use the time lock delta of the current hop to compute the outgoing time lock for the current hop. This is incorrect as the time lock delta of the _outgoing_ hop should be used, as this is what we're paying for "transit" on. This is a bug left over from when we switched the meaning of the CLTV delta on the ChannelUpdate message sometime last year. The fix is simple: use the CLTV delta of the prior (later in the route) hop. --- routing/pathfind.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index b85b149f..5aa2298b 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -373,14 +373,14 @@ func newRoute(amtToSend, feeLimit lnwire.MilliSatoshi, sourceVertex Vertex, // route such that each hops time lock increases as we // walk backwards in the route, using the delta of the // previous hop. - route.TotalTimeLock += uint32(edge.TimeLockDelta) + delta := uint32(pathEdges[i+1].TimeLockDelta) + route.TotalTimeLock += delta // Otherwise, the value of the outgoing time-lock will // be the value of the time-lock for the _outgoing_ // HTLC, so we factor in their specified grace period // (time lock delta). - nextHop.OutgoingTimeLock = route.TotalTimeLock - - uint32(edge.TimeLockDelta) + nextHop.OutgoingTimeLock = route.TotalTimeLock - delta } route.Hops[i] = nextHop