htlcswitch: fix bug in generateHops, use CLTV delta of prior hop to compute payload
In this commit, we fix a bug in the generateHops helper function. Before this commit, it erroneously used the CLTV delta of the current hop, rather than that of the prior hop when computing the payload. This was incorrect, as when computing the timelock for the incoming hop, we need to factor in the CTLV delta of the outgoing lock, not the incoming lock.
This commit is contained in:
parent
4eb07e8288
commit
6e051a80ff
@ -601,15 +601,17 @@ func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32,
|
||||
nextHop = path[i+1].channel.ShortChanID()
|
||||
}
|
||||
|
||||
var timeLock uint32
|
||||
// If this is the last, hop, then the time lock will be their
|
||||
// specified delta policy plus our starting height.
|
||||
totalTimelock += lastHop.cfg.FwrdingPolicy.TimeLockDelta
|
||||
timeLock := totalTimelock
|
||||
|
||||
// Otherwise, the outgoing time lock should be the incoming
|
||||
// timelock minus their specified delta.
|
||||
if i != len(path)-1 {
|
||||
delta := path[i].cfg.FwrdingPolicy.TimeLockDelta
|
||||
if i == len(path)-1 {
|
||||
totalTimelock += lastHop.cfg.FwrdingPolicy.TimeLockDelta
|
||||
timeLock = totalTimelock
|
||||
} else {
|
||||
// Otherwise, the outgoing time lock should be the
|
||||
// incoming timelock minus their specified delta.
|
||||
delta := path[i+1].cfg.FwrdingPolicy.TimeLockDelta
|
||||
totalTimelock += delta
|
||||
timeLock = totalTimelock - delta
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user