From f829d33d6fd51e2a6d607dc651edbe3f9ea05416 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 28 May 2019 11:03:14 +0200 Subject: [PATCH] route: return 0 fee from TotalFees for empty route. Otherwise we would crash calling the method on empty routes. --- routing/route/route.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routing/route/route.go b/routing/route/route.go index 9b010e77..2cd04684 100644 --- a/routing/route/route.go +++ b/routing/route/route.go @@ -103,6 +103,10 @@ func (r *Route) HopFee(hopIndex int) lnwire.MilliSatoshi { // the case of a one-hop payment, this value will be zero as we don't need to // pay a fee to ourself. func (r *Route) TotalFees() lnwire.MilliSatoshi { + if len(r.Hops) == 0 { + return 0 + } + return r.TotalAmount - r.Hops[len(r.Hops)-1].AmtToForward }