diff --git a/routing/router.go b/routing/router.go index 637d5ec6..e830edaa 100644 --- a/routing/router.go +++ b/routing/router.go @@ -821,6 +821,13 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey, amt btcutil.Amount) return nil, newErrf(ErrTargetNotInNetwork, "target not found") } + // We'll also fetch the current block height so we can properly + // calculate the required HTLC time locks within the route. + _, currentHeight, err := r.cfg.Chain.GetBestBlock() + if err != nil { + return nil, err + } + // Now that we know the destination is reachable within the graph, // we'll execute our KSP algorithm to find the k-shortest paths from // our source to the destination. @@ -839,7 +846,7 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey, amt btcutil.Amount) // Attempt to make the path into a route. We snip off the first // hop in the path as it contains a "self-hop" that is inserted // by our KSP algorithm. - route, err := newRoute(amt, path[1:]) + route, err := newRoute(amt, path[1:], uint32(currentHeight)) if err != nil { continue }