mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 16:44:20 +01:00
param: upgraded json_tok_sha256
Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
committed by
Rusty Russell
parent
2a0c2601c0
commit
6254d15efd
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user