rpcserver: add additional 'error' field in payment response
In order to not close the payment stream on payment error the additional field have been added in payment response. Now error from stream Recv() function means that something has happend inside the client and we unable to process any payment farther, and error inside the payment response means, that something wrong has happend with payment itself.
This commit is contained in:
1 parent
c4955258f1
commit
6861df0e23
5 files changed
+359
-307
No files matched your search
+12
-1
@@ -1239,7 +1239,18 @@ func (r *rpcServer) SendPayment(paymentStream lnrpc.Lightning_SendPaymentServer)
|
||||
}
|
||||
preImage, route, err := r.server.chanRouter.SendPayment(payment)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
// If we receive payment error than,
|
||||
// instead of terminating the stream,
|
||||
// send error response to the user.
|
||||
err := paymentStream.Send(&lnrpc.SendResponse{
|
||||
PaymentError: err.Error(),
|
||||
PaymentPreimage: nil,
|
||||
PaymentRoute: nil,
|
||||
})
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user