diff --git a/routing/route/route.go b/routing/route/route.go index 2a27e3b5..ff043ef8 100644 --- a/routing/route/route.go +++ b/routing/route/route.go @@ -271,6 +271,11 @@ func NewRouteFromHops(amtToSend lnwire.MilliSatoshi, timeLock uint32, func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) { var path sphinx.PaymentPath + // We can only construct a route if there are hops provided. + if len(r.Hops) == 0 { + return nil, ErrNoRouteHopsProvided + } + // Check maximum route length. if len(r.Hops) > sphinx.NumMaxHops { return nil, ErrMaxRouteHopsExceeded diff --git a/routing/router.go b/routing/router.go index f157b7bd..c8d4bebd 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1487,13 +1487,6 @@ func generateNewSessionKey() (*btcec.PrivateKey, error) { func generateSphinxPacket(rt *route.Route, paymentHash []byte, sessionKey *btcec.PrivateKey) ([]byte, *sphinx.Circuit, error) { - // As a sanity check, we'll ensure that the set of hops has been - // properly filled in, otherwise, we won't actually be able to - // construct a route. - if len(rt.Hops) == 0 { - return nil, nil, route.ErrNoRouteHopsProvided - } - // Now that we know we have an actual route, we'll map the route into a // sphinx payument path which includes per-hop paylods for each hop // that give each node within the route the necessary information