mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
param: listpayments now uses json_tok_sha256
Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
committed by
Rusty Russell
parent
47510a8e74
commit
30e6471fc1
@@ -1,7 +1,7 @@
|
||||
#include "json.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <ccan/str/hex/hex.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <ccan/str/hex/hex.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/json.h>
|
||||
#include <common/type_to_string.h>
|
||||
|
||||
@@ -1061,17 +1061,16 @@ static void json_listpayments(struct command *cmd, const char *buffer,
|
||||
{
|
||||
const struct wallet_payment **payments;
|
||||
struct json_result *response = new_json_result(cmd);
|
||||
const jsmntok_t *rhashtok;
|
||||
struct sha256 *rhash = NULL;
|
||||
struct sha256 *rhash;
|
||||
const char *b11str;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_opt("bolt11", json_tok_string, &b11str),
|
||||
p_opt("payment_hash", json_tok_tok, &rhashtok),
|
||||
p_opt("payment_hash", json_tok_sha256, &rhash),
|
||||
NULL))
|
||||
return;
|
||||
|
||||
if (rhashtok && b11str) {
|
||||
if (rhash && b11str) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Can only specify one of"
|
||||
" {bolt11} or {payment_hash}");
|
||||
@@ -1089,17 +1088,6 @@ static void json_listpayments(struct command *cmd, const char *buffer,
|
||||
return;
|
||||
}
|
||||
rhash = &b11->payment_hash;
|
||||
} else if (rhashtok) {
|
||||
rhash = tal(cmd, struct sha256);
|
||||
if (!hex_decode(buffer + rhashtok->start,
|
||||
rhashtok->end - rhashtok->start,
|
||||
rhash, sizeof(*rhash))) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"'%.*s' is not a valid sha256 hash",
|
||||
rhashtok->end - rhashtok->start,
|
||||
buffer + rhashtok->start);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash);
|
||||
|
||||
Reference in New Issue
Block a user