mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
routing: exit on unexpected RequestRoute error
We whitelist a set of "expected" errors that can be returned from RequestRoute, by converting them into a new type noRouteError. For any other error returned by RequestRoute, we'll now exit immediately.
This commit is contained in:
@ -210,11 +210,16 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
|
||||
log.Warnf("Failed to find route for payment %x: %v",
|
||||
p.paymentHash, err)
|
||||
|
||||
routeErr, ok := err.(noRouteError)
|
||||
if !ok {
|
||||
return [32]byte{}, nil, err
|
||||
}
|
||||
|
||||
// There is no route to try, and we have no active
|
||||
// shards. This means that there is no way for us to
|
||||
// send the payment, so mark it failed with no route.
|
||||
if state.numShardsInFlight == 0 {
|
||||
failureCode := errorToPaymentFailure(err)
|
||||
failureCode := routeErr.FailureReason()
|
||||
log.Debugf("Marking payment %v permanently "+
|
||||
"failed with no route: %v",
|
||||
p.paymentHash, failureCode)
|
||||
@ -570,25 +575,6 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
|
||||
}, nil
|
||||
}
|
||||
|
||||
// errorToPaymentFailure takes a path finding error and converts it into a
|
||||
// payment-level failure.
|
||||
func errorToPaymentFailure(err error) channeldb.FailureReason {
|
||||
switch err {
|
||||
case
|
||||
errNoTlvPayload,
|
||||
errNoPaymentAddr,
|
||||
errNoPathFound,
|
||||
errEmptyPaySession:
|
||||
|
||||
return channeldb.FailureReasonNoRoute
|
||||
|
||||
case errInsufficientBalance:
|
||||
return channeldb.FailureReasonInsufficientBalance
|
||||
}
|
||||
|
||||
return channeldb.FailureReasonError
|
||||
}
|
||||
|
||||
// createNewPaymentAttempt creates a new payment attempt from the given route.
|
||||
func (p *shardHandler) createNewPaymentAttempt(rt *route.Route) (
|
||||
lnwire.ShortChannelID, *lnwire.UpdateAddHTLC,
|
||||
|
Reference in New Issue
Block a user