Skip to content

Commit dcf08b1

Browse files
committed
rpcserver: stop SendPayment update stream when payment fails
Updates the SendPayment RPC to return immediately upon receiving a payment failure update. This avoids unnecessary waiting for a context timeout or quit signal.
1 parent 17b125f commit dcf08b1

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)