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:
Wilmer Paulino
2019-10-11 15:46:10 -04:00
parent e64493fe5b
commit 0fc401de19
14 changed files with 75 additions and 46 deletions

View File

@@ -248,11 +248,14 @@ func (s *Server) EstimateRouteFee(ctx context.Context,
feeLimit := lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin)
// Finally, we'll query for a route to the destination that can carry
// that target amount, we'll only request a single route.
// that target amount, we'll only request a single route. Set a
// restriction for the default CLTV limit, otherwise we can find a route
// that exceeds it and is useless to us.
route, err := s.cfg.Router.FindRoute(
s.cfg.RouterBackend.SelfNode, destNode, amtMsat,
&routing.RestrictParams{
FeeLimit: feeLimit,
FeeLimit: feeLimit,
CltvLimit: s.cfg.RouterBackend.MaxTotalTimelock,
}, nil,
)
if err != nil {