diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 7ef02eeb..f2c533ec 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -117,9 +117,27 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) { firstHop, htlcAdd, attempt, err := p.createNewPaymentAttempt( rt, ) + // With SendToRoute, it can happen that the route exceeds protocol + // constraints. Mark the payment as failed with an internal error. + if err == route.ErrMaxRouteHopsExceeded || + err == sphinx.ErrMaxRoutingInfoSizeExceeded { + + log.Debugf("Invalid route provided for payment %x: %v", + p.paymentHash, err) + + controlErr := p.router.cfg.Control.Fail( + p.paymentHash, channeldb.FailureReasonError, + ) + if controlErr != nil { + return [32]byte{}, nil, controlErr + } + } + + // In any case, don't continue if there is an error. if err != nil { return [32]byte{}, nil, err } + p.attempt = attempt // Before sending this HTLC to the switch, we checkpoint the @@ -326,24 +344,6 @@ func (p *paymentLifecycle) createNewPaymentAttempt(rt *route.Route) ( onionBlob, c, err := generateSphinxPacket( rt, p.paymentHash[:], sessionKey, ) - - // With SendToRoute, it can happen that the route exceeds protocol - // constraints. Mark the payment as failed with an internal error. - if err == route.ErrMaxRouteHopsExceeded || - err == sphinx.ErrMaxRoutingInfoSizeExceeded { - - log.Debugf("Invalid route provided for payment %x: %v", - p.paymentHash, err) - - controlErr := p.router.cfg.Control.Fail( - p.paymentHash, channeldb.FailureReasonError, - ) - if controlErr != nil { - return lnwire.ShortChannelID{}, nil, nil, controlErr - } - } - - // In any case, don't continue if there is an error. if err != nil { return lnwire.ShortChannelID{}, nil, nil, err }