mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
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:
parent
bdecc5bea9
commit
6c986864ff
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user