@@ -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
@@ -696,8 +685,6 @@ class submitblock_StateCatcher : public CValidationInterface
696685static UniValue submitblock (const JSONRPCRequest& request)
697686{
698687 // We allow 2 arguments for compliance with BIP22. Argument 2 is ignored.
699- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 ) {
700- throw std::runtime_error (
701688 RPCHelpMan{" submitblock" ,
702689 " \n Attempts to submit new block to network.\n "
703690 " See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n " ,
@@ -710,8 +697,7 @@ static UniValue submitblock(const JSONRPCRequest& request)
710697 HelpExampleCli (" submitblock" , " \" mydata\" " )
711698 + HelpExampleRpc (" submitblock" , " \" mydata\" " )
712699 },
713- }.ToString ());
714- }
700+ }.Check (request);
715701
716702 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
717703 CBlock& block = *blockptr;
@@ -761,8 +747,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
761747
762748static UniValue submitheader (const JSONRPCRequest& request)
763749{
764- if (request.fHelp || request.params .size () != 1 ) {
765- throw std::runtime_error (
766750 RPCHelpMan{" submitheader" ,
767751 " \n Decode the given hexdata as a header and submit it as a candidate chain tip if valid."
768752 " \n Throws when the header is invalid.\n " ,
@@ -776,8 +760,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
776760 HelpExampleCli (" submitheader" , " \" aabbcc\" " ) +
777761 HelpExampleRpc (" submitheader" , " \" aabbcc\" " )
778762 },
779- }.ToString ());
780- }
763+ }.Check (request);
781764
782765 CBlockHeader h;
783766 if (!DecodeHexBlockHeader (h, request.params [0 ].get_str ())) {
@@ -801,8 +784,6 @@ static UniValue submitheader(const JSONRPCRequest& request)
801784
802785static UniValue estimatesmartfee (const JSONRPCRequest& request)
803786{
804- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
805- throw std::runtime_error (
806787 RPCHelpMan{" estimatesmartfee" ,
807788 " \n Estimates the approximate fee per kilobyte needed for a transaction to begin\n "
808789 " confirmation within conf_target blocks if possible and return the number of blocks\n "
@@ -835,7 +816,7 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
835816 RPCExamples{
836817 HelpExampleCli (" estimatesmartfee" , " 6" )
837818 },
838- }.ToString () );
819+ }.Check (request );
839820
840821 RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VSTR});
841822 RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
@@ -866,8 +847,6 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
866847
867848static UniValue estimaterawfee (const JSONRPCRequest& request)
868849{
869- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
870- throw std::runtime_error (
871850 RPCHelpMan{" estimaterawfee" ,
872851 " \n WARNING: This interface is unstable and may disappear or change!\n "
873852 " \n WARNING: This is an advanced API call that is tightly coupled to the specific\n "
@@ -908,7 +887,7 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
908887 RPCExamples{
909888 HelpExampleCli (" estimaterawfee" , " 6 0.9" )
910889 },
911- }.ToString () );
890+ }.Check (request );
912891
913892 RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VNUM}, true );
914893 RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
0 commit comments