From c06120640685ccf50c42a730a5779983e728a948 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 28 Apr 2020 19:49:48 +0200 Subject: [PATCH] lndclient: expose failure reason --- lndclient/router_client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lndclient/router_client.go b/lndclient/router_client.go index 1bba14d..f72c3d1 100644 --- a/lndclient/router_client.go +++ b/lndclient/router_client.go @@ -34,7 +34,12 @@ type RouterClient interface { // PaymentStatus describe the state of a payment. type PaymentStatus struct { - State lnrpc.Payment_PaymentStatus + State lnrpc.Payment_PaymentStatus + + // FailureReason is the reason why the payment failed. Only set when + // State is Failed. + FailureReason lnrpc.PaymentFailureReason + Preimage lntypes.Preimage Fee lnwire.MilliSatoshi Value lnwire.MilliSatoshi @@ -232,7 +237,8 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) ( State: rpcPayment.Status, } - if status.State == lnrpc.Payment_SUCCEEDED { + switch status.State { + case lnrpc.Payment_SUCCEEDED: preimage, err := lntypes.MakePreimageFromStr( rpcPayment.PaymentPreimage, ) @@ -242,6 +248,9 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) ( status.Preimage = preimage status.Fee = lnwire.MilliSatoshi(rpcPayment.FeeMsat) status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat) + + case lnrpc.Payment_FAILED: + status.FailureReason = rpcPayment.FailureReason } for _, htlc := range rpcPayment.Htlcs {