param: upgraded json_tok_sha256

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-08-14 15:16:49 -05:00
committed by Rusty Russell
parent 2a0c2601c0
commit 6254d15efd
7 changed files with 32 additions and 23 deletions

View File

@@ -142,6 +142,22 @@ bool json_tok_number(struct command *cmd, const char *name,
return true;
}
bool json_tok_sha256(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
struct sha256 **hash)
{
*hash = tal(cmd, struct sha256);
if (hex_decode(buffer + tok->start,
tok->end - tok->start,
*hash, sizeof(**hash)))
return true;
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be a 32 byte hex value, not '%.*s'",
name, tok->end - tok->start, buffer + tok->start);
return false;
}
bool json_tok_u64(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
uint64_t **num)