aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/rawtransaction.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-03-17 22:24:46 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-03-17 22:52:18 -0400
commitfa3caa1666a9baa856e92398a890aaddbdd98f7c (patch)
tree8ef4f19f41d79c90db6315a0498bc6c3e4d37a2d /src/rpc/rawtransaction.cpp
parentfaad33ff15398159115afd4799e3c97ac3df2a3a (diff)
rpc: decodescript use IsValidNumArgs over hardcoded check
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
-rw-r--r--src/rpc/rawtransaction.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index f3a4b168e8..3e258c3862 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -610,9 +610,7 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
static UniValue decodescript(const JSONRPCRequest& request)
{
- if (request.fHelp || request.params.size() != 1)
- throw std::runtime_error(
- RPCHelpMan{"decodescript",
+ const RPCHelpMan help{"decodescript",
"\nDecode a hex-encoded script.\n",
{
{"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\"")
+ HelpExampleRpc("decodescript", "\"hexstring\"")
},
- }.ToString());
+ };
+
+ if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
+ throw std::runtime_error(help.ToString());
+ }
RPCTypeCheck(request.params, {UniValue::VSTR});