Skip to content

Commit fa1c359

Browse files
author
MarcoFalke
committed
rpc: Use IsValidNumArgs in getblock
1 parent 2eb8c5d commit fa1c359

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/rpc/blockchain.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,7 @@ static CBlock GetBlockChecked(const CBlockIndex* pblockindex)
824824

825825
static UniValue getblock(const JSONRPCRequest& request)
826826
{
827-
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
828-
throw std::runtime_error(
829-
RPCHelpMan{"getblock",
827+
const RPCHelpMan help{"getblock",
830828
"\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
831829
"If verbosity is 1, returns an Object with information about block <hash>.\n"
832830
"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)
878876
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
879877
+ HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
880878
},
881-
}.ToString());
879+
};
880+
881+
if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
882+
throw std::runtime_error(help.ToString());
883+
}
882884

883885
LOCK(cs_main);
884886

0 commit comments

Comments
 (0)