mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 08:55:59 +01:00
routerrpc: map errors to grpc status code
The 'payment already exists' case is common in restart scenarios. With this commit it is no longer necessary to string-match on the error message. Implementation is identical to SendPaymentV2.
This commit is contained in:
parent
d26001a69a
commit
856abade3d
1 changed files with 7 additions and 0 deletions
|
@ -375,6 +375,13 @@ func (s *Server) SendToRouteV2(ctx context.Context,
|
|||
return rpcAttempt, nil
|
||||
}
|
||||
|
||||
// Transform user errors to grpc code.
|
||||
if err == channeldb.ErrPaymentInFlight ||
|
||||
err == channeldb.ErrAlreadyPaid {
|
||||
|
||||
return nil, status.Error(codes.AlreadyExists, err.Error())
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue