json: Add helper to decode sha256 hashes

This commit is contained in:
Christian Decker
2020-05-26 12:24:10 +02:00
parent 0b85b983ac
commit 957a3a01b9
2 changed files with 11 additions and 0 deletions

View File

@@ -225,6 +225,15 @@ bool json_to_bool(const char *buffer, const jsmntok_t *tok, bool *b)
return false;
}
bool json_to_sha256(const char *buffer, const jsmntok_t *tok, struct sha256 *dest)
{
if (tok->type != JSMN_STRING)
return false;
return hex_decode(buffer + tok->start, tok->end - tok->start, dest,
sizeof(struct sha256));
}
u8 *json_tok_bin_from_hex(const tal_t *ctx, const char *buffer, const jsmntok_t *tok)
{
u8 *result;