param: added json_tok_string

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-08-29 17:53:00 -05:00
committed by Rusty Russell
parent 0b26a17a0f
commit 47510a8e74
6 changed files with 32 additions and 45 deletions

View File

@@ -599,21 +599,21 @@ static void json_pay_stop_retrying(struct pay *pay)
static void json_pay(struct command *cmd,
const char *buffer, const jsmntok_t *params)
{
const jsmntok_t *bolt11tok, *desctok;
double *riskfactor;
double *maxfeepercent;
u64 *msatoshi;
struct pay *pay = tal(cmd, struct pay);
struct bolt11 *b11;
char *fail, *b11str, *desc;
const char *b11str, *desc;
char *fail;
unsigned int *retryfor;
unsigned int *maxdelay;
unsigned int *exemptfee;
if (!param(cmd, buffer, params,
p_req("bolt11", json_tok_tok, &bolt11tok),
p_req("bolt11", json_tok_string, &b11str),
p_opt("msatoshi", json_tok_u64, &msatoshi),
p_opt("description", json_tok_tok, &desctok),
p_opt("description", json_tok_string, &desc),
p_opt_def("riskfactor", json_tok_double, &riskfactor, 1.0),
p_opt_def("maxfeepercent", json_tok_percent, &maxfeepercent, 0.5),
p_opt_def("retry_for", json_tok_number, &retryfor, 60),
@@ -623,14 +623,6 @@ static void json_pay(struct command *cmd,
NULL))
return;
b11str = tal_strndup(cmd, buffer + bolt11tok->start,
bolt11tok->end - bolt11tok->start);
if (desctok)
desc = tal_strndup(cmd, buffer + desctok->start,
desctok->end - desctok->start);
else
desc = NULL;
b11 = bolt11_decode(pay, b11str, desc, &fail);
if (!b11) {
command_fail(cmd, JSONRPC2_INVALID_PARAMS,