json_command: command_fail_badparam helper.

It's common to want to complain a token is not what we expected.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-08-26 06:50:50 +09:30
parent aa441e3b27
commit 39e4796ae3
13 changed files with 110 additions and 159 deletions

View File

@@ -31,10 +31,8 @@ struct command_result *param_pubkey(struct command *cmd, const char *name,
if (json_to_pubkey(buffer, tok, *pubkey))
return NULL;
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be a pubkey, not '%.*s'",
name, json_tok_full_len(tok),
json_tok_full(buffer, tok));
return command_fail_badparam(cmd, name, buffer, tok,
"should be a compressed pubkey");
}
struct command_result *param_short_channel_id(struct command *cmd,
@@ -47,10 +45,8 @@ struct command_result *param_short_channel_id(struct command *cmd,
if (json_to_short_channel_id(buffer, tok, *scid))
return NULL;
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be a short channel id, not '%.*s'",
name, json_tok_full_len(tok),
json_tok_full(buffer, tok));
return command_fail_badparam(cmd, name, buffer, tok,
"should be a short_channel_id of form NxNxN");
}
struct command_result *param_feerate_style(struct command *cmd,