routing: obtain current height when creating a new route

This commit is contained in:
Olaoluwa Osuntokun 2017-08-02 21:02:18 -07:00
parent d331ddd2f4
commit f61d977176
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -821,6 +821,13 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey, amt btcutil.Amount)
return nil, newErrf(ErrTargetNotInNetwork, "target not found") 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, // Now that we know the destination is reachable within the graph,
// we'll execute our KSP algorithm to find the k-shortest paths from // we'll execute our KSP algorithm to find the k-shortest paths from
// our source to the destination. // 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 // 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 // hop in the path as it contains a "self-hop" that is inserted
// by our KSP algorithm. // by our KSP algorithm.
route, err := newRoute(amt, path[1:]) route, err := newRoute(amt, path[1:], uint32(currentHeight))
if err != nil { if err != nil {
continue continue
} }