File tree 5 files changed +20
-10
lines changed
5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class JSONRPCRequest
34
34
UniValue id;
35
35
std::string strMethod;
36
36
UniValue params;
37
- enum Mode { EXECUTE, GET_HELP } mode = EXECUTE;
37
+ enum Mode { EXECUTE, GET_HELP, GET_ARGS } mode = EXECUTE;
38
38
std::string URI;
39
39
std::string authUser;
40
40
std::string peerAddr;
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ static RPCHelpMan help()
149
149
}
150
150
if (strCommand == " dump_all_command_conversions" ) {
151
151
// Used for testing only, undocumented
152
- return tableRPC.dumpArgMap ();
152
+ return tableRPC.dumpArgMap (jsonRequest );
153
153
}
154
154
155
155
return tableRPC.help (strCommand, jsonRequest);
@@ -492,13 +492,18 @@ std::vector<std::string> CRPCTable::listCommands() const
492
492
return commandList;
493
493
}
494
494
495
- UniValue CRPCTable::dumpArgMap () const
495
+ UniValue CRPCTable::dumpArgMap (const JSONRPCRequest& args_request ) const
496
496
{
497
+ JSONRPCRequest request (args_request);
498
+ request.mode = JSONRPCRequest::GET_ARGS;
499
+
497
500
UniValue ret{UniValue::VARR};
498
501
for (const auto & cmd : mapCommands) {
499
- for (const auto & c : cmd.second ) {
500
- const auto help = RpcMethodFnType (c->unique_id )();
501
- help.AppendArgMap (ret);
502
+ UniValue result;
503
+ if (ExecuteCommands (cmd.second , request, result)) {
504
+ for (const auto & values : result.getValues ()) {
505
+ ret.push_back (values);
506
+ }
502
507
}
503
508
}
504
509
return ret;
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ class CRPCTable
148
148
/* *
149
149
* Return all named arguments that need to be converted by the client from string to another JSON type
150
150
*/
151
- UniValue dumpArgMap () const ;
151
+ UniValue dumpArgMap (const JSONRPCRequest& request ) const ;
152
152
153
153
/* *
154
154
* Appends a CRPCCommand to the dispatch table.
Original file line number Diff line number Diff line change @@ -478,6 +478,9 @@ std::string RPCExamples::ToDescriptionString() const
478
478
479
479
UniValue RPCHelpMan::HandleRequest (const JSONRPCRequest& request)
480
480
{
481
+ if (request.mode == JSONRPCRequest::GET_ARGS) {
482
+ return GetArgMap ();
483
+ }
481
484
/*
482
485
* Check if the given request is valid according to this command or if
483
486
* the user is asking for help information, and throw help when appropriate.
@@ -561,8 +564,9 @@ std::string RPCHelpMan::ToString() const
561
564
return ret;
562
565
}
563
566
564
- void RPCHelpMan::AppendArgMap (UniValue& arr ) const
567
+ UniValue RPCHelpMan::GetArgMap ( ) const
565
568
{
569
+ UniValue arr{UniValue::VARR};
566
570
for (int i{0 }; i < int (m_args.size ()); ++i) {
567
571
const auto & arg = m_args.at (i);
568
572
std::vector<std::string> arg_names;
@@ -577,6 +581,7 @@ void RPCHelpMan::AppendArgMap(UniValue& arr) const
577
581
arr.push_back (map);
578
582
}
579
583
}
584
+ return arr;
580
585
}
581
586
582
587
std::string RPCArg::GetFirstName () const
Original file line number Diff line number Diff line change @@ -337,8 +337,8 @@ class RPCHelpMan
337
337
338
338
UniValue HandleRequest (const JSONRPCRequest& request);
339
339
std::string ToString () const ;
340
- /* * Append the named args that need to be converted from string to another JSON type */
341
- void AppendArgMap ( UniValue& arr ) const ;
340
+ /* * Return the named args that need to be converted from string to another JSON type */
341
+ UniValue GetArgMap ( ) const ;
342
342
/* * If the supplied number of args is neither too small nor too high */
343
343
bool IsValidNumArgs (size_t num_args) const ;
344
344
std::vector<std::string> GetArgNames () const ;
You can’t perform that action at this time.
0 commit comments