mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
rpc: Integrate the status flow in the listsendpays command
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
eaec226f99
commit
fd33aed4b5
@@ -860,7 +860,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),
|
||||
@@ -1516,12 +1516,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_str;
|
||||
|
||||
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_str),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
@@ -1553,7 +1554,14 @@ static struct command_result *json_listsendpays(struct command *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash);
|
||||
if (status_str) {
|
||||
enum wallet_payment_status status;
|
||||
|
||||
if (!string_to_payment_status(status_str, &status))
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "Unrecognized status: %s", status_str);
|
||||
payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash, &status);
|
||||
} else
|
||||
payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash, NULL);
|
||||
|
||||
response = json_stream_success(cmd);
|
||||
|
||||
@@ -1606,7 +1614,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",
|
||||
|
||||
Reference in New Issue
Block a user