From 998680ad59bd523383da716aada92216f2f6aebf Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 17 Apr 2019 13:26:52 -0700 Subject: [PATCH] routing: fall back to edge MaxHTLC within findPath instead of Capacity In this commit, we make our findPath function use an edge's MaxHTLC as its available bandwidth instead of its Capacity. We do this as it's possible for the capacity of an edge to not exist when operating as a light client. For channels that do not support the MaxHTLC optional field, we'll fall back to using the edge's Capacity. --- routing/pathfind.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index 30d2b0da..86ca0819 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -693,11 +693,16 @@ func findPath(g *graphParams, r *RestrictParams, source, target Vertex, edgeBandwidth, ok := g.bandwidthHints[edgeInfo.ChannelID] if !ok { // If we don't have a hint for this edge, then - // we'll just use the known Capacity as the - // available bandwidth. - edgeBandwidth = lnwire.NewMSatFromSatoshis( - edgeInfo.Capacity, - ) + // we'll just use the known Capacity/MaxHTLC as + // the available bandwidth. It's possible for + // the capacity to be unknown when operating + // under a light client. + edgeBandwidth = inEdge.MaxHTLC + if edgeBandwidth == 0 { + edgeBandwidth = lnwire.NewMSatFromSatoshis( + edgeInfo.Capacity, + ) + } } // Before we can process the edge, we'll need to fetch