lndclient: expose failure reason

pull/187/head
Joost Jager 4 years ago
parent b054e84eb2
commit c061206406
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -34,7 +34,12 @@ type RouterClient interface {
// PaymentStatus describe the state of a payment. // PaymentStatus describe the state of a payment.
type PaymentStatus struct { 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 Preimage lntypes.Preimage
Fee lnwire.MilliSatoshi Fee lnwire.MilliSatoshi
Value lnwire.MilliSatoshi Value lnwire.MilliSatoshi
@ -232,7 +237,8 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
State: rpcPayment.Status, State: rpcPayment.Status,
} }
if status.State == lnrpc.Payment_SUCCEEDED { switch status.State {
case lnrpc.Payment_SUCCEEDED:
preimage, err := lntypes.MakePreimageFromStr( preimage, err := lntypes.MakePreimageFromStr(
rpcPayment.PaymentPreimage, rpcPayment.PaymentPreimage,
) )
@ -242,6 +248,9 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
status.Preimage = preimage status.Preimage = preimage
status.Fee = lnwire.MilliSatoshi(rpcPayment.FeeMsat) status.Fee = lnwire.MilliSatoshi(rpcPayment.FeeMsat)
status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat) status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat)
case lnrpc.Payment_FAILED:
status.FailureReason = rpcPayment.FailureReason
} }
for _, htlc := range rpcPayment.Htlcs { for _, htlc := range rpcPayment.Htlcs {

Loading…
Cancel
Save