Skip to content

Commit

Permalink
Starting work on the architecture to filter the payment list
Browse files Browse the repository at this point in the history
This is a working in progress feature and it is a propose to give the user to see the possibility to see the payment filtered by status.

Fixes #4588

Changelog: JSON-RPC:  Add new parameter `status` to listpays+listsendpays

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Jun 16, 2021
1 parent 75720ad commit 9ba5391
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 61 deletions.
2 changes: 1 addition & 1 deletion lightningd/offer.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static struct command_result *prev_payment(struct command *cmd,
bool prev_paid = false;

assert(!invreq->payer_info);
payments = wallet_payment_list(cmd, cmd->ld->wallet, NULL);
payments = wallet_payment_list(cmd, cmd->ld->wallet, NULL, NULL);

for (size_t i = 0; i < tal_count(payments); i++) {
const struct tlv_invoice *inv;
Expand Down
9 changes: 5 additions & 4 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ send_payment_core(struct lightningd *ld,
bool have_complete = false;

/* Now, do we already have one or more payments? */
payments = wallet_payment_list(tmpctx, ld->wallet, rhash);
payments = wallet_payment_list(tmpctx, ld->wallet, rhash, NULL);
for (size_t i = 0; i < tal_count(payments); i++) {
log_debug(ld->log, "Payment %zu/%zu: %s %s",
i, tal_count(payments),
Expand Down Expand Up @@ -1525,12 +1525,13 @@ static struct command_result *json_listsendpays(struct command *cmd,
const struct wallet_payment **payments;
struct json_stream *response;
struct sha256 *rhash;
const char *invstring;
const char *invstring, *status;

if (!param(cmd, buffer, params,
/* FIXME: parameter should be invstring now */
p_opt("bolt11", param_string, &invstring),
p_opt("payment_hash", param_sha256, &rhash),
p_opt("status", param_string, &status),
NULL))
return command_param_failed();

Expand Down Expand Up @@ -1562,7 +1563,7 @@ static struct command_result *json_listsendpays(struct command *cmd,
}
}

payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash);
payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash, NULL);

response = json_stream_success(cmd);

Expand Down Expand Up @@ -1615,7 +1616,7 @@ static struct command_result *json_delpay(struct command *cmd,
payment_status_to_string(status));
}

payments = wallet_payment_list(cmd, cmd->ld->wallet, payment_hash);
payments = wallet_payment_list(cmd, cmd->ld->wallet, payment_hash, NULL);

if (tal_count(payments) == 0)
return command_fail(cmd, PAY_NO_SUCH_PAYMENT, "Unknown payment with payment_hash: %s",
Expand Down
6 changes: 5 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;
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),
NULL))
return command_param_failed();

Expand All @@ -1926,6 +1927,9 @@ static struct command_result *json_listpays(struct command *cmd,
if (payment_hash)
json_add_sha256(req->js, "payment_hash", payment_hash);

if(status)
json_add_string(req->js, "status", status);

return send_outreq(cmd->plugin, req);
}

Expand Down
10 changes: 8 additions & 2 deletions wallet/db_postgres_sqlgen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions wallet/db_sqlite3_sqlgen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 52 additions & 48 deletions wallet/statements_gettextgen.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ba5391

Please sign in to comment.