@@ -34,7 +34,12 @@ type RouterClient interface {
34
34
35
35
// PaymentStatus describe the state of a payment.
36
36
type PaymentStatus struct {
37
- State lnrpc.Payment_PaymentStatus
37
+ State lnrpc.Payment_PaymentStatus
38
+
39
+ // FailureReason is the reason why the payment failed. Only set when
40
+ // State is Failed.
41
+ FailureReason lnrpc.PaymentFailureReason
42
+
38
43
Preimage lntypes.Preimage
39
44
Fee lnwire.MilliSatoshi
40
45
Value lnwire.MilliSatoshi
@@ -232,7 +237,8 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
232
237
State : rpcPayment .Status ,
233
238
}
234
239
235
- if status .State == lnrpc .Payment_SUCCEEDED {
240
+ switch status .State {
241
+ case lnrpc .Payment_SUCCEEDED :
236
242
preimage , err := lntypes .MakePreimageFromStr (
237
243
rpcPayment .PaymentPreimage ,
238
244
)
@@ -242,6 +248,9 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
242
248
status .Preimage = preimage
243
249
status .Fee = lnwire .MilliSatoshi (rpcPayment .FeeMsat )
244
250
status .Value = lnwire .MilliSatoshi (rpcPayment .ValueMsat )
251
+
252
+ case lnrpc .Payment_FAILED :
253
+ status .FailureReason = rpcPayment .FailureReason
245
254
}
246
255
247
256
for _ , htlc := range rpcPayment .Htlcs {
0 commit comments