mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
param: upgraded json_tok_pubkey
Also add json_to_pubkey as utility function. Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
committed by
Rusty Russell
parent
6254d15efd
commit
9b28ecf8fc
@@ -172,13 +172,27 @@ bool json_tok_u64(struct command *cmd, const char *name,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_tok_pubkey(const char *buffer, const jsmntok_t *tok,
|
||||
struct pubkey *pubkey)
|
||||
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
||||
struct pubkey *pubkey)
|
||||
{
|
||||
return pubkey_from_hexstr(buffer + tok->start,
|
||||
tok->end - tok->start, pubkey);
|
||||
}
|
||||
|
||||
bool json_tok_pubkey(struct command *cmd, const char *name,
|
||||
const char *buffer, const jsmntok_t *tok,
|
||||
struct pubkey **pubkey)
|
||||
{
|
||||
*pubkey = tal(cmd, struct pubkey);
|
||||
if (json_to_pubkey(buffer, tok, *pubkey))
|
||||
return true;
|
||||
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"'%s' should be a pubkey, not '%.*s'",
|
||||
name, tok->end - tok->start, buffer + tok->start);
|
||||
return false;
|
||||
}
|
||||
|
||||
void json_add_short_channel_id(struct json_result *response,
|
||||
const char *fieldname,
|
||||
const struct short_channel_id *id)
|
||||
|
||||
Reference in New Issue
Block a user