json: add a param parser for a txid

This commit is contained in:
lisa neigut
2019-06-05 14:58:53 +09:30
committed by Rusty Russell
parent c40250ad0b
commit a4a193840f
5 changed files with 33 additions and 0 deletions

View File

@@ -108,6 +108,21 @@ struct command_result *param_pubkey(struct command *cmd, const char *name,
json_tok_full(buffer, tok));
}
struct command_result *param_txid(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
struct bitcoin_txid **txid)
{
*txid = tal(cmd, struct bitcoin_txid);
if (json_to_txid(buffer, tok, *txid))
return NULL;
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be txid, not '%.*s'",
name, json_tok_full_len(tok),
json_tok_full(buffer, tok));
}
void json_add_short_channel_id(struct json_stream *response,
const char *fieldname,
const struct short_channel_id *scid)