json: Add parser for u32 params

This commit is contained in:
Christian Decker 2022-05-19 13:51:49 +02:00
parent bad943da55
commit 6d07f4ed85
2 changed files with 17 additions and 0 deletions

View file

@ -122,6 +122,18 @@ struct command_result *param_sha256(struct command *cmd, const char *name,
"should be a 32 byte hex value");
}
struct command_result *param_u32(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
uint32_t **num)
{
*num = tal(cmd, uint32_t);
if (json_to_u32(buffer, tok, *num))
return NULL;
return command_fail_badparam(cmd, name, buffer, tok,
"should be an unsigned 32 bit integer");
}
struct command_result *param_u64(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
uint64_t **num)

View file

@ -68,6 +68,11 @@ struct command_result *param_sha256(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
struct sha256 **hash);
/* Extract number from this (may be a string, or a number literal) */
struct command_result *param_u32(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
uint32_t **num);
/* Extract number from this (may be a string, or a number literal) */
struct command_result *param_u64(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,