From 7a6817c243e1faa7fb013cdd2752d415a545ee46 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Fri, 13 Aug 2021 12:34:57 +0200 Subject: [PATCH] plugin: Adding status to the pay plugin Signed-off-by: Vincenzo Palazzo --- contrib/pyln-client/pyln/client/lightning.py | 5 +++-- doc/lightning-listsendpays.7 | 6 ++--- doc/lightning-listsendpays.7.md | 4 ++-- external/lnprototest | 2 +- plugins/pay.c | 5 ++++- wallet/db_postgres_sqlgen.c | 23 +------------------- wallet/db_sqlite3_sqlgen.c | 23 +------------------- wallet/statements_gettextgen.po | 23 +------------------- 8 files changed, 16 insertions(+), 75 deletions(-) diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index 150cbdeb68b0..52abb8bfc425 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -954,11 +954,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 b/doc/lightning-listsendpays.7 index 93b9834fbd6b..6b4aec808b71 100644 --- a/doc/lightning-listsendpays.7 +++ b/doc/lightning-listsendpays.7 @@ -3,14 +3,14 @@ lightning-listsendpays - Low-level command for querying sendpay status .SH SYNOPSIS -\fBlistsendpays\fR [\fIbolt11\fR] [\fIpayment_hash\fR] +\fBlistsendpays\fR [\fIbolt11\fR] [\fIpayment_hash\fR] [*status*] .SH DESCRIPTION The \fBlistsendpays\fR RPC command gets the status of all \fIsendpay\fR commands (which is also used by the \fIpay\fR command), or with \fIbolt11\fR or \fIpayment_hash\fR 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 \fIsendpay\fR @@ -75,4 +75,4 @@ responsible\. Main web site: \fIhttps://github.com/ElementsProject/lightning\fR -\" SHA256STAMP:01f2a7682c9af98704b04b2b5efe695ae6abc0cf41e13a4bc36c14e8b9662822 +\" SHA256STAMP:d9151661ba6df9b054603e18a7dae94ac6d6a26c28a05e825fad298ae81231b2 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/external/lnprototest b/external/lnprototest index ff3750b0ce88..2b99492ed054 160000 --- a/external/lnprototest +++ b/external/lnprototest @@ -1 +1 @@ -Subproject commit ff3750b0ce88130c09dcd02086340baaec2be016 +Subproject commit 2b99492ed0544a6c0475a79ca4ed484bc9191635 diff --git a/plugins/pay.c b/plugins/pay.c index 5925354ae774..3ff0036701aa 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); } diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index c9ba9e5918ef..9455b4bcce67 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -2038,25 +2038,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -// SHA256STAMP:27a166e040e517422e91cf7ffbd12426b34337b8d75f82d7aa4c448beae5e821 -======= -======= ->>>>>>> wallet db: Support the query on database with status and payment hash. -<<<<<<< refs/remotes/ElementsProject/master -// SHA256STAMP:6353b67b3e4f539da2d1f0c2564c4a8243f07d59cd0b73bc83d5552600bd67f7 -======= -// SHA256STAMP:b5f4c156aa7e336af86f98eafc5e198d3653ff27b21d861a5e777645bf6d89ec ->>>>>>> rpc: Integrate the status flow in the listsendpays command -<<<<<<< refs/remotes/ElementsProject/master ->>>>>>> rpc: Integrate the status flow in the listsendpays command -======= -======= -// SHA256STAMP:2af9ace16d4db060e649c3e078271504fce5a7c5661a25464a551aa7cc7029d0 ->>>>>>> wallet db: Support the query on database with status and payment hash. ->>>>>>> wallet db: Support the query on database with status and payment hash. -======= -// SHA256STAMP:c08699eae7d8de418f7b197aad5682203ebbae633ce8888b9b4797a2db8ce106 ->>>>>>> doc: Update doc with the new parameter supported +// SHA256STAMP:d0ce56fcfab3289812c54087d195fd04a556a3b39fe086cbbcf0f16e725e2948 diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index 68b98b2a0da8..faf465f7790a 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -2038,25 +2038,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -// SHA256STAMP:27a166e040e517422e91cf7ffbd12426b34337b8d75f82d7aa4c448beae5e821 -======= -======= ->>>>>>> wallet db: Support the query on database with status and payment hash. -<<<<<<< refs/remotes/ElementsProject/master -// SHA256STAMP:6353b67b3e4f539da2d1f0c2564c4a8243f07d59cd0b73bc83d5552600bd67f7 -======= -// SHA256STAMP:b5f4c156aa7e336af86f98eafc5e198d3653ff27b21d861a5e777645bf6d89ec ->>>>>>> rpc: Integrate the status flow in the listsendpays command -<<<<<<< refs/remotes/ElementsProject/master ->>>>>>> rpc: Integrate the status flow in the listsendpays command -======= -======= -// SHA256STAMP:2af9ace16d4db060e649c3e078271504fce5a7c5661a25464a551aa7cc7029d0 ->>>>>>> wallet db: Support the query on database with status and payment hash. ->>>>>>> wallet db: Support the query on database with status and payment hash. -======= -// SHA256STAMP:c08699eae7d8de418f7b197aad5682203ebbae633ce8888b9b4797a2db8ce106 ->>>>>>> doc: Update doc with the new parameter supported +// SHA256STAMP:d0ce56fcfab3289812c54087d195fd04a556a3b39fe086cbbcf0f16e725e2948 diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index 191a697eb89d..4e0aa30b8d82 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -1345,25 +1345,4 @@ msgstr "" #: wallet/test/run-wallet.c:1696 msgid "INSERT INTO channels (id) VALUES (1);" msgstr "" -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -<<<<<<< refs/remotes/ElementsProject/master -# SHA256STAMP:3652b5850f08383c0f0c01a7f11c1a22ec2b4ac16018152d2770a73674fb05ec -======= -======= ->>>>>>> wallet db: Support the query on database with status and payment hash. -<<<<<<< refs/remotes/ElementsProject/master -# SHA256STAMP:e203d19d9f4192ad6b3aa1a6f257d4f7b267df56c5de9810b573f0affa0122fd -======= -# SHA256STAMP:e074dc48b7055c740baa4da907a743baf1048d03dca12ebd1ed5989a9b0b7549 ->>>>>>> rpc: Integrate the status flow in the listsendpays command -<<<<<<< refs/remotes/ElementsProject/master ->>>>>>> rpc: Integrate the status flow in the listsendpays command -======= -======= -# SHA256STAMP:697c27016716f435d1ecb4ec3fca117316f779d88c02dbde7ea3214b4bc0a2c7 ->>>>>>> wallet db: Support the query on database with status and payment hash. ->>>>>>> wallet db: Support the query on database with status and payment hash. -======= -# SHA256STAMP:de612e43f4a76fed487047d802d20cc7185cf5650ed31bc01efb89c495bfbb14 ->>>>>>> doc: Update doc with the new parameter supported +# SHA256STAMP:bf66f681b4d5c9cf4b868ebf7515bc47a49df4b36882a878556171636757b515