rpc: decodescript use IsValidNumArgs over hardcoded check
This commit is contained in:
parent
faad33ff15
commit
fa3caa1666
1 changed files with 6 additions and 4 deletions
|
@ -610,9 +610,7 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
|
||||||
|
|
||||||
static UniValue decodescript(const JSONRPCRequest& request)
|
static UniValue decodescript(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() != 1)
|
const RPCHelpMan help{"decodescript",
|
||||||
throw std::runtime_error(
|
|
||||||
RPCHelpMan{"decodescript",
|
|
||||||
"\nDecode a hex-encoded script.\n",
|
"\nDecode a hex-encoded script.\n",
|
||||||
{
|
{
|
||||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
|
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
|
||||||
|
@ -643,7 +641,11 @@ static UniValue decodescript(const JSONRPCRequest& request)
|
||||||
HelpExampleCli("decodescript", "\"hexstring\"")
|
HelpExampleCli("decodescript", "\"hexstring\"")
|
||||||
+ HelpExampleRpc("decodescript", "\"hexstring\"")
|
+ HelpExampleRpc("decodescript", "\"hexstring\"")
|
||||||
},
|
},
|
||||||
}.ToString());
|
};
|
||||||
|
|
||||||
|
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
|
||||||
|
throw std::runtime_error(help.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
RPCTypeCheck(request.params, {UniValue::VSTR});
|
RPCTypeCheck(request.params, {UniValue::VSTR});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue