From f61d977176ee3e2e0dd33d8d13fe350e7f4f9ad9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 2 Aug 2017 21:02:18 -0700 Subject: [PATCH] routing: obtain current height when creating a new route --- routing/router.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 }