aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-05-01 11:21:30 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-05-01 11:16:21 -0400
commitfa1c3591add184ecb43eb3b149f4833f241e3858 (patch)
tree98cc6c73738365f6153bd073a29fad16cd106b1d /src
parent2eb8c5d7a28b4dcecd60484773eaacd1608f6291 (diff)
rpc: Use IsValidNumArgs in getblock
Diffstat (limited to 'src')
-rw-r--r--src/rpc/blockchain.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 672fc69673..cd56e48ab8 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -824,9 +824,7 @@ static CBlock GetBlockChecked(const CBlockIndex* pblockindex)
static UniValue getblock(const JSONRPCRequest& request)
{
- if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
- throw std::runtime_error(
- RPCHelpMan{"getblock",
+ const RPCHelpMan help{"getblock",
"\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
"If verbosity is 1, returns an Object with information about block <hash>.\n"
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
@@ -878,7 +876,11 @@ static UniValue getblock(const JSONRPCRequest& request)
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
+ HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
},
- }.ToString());
+ };
+
+ if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
+ throw std::runtime_error(help.ToString());
+ }
LOCK(cs_main);