routing+routerrpc: take max cltv limit into account within path finding
With the introduction of the max CLTV limit parameter, nodes are able to reject HTLCs that exceed it. This should also be applied to path finding, otherwise HTLCs crafted by the same node that exceed it never left the switch. This wasn't a big deal since the previous max CLTV limit was ~5000 blocks. Once it was lowered to 1008, the issue became more apparent. Therefore, all of our path finding attempts now have a restriction of said limit in in order to properly carry out HTLCs to the network.
This commit is contained in:
14 files changed
+75
-46
No files matched your search
@@ -73,15 +73,10 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
|
||||
// does not reject the HTLC if some blocks are mined while it's in-flight.
|
||||
finalCltvDelta += BlockPadding
|
||||
|
||||
// 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
|
||||
}
|
||||
// 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.
|
||||
cltvLimit := payment.CltvLimit - uint32(finalCltvDelta)
|
||||
|
||||
// TODO(roasbeef): sync logic amongst dist sys
|
||||
|
||||
|
||||
Reference in new issue
Block a user