route: return 0 fee from TotalFees for empty route.
Otherwise we would crash calling the method on empty routes.
This commit is contained in:
parent
28fdf9712d
commit
f829d33d6f
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user