Bitcoin Core 29.99.0
P2P Digital Currency
server.cpp
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2009-2022 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include <bitcoin-build-config.h> // IWYU pragma: keep
7
8#include <rpc/server.h>
9
10#include <common/args.h>
11#include <common/system.h>
12#include <logging.h>
13#include <node/context.h>
15#include <rpc/server_util.h>
16#include <rpc/util.h>
17#include <sync.h>
19#include <util/strencodings.h>
20#include <util/string.h>
21#include <util/time.h>
22#include <validation.h>
23
24#include <cassert>
25#include <chrono>
26#include <memory>
27#include <mutex>
28#include <unordered_map>
29
31
33static std::atomic<bool> g_rpc_running{false};
34static bool fRPCInWarmup GUARDED_BY(g_rpc_warmup_mutex) = true;
35static std::string rpcWarmupStatus GUARDED_BY(g_rpc_warmup_mutex) = "RPC server started";
36/* Timer-creating functions */
38/* Map of name to timer. */
40static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers GUARDED_BY(g_deadline_timers_mutex);
41static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler);
42
44{
45 std::string method;
46 SteadyClock::time_point start;
47};
48
50{
52 std::list<RPCCommandExecutionInfo> active_commands GUARDED_BY(mutex);
53};
54
56
58{
59 std::list<RPCCommandExecutionInfo>::iterator it;
60 explicit RPCCommandExecution(const std::string& method)
61 {
63 it = g_rpc_server_info.active_commands.insert(g_rpc_server_info.active_commands.end(), {method, SteadyClock::now()});
64 }
66 {
68 g_rpc_server_info.active_commands.erase(it);
69 }
70};
71
72std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const
73{
74 std::string strRet;
75 std::string category;
76 std::set<intptr_t> setDone;
77 std::vector<std::pair<std::string, const CRPCCommand*> > vCommands;
78 vCommands.reserve(mapCommands.size());
79
80 for (const auto& entry : mapCommands)
81 vCommands.emplace_back(entry.second.front()->category + entry.first, entry.second.front());
82 sort(vCommands.begin(), vCommands.end());
83
84 JSONRPCRequest jreq = helpreq;
86 jreq.params = UniValue();
87
88 for (const std::pair<std::string, const CRPCCommand*>& command : vCommands)
89 {
90 const CRPCCommand *pcmd = command.second;
91 std::string strMethod = pcmd->name;
92 if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
93 continue;
94 jreq.strMethod = strMethod;
95 try
96 {
97 UniValue unused_result;
98 if (setDone.insert(pcmd->unique_id).second)
99 pcmd->actor(jreq, unused_result, /*last_handler=*/true);
100 }
101 catch (const std::exception& e)
102 {
103 // Help text is returned in an exception
104 std::string strHelp = std::string(e.what());
105 if (strCommand == "")
106 {
107 if (strHelp.find('\n') != std::string::npos)
108 strHelp = strHelp.substr(0, strHelp.find('\n'));
109
110 if (category != pcmd->category)
111 {
112 if (!category.empty())
113 strRet += "\n";
114 category = pcmd->category;
115 strRet += "== " + Capitalize(category) + " ==\n";
116 }
117 }
118 strRet += strHelp + "\n";
119 }
120 }
121 if (strRet == "")
122 strRet = strprintf("help: unknown command: %s\n", strCommand);
123 strRet = strRet.substr(0,strRet.size()-1);
124 return strRet;
125}
126
128{
129 return RPCHelpMan{
130 "help",
131 "List all commands, or get help for a specified command.\n",
132 {
133 {"command", RPCArg::Type::STR, RPCArg::DefaultHint{"all commands"}, "The command to get help on"},
134 },
135 {
136 RPCResult{RPCResult::Type::STR, "", "The help text"},
138 },
139 RPCExamples{""},
140 [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
141{
142 std::string strCommand;
143 if (jsonRequest.params.size() > 0) {
144 strCommand = jsonRequest.params[0].get_str();
145 }
146 if (strCommand == "dump_all_command_conversions") {
147 // Used for testing only, undocumented
148 return tableRPC.dumpArgMap(jsonRequest);
149 }
150
151 return tableRPC.help(strCommand, jsonRequest);
152},
153 };
154}
155
157{
158 static const std::string RESULT{CLIENT_NAME " stopping"};
159 return RPCHelpMan{
160 "stop",
161 // Also accept the hidden 'wait' integer argument (milliseconds)
162 // For instance, 'stop 1000' makes the call wait 1 second before returning
163 // to the client (intended for testing)
164 "Request a graceful shutdown of " CLIENT_NAME ".",
165 {
166 {"wait", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "how long to wait in ms", RPCArgOptions{.hidden=true}},
167 },
168 RPCResult{RPCResult::Type::STR, "", "A string with the content '" + RESULT + "'"},
169 RPCExamples{""},
170 [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
171{
172 // Event loop will exit after current HTTP requests have been handled, so
173 // this reply will get back to the client.
174 CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown_request))());
175 if (jsonRequest.params[0].isNum()) {
176 UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()});
177 }
178 return RESULT;
179},
180 };
181}
182
184{
185 return RPCHelpMan{
186 "uptime",
187 "Returns the total uptime of the server.\n",
188 {},
189 RPCResult{
190 RPCResult::Type::NUM, "", "The number of seconds that the server has been running"
191 },
193 HelpExampleCli("uptime", "")
194 + HelpExampleRpc("uptime", "")
195 },
196 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
197{
198 return GetTime() - GetStartupTime();
199}
200 };
201}
202
204{
205 return RPCHelpMan{
206 "getrpcinfo",
207 "Returns details of the RPC server.\n",
208 {},
209 RPCResult{
210 RPCResult::Type::OBJ, "", "",
211 {
212 {RPCResult::Type::ARR, "active_commands", "All active commands",
213 {
214 {RPCResult::Type::OBJ, "", "Information about an active command",
215 {
216 {RPCResult::Type::STR, "method", "The name of the RPC command"},
217 {RPCResult::Type::NUM, "duration", "The running time in microseconds"},
218 }},
219 }},
220 {RPCResult::Type::STR, "logpath", "The complete file path to the debug log"},
221 }
222 },
224 HelpExampleCli("getrpcinfo", "")
225 + HelpExampleRpc("getrpcinfo", "")},
226 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
227{
229 UniValue active_commands(UniValue::VARR);
230 for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands) {
232 entry.pushKV("method", info.method);
233 entry.pushKV("duration", int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - info.start)});
234 active_commands.push_back(std::move(entry));
235 }
236
237 UniValue result(UniValue::VOBJ);
238 result.pushKV("active_commands", std::move(active_commands));
239
240 const std::string path = LogInstance().m_file_path.utf8string();
241 UniValue log_path(UniValue::VSTR, path);
242 result.pushKV("logpath", std::move(log_path));
243
244 return result;
245}
246 };
247}
248
250 /* Overall control/query calls */
251 {"control", &getrpcinfo},
252 {"control", &help},
253 {"control", &stop},
254 {"control", &uptime},
255};
256
258{
259 for (const auto& c : vRPCCommands) {
260 appendCommand(c.name, &c);
261 }
262}
263
264void CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
265{
266 CHECK_NONFATAL(!IsRPCRunning()); // Only add commands before rpc is running
267
268 mapCommands[name].push_back(pcmd);
269}
270
271bool CRPCTable::removeCommand(const std::string& name, const CRPCCommand* pcmd)
272{
273 auto it = mapCommands.find(name);
274 if (it != mapCommands.end()) {
275 auto new_end = std::remove(it->second.begin(), it->second.end(), pcmd);
276 if (it->second.end() != new_end) {
277 it->second.erase(new_end, it->second.end());
278 return true;
279 }
280 }
281 return false;
282}
283
285{
286 LogDebug(BCLog::RPC, "Starting RPC\n");
287 g_rpc_running = true;
288}
289
291{
292 static std::once_flag g_rpc_interrupt_flag;
293 // This function could be called twice if the GUI has been started with -server=1.
294 std::call_once(g_rpc_interrupt_flag, []() {
295 LogDebug(BCLog::RPC, "Interrupting RPC\n");
296 // Interrupt e.g. running longpolls
297 g_rpc_running = false;
298 });
299}
300
302{
303 static std::once_flag g_rpc_stop_flag;
304 // This function could be called twice if the GUI has been started with -server=1.
306 std::call_once(g_rpc_stop_flag, [&]() {
307 LogDebug(BCLog::RPC, "Stopping RPC\n");
308 WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
310 LogDebug(BCLog::RPC, "RPC stopped.\n");
311 });
312}
313
315{
316 return g_rpc_running;
317}
318
320{
321 if (!IsRPCRunning()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
322}
323
324void SetRPCWarmupStatus(const std::string& newStatus)
325{
327 rpcWarmupStatus = newStatus;
328}
329
331{
333 assert(fRPCInWarmup);
334 fRPCInWarmup = false;
335}
336
337bool RPCIsInWarmup(std::string *outStatus)
338{
340 if (outStatus)
341 *outStatus = rpcWarmupStatus;
342 return fRPCInWarmup;
343}
344
345bool IsDeprecatedRPCEnabled(const std::string& method)
346{
347 const std::vector<std::string> enabled_methods = gArgs.GetArgs("-deprecatedrpc");
348
349 return find(enabled_methods.begin(), enabled_methods.end(), method) != enabled_methods.end();
350}
351
352UniValue JSONRPCExec(const JSONRPCRequest& jreq, bool catch_errors)
353{
354 UniValue result;
355 if (catch_errors) {
356 try {
357 result = tableRPC.execute(jreq);
358 } catch (UniValue& e) {
359 return JSONRPCReplyObj(NullUniValue, std::move(e), jreq.id, jreq.m_json_version);
360 } catch (const std::exception& e) {
362 }
363 } else {
364 result = tableRPC.execute(jreq);
365 }
366
367 return JSONRPCReplyObj(std::move(result), NullUniValue, jreq.id, jreq.m_json_version);
368}
369
374static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, const std::vector<std::pair<std::string, bool>>& argNames)
375{
376 JSONRPCRequest out = in;
377 out.params = UniValue(UniValue::VARR);
378 // Build a map of parameters, and remove ones that have been processed, so that we can throw a focused error if
379 // there is an unknown one.
380 const std::vector<std::string>& keys = in.params.getKeys();
381 const std::vector<UniValue>& values = in.params.getValues();
382 std::unordered_map<std::string, const UniValue*> argsIn;
383 for (size_t i=0; i<keys.size(); ++i) {
384 auto [_, inserted] = argsIn.emplace(keys[i], &values[i]);
385 if (!inserted) {
386 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + keys[i] + " specified multiple times");
387 }
388 }
389 // Process expected parameters. If any parameters were left unspecified in
390 // the request before a parameter that was specified, null values need to be
391 // inserted at the unspecified parameter positions, and the "hole" variable
392 // below tracks the number of null values that need to be inserted.
393 // The "initial_hole_size" variable stores the size of the initial hole,
394 // i.e. how many initial positional arguments were left unspecified. This is
395 // used after the for-loop to add initial positional arguments from the
396 // "args" parameter, if present.
397 int hole = 0;
398 int initial_hole_size = 0;
399 const std::string* initial_param = nullptr;
400 UniValue options{UniValue::VOBJ};
401 for (const auto& [argNamePattern, named_only]: argNames) {
402 std::vector<std::string> vargNames = SplitString(argNamePattern, '|');
403 auto fr = argsIn.end();
404 for (const std::string & argName : vargNames) {
405 fr = argsIn.find(argName);
406 if (fr != argsIn.end()) {
407 break;
408 }
409 }
410
411 // Handle named-only parameters by pushing them into a temporary options
412 // object, and then pushing the accumulated options as the next
413 // positional argument.
414 if (named_only) {
415 if (fr != argsIn.end()) {
416 if (options.exists(fr->first)) {
417 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " specified multiple times");
418 }
419 options.pushKVEnd(fr->first, *fr->second);
420 argsIn.erase(fr);
421 }
422 continue;
423 }
424
425 if (!options.empty() || fr != argsIn.end()) {
426 for (int i = 0; i < hole; ++i) {
427 // Fill hole between specified parameters with JSON nulls,
428 // but not at the end (for backwards compatibility with calls
429 // that act based on number of specified parameters).
430 out.params.push_back(UniValue());
431 }
432 hole = 0;
433 if (!initial_param) initial_param = &argNamePattern;
434 } else {
435 hole += 1;
436 if (out.params.empty()) initial_hole_size = hole;
437 }
438
439 // If named input parameter "fr" is present, push it onto out.params. If
440 // options are present, push them onto out.params. If both are present,
441 // throw an error.
442 if (fr != argsIn.end()) {
443 if (!options.empty()) {
444 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " conflicts with parameter " + options.getKeys().front());
445 }
446 out.params.push_back(*fr->second);
447 argsIn.erase(fr);
448 }
449 if (!options.empty()) {
450 out.params.push_back(std::move(options));
451 options = UniValue{UniValue::VOBJ};
452 }
453 }
454 // If leftover "args" param was found, use it as a source of positional
455 // arguments and add named arguments after. This is a convenience for
456 // clients that want to pass a combination of named and positional
457 // arguments as described in doc/JSON-RPC-interface.md#parameter-passing
458 auto positional_args{argsIn.extract("args")};
459 if (positional_args && positional_args.mapped()->isArray()) {
460 if (initial_hole_size < (int)positional_args.mapped()->size() && initial_param) {
461 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + *initial_param + " specified twice both as positional and named argument");
462 }
463 // Assign positional_args to out.params and append named_args after.
464 UniValue named_args{std::move(out.params)};
465 out.params = *positional_args.mapped();
466 for (size_t i{out.params.size()}; i < named_args.size(); ++i) {
467 out.params.push_back(named_args[i]);
468 }
469 }
470 // If there are still arguments in the argsIn map, this is an error.
471 if (!argsIn.empty()) {
472 throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown named parameter " + argsIn.begin()->first);
473 }
474 // Return request with named arguments transformed to positional arguments
475 return out;
476}
477
478static bool ExecuteCommands(const std::vector<const CRPCCommand*>& commands, const JSONRPCRequest& request, UniValue& result)
479{
480 for (const auto& command : commands) {
481 if (ExecuteCommand(*command, request, result, &command == &commands.back())) {
482 return true;
483 }
484 }
485 return false;
486}
487
489{
490 // Return immediately if in warmup
491 {
493 if (fRPCInWarmup)
494 throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
495 }
496
497 // Find method
498 auto it = mapCommands.find(request.strMethod);
499 if (it != mapCommands.end()) {
500 UniValue result;
501 if (ExecuteCommands(it->second, request, result)) {
502 return result;
503 }
504 }
505 throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
506}
507
508static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler)
509{
510 try {
511 RPCCommandExecution execution(request.strMethod);
512 // Execute, convert arguments to array if necessary
513 if (request.params.isObject()) {
514 return command.actor(transformNamedArguments(request, command.argNames), result, last_handler);
515 } else {
516 return command.actor(request, result, last_handler);
517 }
518 } catch (const UniValue::type_error& e) {
519 throw JSONRPCError(RPC_TYPE_ERROR, e.what());
520 } catch (const std::exception& e) {
521 throw JSONRPCError(RPC_MISC_ERROR, e.what());
522 }
523}
524
525std::vector<std::string> CRPCTable::listCommands() const
526{
527 std::vector<std::string> commandList;
528 commandList.reserve(mapCommands.size());
529 for (const auto& i : mapCommands) commandList.emplace_back(i.first);
530 return commandList;
531}
532
534{
535 JSONRPCRequest request = args_request;
537
539 for (const auto& cmd : mapCommands) {
540 UniValue result;
541 if (ExecuteCommands(cmd.second, request, result)) {
542 for (const auto& values : result.getValues()) {
543 ret.push_back(values);
544 }
545 }
546 }
547 return ret;
548}
549
551{
552 if (!timerInterface)
553 timerInterface = iface;
554}
555
557{
558 timerInterface = iface;
559}
560
562{
563 if (timerInterface == iface)
564 timerInterface = nullptr;
565}
566
567void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds)
568{
569 if (!timerInterface)
570 throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
572 deadlineTimers.erase(name);
573 LogDebug(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name());
574 deadlineTimers.emplace(name, std::unique_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000)));
575}
576
ArgsManager gArgs
Definition: args.cpp:42
int ret
const auto cmd
const auto command
#define CHECK_NONFATAL(condition)
Identity function.
Definition: check.h:102
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: args.cpp:362
fs::path m_file_path
Definition: logging.h:141
std::string category
Definition: server.h:107
intptr_t unique_id
Definition: server.h:120
std::string name
Definition: server.h:108
Actor actor
Definition: server.h:109
RPC command dispatcher.
Definition: server.h:127
CRPCTable()
Definition: server.cpp:257
std::map< std::string, std::vector< const CRPCCommand * > > mapCommands
Definition: server.h:129
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
Definition: server.cpp:271
std::vector< std::string > listCommands() const
Returns a list of registered commands.
Definition: server.cpp:525
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
Definition: server.cpp:488
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:264
std::string help(const std::string &name, const JSONRPCRequest &helpreq) const
Definition: server.cpp:72
UniValue dumpArgMap(const JSONRPCRequest &request) const
Return all named arguments that need to be converted by the client from string to another JSON type.
Definition: server.cpp:533
Different type to mark Mutex at global scope.
Definition: sync.h:140
UniValue params
Definition: request.h:40
std::string strMethod
Definition: request.h:39
JSONRPCVersion m_json_version
Definition: request.h:46
enum JSONRPCRequest::Mode mode
std::optional< UniValue > id
Definition: request.h:38
RPC timer "driver".
Definition: server.h:52
virtual RPCTimerBase * NewTimer(std::function< void()> &func, int64_t millis)=0
Factory function for timers.
virtual const char * Name()=0
Implementation name.
void push_back(UniValue val)
Definition: univalue.cpp:104
const std::string & get_str() const
@ VOBJ
Definition: univalue.h:24
@ VSTR
Definition: univalue.h:24
@ VARR
Definition: univalue.h:24
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
void pushKV(std::string key, UniValue val)
Definition: univalue.cpp:126
bool isObject() const
Definition: univalue.h:86
int64_t GetStartupTime()
Definition: system.cpp:109
BCLog::Logger & LogInstance()
Definition: logging.cpp:24
#define LogDebug(category,...)
Definition: logging.h:280
@ RPC
Definition: logging.h:50
std::vector< std::string > SplitString(std::string_view str, char sep)
Definition: string.h:136
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:70
UniValue JSONRPCReplyObj(UniValue result, UniValue error, std::optional< UniValue > id, JSONRPCVersion jsonrpc_version)
Definition: request.cpp:51
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
Definition: request.cpp:165
const char * name
Definition: rest.cpp:49
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:40
@ RPC_METHOD_NOT_FOUND
Definition: protocol.h:32
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
Definition: protocol.h:41
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
Definition: protocol.h:58
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:44
@ RPC_IN_WARMUP
Client still warming up.
Definition: protocol.h:50
@ RPC_INTERNAL_ERROR
Definition: protocol.h:36
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:186
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:204
static const int64_t values[]
A selection of numbers that do not trigger int64_t overflow when added/subtracted.
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
Definition: server.cpp:550
bool IsDeprecatedRPCEnabled(const std::string &method)
Definition: server.cpp:345
void SetRPCWarmupFinished()
Definition: server.cpp:330
static RPCHelpMan uptime()
Definition: server.cpp:183
void StartRPC()
Definition: server.cpp:284
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
Definition: server.cpp:561
static RPCHelpMan getrpcinfo()
Definition: server.cpp:203
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
Definition: server.cpp:567
static bool ExecuteCommands(const std::vector< const CRPCCommand * > &commands, const JSONRPCRequest &request, UniValue &result)
Definition: server.cpp:478
bool RPCIsInWarmup(std::string *outStatus)
Definition: server.cpp:337
static RPCTimerInterface * timerInterface
Definition: server.cpp:37
static bool ExecuteCommand(const CRPCCommand &command, const JSONRPCRequest &request, UniValue &result, bool last_handler)
Definition: server.cpp:508
void StopRPC()
Definition: server.cpp:301
static RPCHelpMan stop()
Definition: server.cpp:156
static std::atomic< bool > g_rpc_running
Definition: server.cpp:33
static JSONRPCRequest transformNamedArguments(const JSONRPCRequest &in, const std::vector< std::pair< std::string, bool > > &argNames)
Process named arguments into a vector of positional arguments, based on the passed-in specification f...
Definition: server.cpp:374
static GlobalMutex g_deadline_timers_mutex
Definition: server.cpp:39
bool IsRPCRunning()
Query whether RPC is running.
Definition: server.cpp:314
void InterruptRPC()
Definition: server.cpp:290
UniValue JSONRPCExec(const JSONRPCRequest &jreq, bool catch_errors)
Definition: server.cpp:352
static bool fRPCInWarmup GUARDED_BY(g_rpc_warmup_mutex)
static GlobalMutex g_rpc_warmup_mutex
Definition: server.cpp:32
static RPCHelpMan help()
Definition: server.cpp:127
static RPCServerInfo g_rpc_server_info
Definition: server.cpp:55
static const CRPCCommand vRPCCommands[]
Definition: server.cpp:249
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
Definition: server.cpp:324
CRPCTable tableRPC
Definition: server.cpp:577
void RPCSetTimerInterface(RPCTimerInterface *iface)
Set the factory function for timers.
Definition: server.cpp:556
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
Definition: server.cpp:319
NodeContext & EnsureAnyNodeContext(const std::any &context)
Definition: server_util.cpp:25
std::string DefaultHint
Hint for default value.
Definition: util.h:216
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
bool hidden
For testing only.
Definition: util.h:169
RPCCommandExecution(const std::string &method)
Definition: server.cpp:60
std::list< RPCCommandExecutionInfo >::iterator it
Definition: server.cpp:59
SteadyClock::time_point start
Definition: server.cpp:46
std::string method
Definition: server.cpp:45
@ ANY
Special type to disable type checks (for testing only)
std::list< RPCCommandExecutionInfo > active_commands GUARDED_BY(mutex)
Mutex mutex
Definition: server.cpp:51
#define LOCK(cs)
Definition: sync.h:257
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:301
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1172
consteval auto _(util::TranslatedLiteral str)
Definition: translation.h:79
const UniValue NullUniValue
Definition: univalue.cpp:16
std::string Capitalize(std::string str)
Capitalizes the first character of the given string.
void UninterruptibleSleep(const std::chrono::microseconds &n)
Definition: time.cpp:20
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
Definition: time.cpp:76
assert(!tx.IsCoinBase())