diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index e7b8af20ae68..74af1ce01720 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -953,11 +953,12 @@ def listpeers(self, peerid=None, level=None): } return self.call("listpeers", payload) - def listsendpays(self, bolt11=None, payment_hash=None): + def listsendpays(self, bolt11=None, payment_hash=None, status=None): """Show all sendpays results, or only for `bolt11` or `payment_hash`.""" payload = { "bolt11": bolt11, - "payment_hash": payment_hash + "payment_hash": payment_hash, + "status": status } return self.call("listsendpays", payload) diff --git a/doc/lightning-listsendpays.7.md b/doc/lightning-listsendpays.7.md index bf0960f1cae1..b3a7c154b52c 100644 --- a/doc/lightning-listsendpays.7.md +++ b/doc/lightning-listsendpays.7.md @@ -4,7 +4,7 @@ lightning-listsendpays -- Low-level command for querying sendpay status SYNOPSIS -------- -**listsendpays** \[*bolt11*\] \[*payment\_hash*\] +**listsendpays** \[*bolt11*\] \[*payment\_hash*\] [\*status*\] DESCRIPTION ----------- @@ -12,7 +12,7 @@ DESCRIPTION The **listsendpays** RPC command gets the status of all *sendpay* commands (which is also used by the *pay* command), or with *bolt11* or *payment\_hash* limits results to that specific payment. You cannot -specify both. +specify both. It is possible filter the payments also by status. Note that in future there may be more than one concurrent *sendpay* command per *pay*, so this command should be used with caution. diff --git a/plugins/pay.c b/plugins/pay.c index 5925354ae774..37ce0a84729b 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1905,7 +1905,7 @@ static struct command_result *json_listpays(struct command *cmd, const char *buf, const jsmntok_t *params) { - const char *invstring; + const char *invstring, *status_str; struct sha256 *payment_hash; struct out_req *req; @@ -1914,6 +1914,7 @@ static struct command_result *json_listpays(struct command *cmd, /* FIXME: parameter should be invstring now */ p_opt("bolt11", param_string, &invstring), p_opt("payment_hash", param_sha256, &payment_hash), + p_opt("status", param_string, &status_str) NULL)) return command_param_failed(); @@ -1926,6 +1927,8 @@ static struct command_result *json_listpays(struct command *cmd, if (payment_hash) json_add_sha256(req->js, "payment_hash", payment_hash); + if (status_str) + json_add_string(req->js, "status", status_str); return send_outreq(cmd->plugin, req); }