Skip to content

Commit c061206

Browse files
committed
lndclient: expose failure reason
1 parent b054e84 commit c061206

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lndclient/router_client.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ type RouterClient interface {
3434

3535
// PaymentStatus describe the state of a payment.
3636
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+
3843
Preimage lntypes.Preimage
3944
Fee lnwire.MilliSatoshi
4045
Value lnwire.MilliSatoshi
@@ -232,7 +237,8 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
232237
State: rpcPayment.Status,
233238
}
234239

235-
if status.State == lnrpc.Payment_SUCCEEDED {
240+
switch status.State {
241+
case lnrpc.Payment_SUCCEEDED:
236242
preimage, err := lntypes.MakePreimageFromStr(
237243
rpcPayment.PaymentPreimage,
238244
)
@@ -242,6 +248,9 @@ func unmarshallPaymentStatus(rpcPayment *lnrpc.Payment) (
242248
status.Preimage = preimage
243249
status.Fee = lnwire.MilliSatoshi(rpcPayment.FeeMsat)
244250
status.Value = lnwire.MilliSatoshi(rpcPayment.ValueMsat)
251+
252+
case lnrpc.Payment_FAILED:
253+
status.FailureReason = rpcPayment.FailureReason
245254
}
246255

247256
for _, htlc := range rpcPayment.Htlcs {

0 commit comments

Comments
 (0)