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.
This commit is contained in:
Olaoluwa Osuntokun 2018-06-25 20:27:46 -07:00
parent bdecc5bea9
commit 6c986864ff
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -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