Skip to content

Commit 8b9cfa0

Browse files
authored
Merge pull request #1532 from lightninglabs/1531-sendpayment-fail-fast
rpcserver: stop SendPayment update stream when payment fails
2 parents 17b125f + dcf08b1 commit 8b9cfa0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rpcserver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7817,6 +7817,13 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
78177817
if err != nil {
78187818
return err
78197819
}
7820+
7821+
// If the payment failed, return an error and stop listening
7822+
// for updates immediately.
7823+
if update.Status == lnrpc.Payment_FAILED {
7824+
return fmt.Errorf("payment failed: %s",
7825+
update.FailureReason.String())
7826+
}
78207827
}
78217828
}
78227829

0 commit comments

Comments
 (0)