@@ -78,8 +78,6 @@ static UniValue GetNetworkHashPS(int lookup, int height) {
7878
7979static UniValue getnetworkhashps (const JSONRPCRequest& request)
8080{
81- if (request.fHelp || request.params .size () > 2 )
82- throw std::runtime_error (
8381 RPCHelpMan{" getnetworkhashps" ,
8482 " \n Returns the estimated network hashes per second based on the last n blocks.\n "
8583 " Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n "
@@ -95,7 +93,7 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
9593 HelpExampleCli (" getnetworkhashps" , " " )
9694 + HelpExampleRpc (" getnetworkhashps" , " " )
9795 },
98- }.ToString () );
96+ }.Check (request );
9997
10098 LOCK (cs_main);
10199 return GetNetworkHashPS (!request.params [0 ].isNull () ? request.params [0 ].get_int () : 120 , !request.params [1 ].isNull () ? request.params [1 ].get_int () : -1 );
@@ -145,8 +143,6 @@ static UniValue generateBlocks(const CScript& coinbase_script, int nGenerate, ui
145143
146144static UniValue generatetoaddress (const JSONRPCRequest& request)
147145{
148- if (request.fHelp || request.params .size () < 2 || request.params .size () > 3 )
149- throw std::runtime_error (
150146 RPCHelpMan{" generatetoaddress" ,
151147 " \n Mine blocks immediately to a specified address (before the RPC call returns)\n " ,
152148 {
@@ -163,7 +159,7 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
163159 + " If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n "
164160 + HelpExampleCli (" getnewaddress" , " " )
165161 },
166- }.ToString () );
162+ }.Check (request );
167163
168164 int nGenerate = request.params [0 ].get_int ();
169165 uint64_t nMaxTries = 1000000 ;
@@ -183,8 +179,6 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
183179
184180static UniValue getmininginfo (const JSONRPCRequest& request)
185181{
186- if (request.fHelp || request.params .size () != 0 ) {
187- throw std::runtime_error (
188182 RPCHelpMan{" getmininginfo" ,
189183 " \n Returns a json object containing mining-related information." ,
190184 {},
@@ -204,8 +198,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
204198 HelpExampleCli (" getmininginfo" , " " )
205199 + HelpExampleRpc (" getmininginfo" , " " )
206200 },
207- }.ToString ());
208- }
201+ }.Check (request);
209202
210203 LOCK (cs_main);
211204
@@ -225,8 +218,6 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
225218// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
226219static UniValue prioritisetransaction (const JSONRPCRequest& request)
227220{
228- if (request.fHelp || request.params .size () != 3 )
229- throw std::runtime_error (
230221 RPCHelpMan{" prioritisetransaction" ,
231222 " Accepts the transaction into mined blocks at a higher (or lower) priority\n " ,
232223 {
@@ -245,7 +236,7 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request)
245236 HelpExampleCli (" prioritisetransaction" , " \" txid\" 0.0 10000" )
246237 + HelpExampleRpc (" prioritisetransaction" , " \" txid\" , 0.0, 10000" )
247238 },
248- }.ToString () );
239+ }.Check (request );
249240
250241 LOCK (cs_main);
251242
@@ -291,8 +282,6 @@ static std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
291282
292283static UniValue getblocktemplate (const JSONRPCRequest& request)
293284{
294- if (request.fHelp || request.params .size () > 1 )
295- throw std::runtime_error (
296285 RPCHelpMan{" getblocktemplate" ,
297286 " \n If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n "
298287 " It returns data needed to construct a block to work on.\n "
@@ -367,7 +356,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
367356 HelpExampleCli (" getblocktemplate" , " {\" rules\" : [\" segwit\" ]}" )
368357 + HelpExampleRpc (" getblocktemplate" , " {\" rules\" : [\" segwit\" ]}" )
369358 },
370- }.ToString () );
359+ }.Check (request );
371360
372361 LOCK (cs_main);
373362
@@ -697,8 +686,6 @@ class submitblock_StateCatcher : public CValidationInterface
697686static UniValue submitblock (const JSONRPCRequest& request)
698687{
699688 // We allow 2 arguments for compliance with BIP22. Argument 2 is ignored.
700- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 ) {
701- throw std::runtime_error (
702689 RPCHelpMan{" submitblock" ,
703690 " \n Attempts to submit new block to network.\n "
704691 " See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n " ,
@@ -711,8 +698,7 @@ static UniValue submitblock(const JSONRPCRequest& request)
711698 HelpExampleCli (" submitblock" , " \" mydata\" " )
712699 + HelpExampleRpc (" submitblock" , " \" mydata\" " )
713700 },
714- }.ToString ());
715- }
701+ }.Check (request);
716702
717703 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
718704 CBlock& block = *blockptr;
@@ -762,8 +748,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
762748
763749static UniValue submitheader (const JSONRPCRequest& request)
764750{
765- if (request.fHelp || request.params .size () != 1 ) {
766- throw std::runtime_error (
767751 RPCHelpMan{" submitheader" ,
768752 " \n Decode the given hexdata as a header and submit it as a candidate chain tip if valid."
769753 " \n Throws when the header is invalid.\n " ,
@@ -777,8 +761,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
777761 HelpExampleCli (" submitheader" , " \" aabbcc\" " ) +
778762 HelpExampleRpc (" submitheader" , " \" aabbcc\" " )
779763 },
780- }.ToString ());
781- }
764+ }.Check (request);
782765
783766 CBlockHeader h;
784767 if (!DecodeHexBlockHeader (h, request.params [0 ].get_str ())) {
@@ -802,8 +785,6 @@ static UniValue submitheader(const JSONRPCRequest& request)
802785
803786static UniValue estimatesmartfee (const JSONRPCRequest& request)
804787{
805- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
806- throw std::runtime_error (
807788 RPCHelpMan{" estimatesmartfee" ,
808789 " \n Estimates the approximate fee per kilobyte needed for a transaction to begin\n "
809790 " confirmation within conf_target blocks if possible and return the number of blocks\n "
@@ -836,7 +817,7 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
836817 RPCExamples{
837818 HelpExampleCli (" estimatesmartfee" , " 6" )
838819 },
839- }.ToString () );
820+ }.Check (request );
840821
841822 RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VSTR});
842823 RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
@@ -867,8 +848,6 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
867848
868849static UniValue estimaterawfee (const JSONRPCRequest& request)
869850{
870- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
871- throw std::runtime_error (
872851 RPCHelpMan{" estimaterawfee" ,
873852 " \n WARNING: This interface is unstable and may disappear or change!\n "
874853 " \n WARNING: This is an advanced API call that is tightly coupled to the specific\n "
@@ -909,7 +888,7 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
909888 RPCExamples{
910889 HelpExampleCli (" estimaterawfee" , " 6 0.9" )
911890 },
912- }.ToString () );
891+ }.Check (request );
913892
914893 RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VNUM}, true );
915894 RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
0 commit comments