mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
param: upgraded json_tok_escaped_string
Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
committed by
Rusty Russell
parent
8590dbedfb
commit
aa60057134
@@ -945,19 +945,18 @@ static void json_sendpay_on_resolve(const struct sendpay_result* r,
|
||||
static void json_sendpay(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
const jsmntok_t *routetok, *desctok;
|
||||
const jsmntok_t *routetok;
|
||||
const jsmntok_t *t, *end;
|
||||
size_t n_hops;
|
||||
struct sha256 *rhash;
|
||||
struct route_hop *route;
|
||||
u64 *msatoshi;
|
||||
const struct json_escaped *desc;
|
||||
const char *description;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_req("route", json_tok_tok, &routetok),
|
||||
p_req("payment_hash", json_tok_sha256, &rhash),
|
||||
p_opt("description", json_tok_tok, &desctok),
|
||||
p_opt("description", json_tok_escaped_string, &description),
|
||||
p_opt("msatoshi", json_tok_u64, &msatoshi),
|
||||
NULL))
|
||||
return;
|
||||
@@ -1017,28 +1016,6 @@ static void json_sendpay(struct command *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
if (desctok) {
|
||||
desc = json_tok_escaped_string(cmd, buffer, desctok);
|
||||
if (!desc) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"description '%.*s' not a string",
|
||||
desctok->end - desctok->start,
|
||||
buffer + desctok->start);
|
||||
return;
|
||||
}
|
||||
description = json_escaped_unescape(cmd, desc);
|
||||
if (description == NULL) {
|
||||
command_fail(
|
||||
cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"description '%.*s' not a valid escaped string",
|
||||
desctok->end - desctok->start,
|
||||
buffer + desctok->start);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
description = NULL;
|
||||
}
|
||||
|
||||
if (send_payment(cmd, cmd->ld, rhash, route,
|
||||
msatoshi ? *msatoshi : route[n_hops-1].amount,
|
||||
description,
|
||||
|
||||
Reference in New Issue
Block a user