param: added json_tok_msat

This could have been a local static but its used by the run-param test,
so putting it in json.c made things easier.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-08-27 15:58:50 -05:00
committed by Rusty Russell
parent c553bba7a8
commit 4f81cd3852
4 changed files with 28 additions and 40 deletions

View File

@@ -413,29 +413,6 @@ static void sendpay_nulltok(void)
assert(msatoshi == NULL);
}
static bool json_tok_msat(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t * tok,
u64 **msatoshi_val)
{
if (json_tok_streq(buffer, tok, "any")) {
*msatoshi_val = NULL;
return true;
}
*msatoshi_val = tal(cmd, u64);
if (json_to_u64(buffer, tok, *msatoshi_val) && *msatoshi_val != 0)
return true;
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be a positive number or 'any', not '%.*s'",
name,
tok->end - tok->start,
buffer + tok->start);
return false;
}
/*
* New version of json_tok_label conforming to advanced style. This can eventually
* replace the existing json_tok_label.