routing: add cltv limit to payment session

This commit is contained in:
Joost Jager
2019-02-13 11:53:32 +01:00
parent e3bb3d46a2
commit 06cd64cbbc
3 changed files with 75 additions and 0 deletions

View File

@ -138,6 +138,16 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
"edges, %v vertexes", len(pruneView.edges),
len(pruneView.vertexes))
// If a route cltv limit was specified, we need to subtract the final
// delta before passing it into path finding. The optimal path is
// independent of the final cltv delta and the path finding algorithm is
// unaware of this value.
var cltvLimit *uint32
if payment.CltvLimit != nil {
limit := *payment.CltvLimit - uint32(finalCltvDelta)
cltvLimit = &limit
}
// TODO(roasbeef): sync logic amongst dist sys
// Taking into account this prune view, we'll attempt to locate a path
@ -154,6 +164,7 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
IgnoredEdges: pruneView.edges,
FeeLimit: payment.FeeLimit,
OutgoingChannelID: payment.OutgoingChannelID,
CltvLimit: cltvLimit,
},
p.mc.selfNode.PubKeyBytes, payment.Target,
payment.Amount,