Skip to content

Commit fa3caa1

Browse files
author
MarcoFalke
committed
rpc: decodescript use IsValidNumArgs over hardcoded check
1 parent faad33f commit fa3caa1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,7 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
610610

611611
static UniValue decodescript(const JSONRPCRequest& request)
612612
{
613-
if (request.fHelp || request.params.size() != 1)
614-
throw std::runtime_error(
615-
RPCHelpMan{"decodescript",
613+
const RPCHelpMan help{"decodescript",
616614
"\nDecode a hex-encoded script.\n",
617615
{
618616
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
@@ -643,7 +641,11 @@ static UniValue decodescript(const JSONRPCRequest& request)
643641
HelpExampleCli("decodescript", "\"hexstring\"")
644642
+ HelpExampleRpc("decodescript", "\"hexstring\"")
645643
},
646-
}.ToString());
644+
};
645+
646+
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
647+
throw std::runtime_error(help.ToString());
648+
}
647649

648650
RPCTypeCheck(request.params, {UniValue::VSTR});
649651

0 commit comments

Comments
 (0)