Skip to content

Commit

Permalink
plugin: Adding status to the pay plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Jul 22, 2021
1 parent d2bf904 commit 34d8d76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions contrib/pyln-client/pyln/client/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions doc/lightning-listsendpays.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ lightning-listsendpays -- Low-level command for querying sendpay status
SYNOPSIS
--------

**listsendpays** \[*bolt11*\] \[*payment\_hash*\]
**listsendpays** \[*bolt11*\] \[*payment\_hash*\] [\*status*\]

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.
Expand Down
5 changes: 4 additions & 1 deletion plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();

Expand All @@ -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);
}

Expand Down

0 comments on commit 34d8d76

Please sign in to comment.