mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 03:56:18 +02:00
routing+channeldb: add more failure reasons
This commit is contained in:
@@ -539,17 +539,13 @@ func (s *Server) trackPayment(paymentHash lntypes.Hash,
|
||||
result.Route,
|
||||
)
|
||||
} else {
|
||||
switch result.FailureReason {
|
||||
|
||||
case channeldb.FailureReasonTimeout:
|
||||
status.State = PaymentState_FAILED_TIMEOUT
|
||||
|
||||
case channeldb.FailureReasonNoRoute:
|
||||
status.State = PaymentState_FAILED_NO_ROUTE
|
||||
|
||||
default:
|
||||
return errors.New("unknown failure reason")
|
||||
state, err := marshallFailureReason(
|
||||
result.FailureReason,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
status.State = state
|
||||
}
|
||||
|
||||
// Send event to the client.
|
||||
@@ -565,3 +561,26 @@ func (s *Server) trackPayment(paymentHash lntypes.Hash,
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// marshallFailureReason marshalls the failure reason to the corresponding rpc
|
||||
// type.
|
||||
func marshallFailureReason(reason channeldb.FailureReason) (
|
||||
PaymentState, error) {
|
||||
|
||||
switch reason {
|
||||
|
||||
case channeldb.FailureReasonTimeout:
|
||||
return PaymentState_FAILED_TIMEOUT, nil
|
||||
|
||||
case channeldb.FailureReasonNoRoute:
|
||||
return PaymentState_FAILED_NO_ROUTE, nil
|
||||
|
||||
case channeldb.FailureReasonError:
|
||||
return PaymentState_FAILED_ERROR, nil
|
||||
|
||||
case channeldb.FailureReasonIncorrectPaymentDetails:
|
||||
return PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS, nil
|
||||
}
|
||||
|
||||
return 0, errors.New("unknown failure reason")
|
||||
}
|
||||
|
Reference in New Issue
Block a user