@@ -78,8 +78,6 @@ static UniValue GetNetworkHashPS(int lookup, int height) {
78
78
79
79
static UniValue getnetworkhashps (const JSONRPCRequest& request)
80
80
{
81
- if (request.fHelp || request.params .size () > 2 )
82
- throw std::runtime_error (
83
81
RPCHelpMan{" getnetworkhashps" ,
84
82
" \n Returns the estimated network hashes per second based on the last n blocks.\n "
85
83
" Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n "
@@ -95,7 +93,7 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
95
93
HelpExampleCli (" getnetworkhashps" , " " )
96
94
+ HelpExampleRpc (" getnetworkhashps" , " " )
97
95
},
98
- }.ToString () );
96
+ }.Check (request );
99
97
100
98
LOCK (cs_main);
101
99
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
145
143
146
144
static UniValue generatetoaddress (const JSONRPCRequest& request)
147
145
{
148
- if (request.fHelp || request.params .size () < 2 || request.params .size () > 3 )
149
- throw std::runtime_error (
150
146
RPCHelpMan{" generatetoaddress" ,
151
147
" \n Mine blocks immediately to a specified address (before the RPC call returns)\n " ,
152
148
{
@@ -163,7 +159,7 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
163
159
+ " If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n "
164
160
+ HelpExampleCli (" getnewaddress" , " " )
165
161
},
166
- }.ToString () );
162
+ }.Check (request );
167
163
168
164
int nGenerate = request.params [0 ].get_int ();
169
165
uint64_t nMaxTries = 1000000 ;
@@ -183,8 +179,6 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
183
179
184
180
static UniValue getmininginfo (const JSONRPCRequest& request)
185
181
{
186
- if (request.fHelp || request.params .size () != 0 ) {
187
- throw std::runtime_error (
188
182
RPCHelpMan{" getmininginfo" ,
189
183
" \n Returns a json object containing mining-related information." ,
190
184
{},
@@ -204,8 +198,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
204
198
HelpExampleCli (" getmininginfo" , " " )
205
199
+ HelpExampleRpc (" getmininginfo" , " " )
206
200
},
207
- }.ToString ());
208
- }
201
+ }.Check (request);
209
202
210
203
LOCK (cs_main);
211
204
@@ -225,8 +218,6 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
225
218
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
226
219
static UniValue prioritisetransaction (const JSONRPCRequest& request)
227
220
{
228
- if (request.fHelp || request.params .size () != 3 )
229
- throw std::runtime_error (
230
221
RPCHelpMan{" prioritisetransaction" ,
231
222
" Accepts the transaction into mined blocks at a higher (or lower) priority\n " ,
232
223
{
@@ -245,7 +236,7 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request)
245
236
HelpExampleCli (" prioritisetransaction" , " \" txid\" 0.0 10000" )
246
237
+ HelpExampleRpc (" prioritisetransaction" , " \" txid\" , 0.0, 10000" )
247
238
},
248
- }.ToString () );
239
+ }.Check (request );
249
240
250
241
LOCK (cs_main);
251
242
@@ -291,8 +282,6 @@ static std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
291
282
292
283
static UniValue getblocktemplate (const JSONRPCRequest& request)
293
284
{
294
- if (request.fHelp || request.params .size () > 1 )
295
- throw std::runtime_error (
296
285
RPCHelpMan{" getblocktemplate" ,
297
286
" \n If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n "
298
287
" It returns data needed to construct a block to work on.\n "
@@ -367,7 +356,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
367
356
HelpExampleCli (" getblocktemplate" , " {\" rules\" : [\" segwit\" ]}" )
368
357
+ HelpExampleRpc (" getblocktemplate" , " {\" rules\" : [\" segwit\" ]}" )
369
358
},
370
- }.ToString () );
359
+ }.Check (request );
371
360
372
361
LOCK (cs_main);
373
362
@@ -697,8 +686,6 @@ class submitblock_StateCatcher : public CValidationInterface
697
686
static UniValue submitblock (const JSONRPCRequest& request)
698
687
{
699
688
// 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 (
702
689
RPCHelpMan{" submitblock" ,
703
690
" \n Attempts to submit new block to network.\n "
704
691
" See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n " ,
@@ -711,8 +698,7 @@ static UniValue submitblock(const JSONRPCRequest& request)
711
698
HelpExampleCli (" submitblock" , " \" mydata\" " )
712
699
+ HelpExampleRpc (" submitblock" , " \" mydata\" " )
713
700
},
714
- }.ToString ());
715
- }
701
+ }.Check (request);
716
702
717
703
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
718
704
CBlock& block = *blockptr;
@@ -762,8 +748,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
762
748
763
749
static UniValue submitheader (const JSONRPCRequest& request)
764
750
{
765
- if (request.fHelp || request.params .size () != 1 ) {
766
- throw std::runtime_error (
767
751
RPCHelpMan{" submitheader" ,
768
752
" \n Decode the given hexdata as a header and submit it as a candidate chain tip if valid."
769
753
" \n Throws when the header is invalid.\n " ,
@@ -777,8 +761,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
777
761
HelpExampleCli (" submitheader" , " \" aabbcc\" " ) +
778
762
HelpExampleRpc (" submitheader" , " \" aabbcc\" " )
779
763
},
780
- }.ToString ());
781
- }
764
+ }.Check (request);
782
765
783
766
CBlockHeader h;
784
767
if (!DecodeHexBlockHeader (h, request.params [0 ].get_str ())) {
@@ -802,8 +785,6 @@ static UniValue submitheader(const JSONRPCRequest& request)
802
785
803
786
static UniValue estimatesmartfee (const JSONRPCRequest& request)
804
787
{
805
- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
806
- throw std::runtime_error (
807
788
RPCHelpMan{" estimatesmartfee" ,
808
789
" \n Estimates the approximate fee per kilobyte needed for a transaction to begin\n "
809
790
" confirmation within conf_target blocks if possible and return the number of blocks\n "
@@ -836,7 +817,7 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
836
817
RPCExamples{
837
818
HelpExampleCli (" estimatesmartfee" , " 6" )
838
819
},
839
- }.ToString () );
820
+ }.Check (request );
840
821
841
822
RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VSTR});
842
823
RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
@@ -867,8 +848,6 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
867
848
868
849
static UniValue estimaterawfee (const JSONRPCRequest& request)
869
850
{
870
- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
871
- throw std::runtime_error (
872
851
RPCHelpMan{" estimaterawfee" ,
873
852
" \n WARNING: This interface is unstable and may disappear or change!\n "
874
853
" \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)
909
888
RPCExamples{
910
889
HelpExampleCli (" estimaterawfee" , " 6 0.9" )
911
890
},
912
- }.ToString () );
891
+ }.Check (request );
913
892
914
893
RPCTypeCheck (request.params , {UniValue::VNUM, UniValue::VNUM}, true );
915
894
RPCTypeCheckArgument (request.params [0 ], UniValue::VNUM);
0 commit comments