@@ -130,11 +130,9 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
130
130
return strRet;
131
131
}
132
132
133
- UniValue help (const JSONRPCRequest& jsonRequest )
133
+ static RPCHelpMan help ()
134
134
{
135
- if (jsonRequest.fHelp || jsonRequest.params .size () > 1 )
136
- throw std::runtime_error (
137
- RPCHelpMan{" help" ,
135
+ return RPCHelpMan{" help" ,
138
136
" \n List all commands, or get help for a specified command.\n " ,
139
137
{
140
138
{" command" , RPCArg::Type::STR, /* default */ " all commands" , " The command to get help on" },
@@ -143,44 +141,46 @@ UniValue help(const JSONRPCRequest& jsonRequest)
143
141
RPCResult::Type::STR, " " , " The help text"
144
142
},
145
143
RPCExamples{" " },
146
- }.ToString ()
147
- );
148
-
144
+ [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
145
+ {
149
146
std::string strCommand;
150
147
if (jsonRequest.params .size () > 0 )
151
148
strCommand = jsonRequest.params [0 ].get_str ();
152
149
153
150
return tableRPC.help (strCommand, jsonRequest);
151
+ },
152
+ };
154
153
}
155
154
156
-
157
- UniValue stop (const JSONRPCRequest& jsonRequest)
155
+ static RPCHelpMan stop ()
158
156
{
159
157
static const std::string RESULT{PACKAGE_NAME " stopping" };
160
- // Accept the deprecated and ignored 'detach' boolean argument
158
+ return RPCHelpMan{ " stop " ,
161
159
// Also accept the hidden 'wait' integer argument (milliseconds)
162
160
// For instance, 'stop 1000' makes the call wait 1 second before returning
163
161
// to the client (intended for testing)
164
- if (jsonRequest.fHelp || jsonRequest.params .size () > 1 )
165
- throw std::runtime_error (
166
- RPCHelpMan{" stop" ,
167
162
" \n Request a graceful shutdown of " PACKAGE_NAME " ." ,
168
- {},
163
+ {
164
+ {" wait" , RPCArg::Type::NUM, RPCArg::Optional::OMITTED_NAMED_ARG, " how long to wait in ms" , " " , {}, /* hidden */ true },
165
+ },
169
166
RPCResult{RPCResult::Type::STR, " " , " A string with the content '" + RESULT + " '" },
170
167
RPCExamples{" " },
171
- }.ToString ());
168
+ [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
169
+ {
172
170
// Event loop will exit after current HTTP requests have been handled, so
173
171
// this reply will get back to the client.
174
172
StartShutdown ();
175
173
if (jsonRequest.params [0 ].isNum ()) {
176
174
UninterruptibleSleep (std::chrono::milliseconds{jsonRequest.params [0 ].get_int ()});
177
175
}
178
176
return RESULT;
177
+ },
178
+ };
179
179
}
180
180
181
- static UniValue uptime (const JSONRPCRequest& jsonRequest )
181
+ static RPCHelpMan uptime ()
182
182
{
183
- RPCHelpMan{" uptime" ,
183
+ return RPCHelpMan{" uptime" ,
184
184
" \n Returns the total uptime of the server.\n " ,
185
185
{},
186
186
RPCResult{
@@ -190,14 +190,16 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
190
190
HelpExampleCli (" uptime" , " " )
191
191
+ HelpExampleRpc (" uptime" , " " )
192
192
},
193
- }. Check (jsonRequest);
194
-
193
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
194
+ {
195
195
return GetTime () - GetStartupTime ();
196
196
}
197
+ };
198
+ }
197
199
198
- static UniValue getrpcinfo (const JSONRPCRequest& request )
200
+ static RPCHelpMan getrpcinfo ()
199
201
{
200
- RPCHelpMan{" getrpcinfo" ,
202
+ return RPCHelpMan{" getrpcinfo" ,
201
203
" \n Returns details of the RPC server.\n " ,
202
204
{},
203
205
RPCResult{
@@ -217,8 +219,8 @@ static UniValue getrpcinfo(const JSONRPCRequest& request)
217
219
RPCExamples{
218
220
HelpExampleCli (" getrpcinfo" , " " )
219
221
+ HelpExampleRpc (" getrpcinfo" , " " )},
220
- }. Check ( request);
221
-
222
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
223
+ {
222
224
LOCK (g_rpc_server_info.mutex );
223
225
UniValue active_commands (UniValue::VARR);
224
226
for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands ) {
@@ -237,6 +239,8 @@ static UniValue getrpcinfo(const JSONRPCRequest& request)
237
239
238
240
return result;
239
241
}
242
+ };
243
+ }
240
244
241
245
// clang-format off
242
246
static const CRPCCommand vRPCCommands[] =
0 commit comments