Bitcoin Core 28.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{"help",
130 "\nList all commands, or get help for a specified command.\n",
131 {
132 {"command", RPCArg::Type::STR, RPCArg::DefaultHint{"all commands"}, "The command to get help on"},
133 },
134 {
135 RPCResult{RPCResult::Type::STR, "", "The help text"},
137 },
138 RPCExamples{""},
139 [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
140{
141 std::string strCommand;
142 if (jsonRequest.params.size() > 0) {
143 strCommand = jsonRequest.params[0].get_str();
144 }
145 if (strCommand == "dump_all_command_conversions") {
146 // Used for testing only, undocumented
147 return tableRPC.dumpArgMap(jsonRequest);
148 }
149
150 return tableRPC.help(strCommand, jsonRequest);
151},
152 };
153}
154
156{
157 static const std::string RESULT{CLIENT_NAME " stopping"};
158 return RPCHelpMan{"stop",
159 // Also accept the hidden 'wait' integer argument (milliseconds)
160 // For instance, 'stop 1000' makes the call wait 1 second before returning
161 // to the client (intended for testing)
162 "\nRequest a graceful shutdown of " CLIENT_NAME ".",
163 {
164 {"wait", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "how long to wait in ms", RPCArgOptions{.hidden=true}},
165 },
166 RPCResult{RPCResult::Type::STR, "", "A string with the content '" + RESULT + "'"},
167 RPCExamples{""},
168 [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue
169{
170 // Event loop will exit after current HTTP requests have been handled, so
171 // this reply will get back to the client.
172 CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown_request))());
173 if (jsonRequest.params[0].isNum()) {
174 UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()});
175 }
176 return RESULT;
177},
178 };
179}
180
182{
183 return RPCHelpMan{"uptime",
184 "\nReturns the total uptime of the server.\n",
185 {},
186 RPCResult{
187 RPCResult::Type::NUM, "", "The number of seconds that the server has been running"
188 },
190 HelpExampleCli("uptime", "")
191 + HelpExampleRpc("uptime", "")
192 },
193 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
194{
195 return GetTime() - GetStartupTime();
196}
197 };
198}
199
201{
202 return RPCHelpMan{"getrpcinfo",
203 "\nReturns details of the RPC server.\n",
204 {},
205 RPCResult{
206 RPCResult::Type::OBJ, "", "",
207 {
208 {RPCResult::Type::ARR, "active_commands", "All active commands",
209 {
210 {RPCResult::Type::OBJ, "", "Information about an active command",
211 {
212 {RPCResult::Type::STR, "method", "The name of the RPC command"},
213 {RPCResult::Type::NUM, "duration", "The running time in microseconds"},
214 }},
215 }},
216 {RPCResult::Type::STR, "logpath", "The complete file path to the debug log"},
217 }
218 },
220 HelpExampleCli("getrpcinfo", "")
221 + HelpExampleRpc("getrpcinfo", "")},
222 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
223{
225 UniValue active_commands(UniValue::VARR);
226 for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands) {
228 entry.pushKV("method", info.method);
229 entry.pushKV("duration", int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - info.start)});
230 active_commands.push_back(std::move(entry));
231 }
232
233 UniValue result(UniValue::VOBJ);
234 result.pushKV("active_commands", std::move(active_commands));
235
236 const std::string path = LogInstance().m_file_path.utf8string();
237 UniValue log_path(UniValue::VSTR, path);
238 result.pushKV("logpath", std::move(log_path));
239
240 return result;
241}
242 };
243}
244
246 /* Overall control/query calls */
247 {"control", &getrpcinfo},
248 {"control", &help},
249 {"control", &stop},
250 {"control", &uptime},
251};
252
254{
255 for (const auto& c : vRPCCommands) {
256 appendCommand(c.name, &c);
257 }
258}
259
260void CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
261{
262 CHECK_NONFATAL(!IsRPCRunning()); // Only add commands before rpc is running
263
264 mapCommands[name].push_back(pcmd);
265}
266
267bool CRPCTable::removeCommand(const std::string& name, const CRPCCommand* pcmd)
268{
269 auto it = mapCommands.find(name);
270 if (it != mapCommands.end()) {
271 auto new_end = std::remove(it->second.begin(), it->second.end(), pcmd);
272 if (it->second.end() != new_end) {
273 it->second.erase(new_end, it->second.end());
274 return true;
275 }
276 }
277 return false;
278}
279
281{
282 LogDebug(BCLog::RPC, "Starting RPC\n");
283 g_rpc_running = true;
284}
285
287{
288 static std::once_flag g_rpc_interrupt_flag;
289 // This function could be called twice if the GUI has been started with -server=1.
290 std::call_once(g_rpc_interrupt_flag, []() {
291 LogDebug(BCLog::RPC, "Interrupting RPC\n");
292 // Interrupt e.g. running longpolls
293 g_rpc_running = false;
294 });
295}
296
298{
299 static std::once_flag g_rpc_stop_flag;
300 // This function could be called twice if the GUI has been started with -server=1.
302 std::call_once(g_rpc_stop_flag, [&]() {
303 LogDebug(BCLog::RPC, "Stopping RPC\n");
304 WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
306 LogDebug(BCLog::RPC, "RPC stopped.\n");
307 });
308}
309
311{
312 return g_rpc_running;
313}
314
316{
317 if (!IsRPCRunning()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
318}
319
320void SetRPCWarmupStatus(const std::string& newStatus)
321{
323 rpcWarmupStatus = newStatus;
324}
325
327{
329 assert(fRPCInWarmup);
330 fRPCInWarmup = false;
331}
332
333bool RPCIsInWarmup(std::string *outStatus)
334{
336 if (outStatus)
337 *outStatus = rpcWarmupStatus;
338 return fRPCInWarmup;
339}
340
341bool IsDeprecatedRPCEnabled(const std::string& method)
342{
343 const std::vector<std::string> enabled_methods = gArgs.GetArgs("-deprecatedrpc");
344
345 return find(enabled_methods.begin(), enabled_methods.end(), method) != enabled_methods.end();
346}
347
348UniValue JSONRPCExec(const JSONRPCRequest& jreq, bool catch_errors)
349{
350 UniValue result;
351 if (catch_errors) {
352 try {
353 result = tableRPC.execute(jreq);
354 } catch (UniValue& e) {
355 return JSONRPCReplyObj(NullUniValue, std::move(e), jreq.id, jreq.m_json_version);
356 } catch (const std::exception& e) {
358 }
359 } else {
360 result = tableRPC.execute(jreq);
361 }
362
363 return JSONRPCReplyObj(std::move(result), NullUniValue, jreq.id, jreq.m_json_version);
364}
365
370static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, const std::vector<std::pair<std::string, bool>>& argNames)
371{
372 JSONRPCRequest out = in;
373 out.params = UniValue(UniValue::VARR);
374 // Build a map of parameters, and remove ones that have been processed, so that we can throw a focused error if
375 // there is an unknown one.
376 const std::vector<std::string>& keys = in.params.getKeys();
377 const std::vector<UniValue>& values = in.params.getValues();
378 std::unordered_map<std::string, const UniValue*> argsIn;
379 for (size_t i=0; i<keys.size(); ++i) {
380 auto [_, inserted] = argsIn.emplace(keys[i], &values[i]);
381 if (!inserted) {
382 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + keys[i] + " specified multiple times");
383 }
384 }
385 // Process expected parameters. If any parameters were left unspecified in
386 // the request before a parameter that was specified, null values need to be
387 // inserted at the unspecified parameter positions, and the "hole" variable
388 // below tracks the number of null values that need to be inserted.
389 // The "initial_hole_size" variable stores the size of the initial hole,
390 // i.e. how many initial positional arguments were left unspecified. This is
391 // used after the for-loop to add initial positional arguments from the
392 // "args" parameter, if present.
393 int hole = 0;
394 int initial_hole_size = 0;
395 const std::string* initial_param = nullptr;
396 UniValue options{UniValue::VOBJ};
397 for (const auto& [argNamePattern, named_only]: argNames) {
398 std::vector<std::string> vargNames = SplitString(argNamePattern, '|');
399 auto fr = argsIn.end();
400 for (const std::string & argName : vargNames) {
401 fr = argsIn.find(argName);
402 if (fr != argsIn.end()) {
403 break;
404 }
405 }
406
407 // Handle named-only parameters by pushing them into a temporary options
408 // object, and then pushing the accumulated options as the next
409 // positional argument.
410 if (named_only) {
411 if (fr != argsIn.end()) {
412 if (options.exists(fr->first)) {
413 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " specified multiple times");
414 }
415 options.pushKVEnd(fr->first, *fr->second);
416 argsIn.erase(fr);
417 }
418 continue;
419 }
420
421 if (!options.empty() || fr != argsIn.end()) {
422 for (int i = 0; i < hole; ++i) {
423 // Fill hole between specified parameters with JSON nulls,
424 // but not at the end (for backwards compatibility with calls
425 // that act based on number of specified parameters).
426 out.params.push_back(UniValue());
427 }
428 hole = 0;
429 if (!initial_param) initial_param = &argNamePattern;
430 } else {
431 hole += 1;
432 if (out.params.empty()) initial_hole_size = hole;
433 }
434
435 // If named input parameter "fr" is present, push it onto out.params. If
436 // options are present, push them onto out.params. If both are present,
437 // throw an error.
438 if (fr != argsIn.end()) {
439 if (!options.empty()) {
440 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " conflicts with parameter " + options.getKeys().front());
441 }
442 out.params.push_back(*fr->second);
443 argsIn.erase(fr);
444 }
445 if (!options.empty()) {
446 out.params.push_back(std::move(options));
447 options = UniValue{UniValue::VOBJ};
448 }
449 }
450 // If leftover "args" param was found, use it as a source of positional
451 // arguments and add named arguments after. This is a convenience for
452 // clients that want to pass a combination of named and positional
453 // arguments as described in doc/JSON-RPC-interface.md#parameter-passing
454 auto positional_args{argsIn.extract("args")};
455 if (positional_args && positional_args.mapped()->isArray()) {
456 if (initial_hole_size < (int)positional_args.mapped()->size() && initial_param) {
457 throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + *initial_param + " specified twice both as positional and named argument");
458 }
459 // Assign positional_args to out.params and append named_args after.
460 UniValue named_args{std::move(out.params)};
461 out.params = *positional_args.mapped();
462 for (size_t i{out.params.size()}; i < named_args.size(); ++i) {
463 out.params.push_back(named_args[i]);
464 }
465 }
466 // If there are still arguments in the argsIn map, this is an error.
467 if (!argsIn.empty()) {
468 throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown named parameter " + argsIn.begin()->first);
469 }
470 // Return request with named arguments transformed to positional arguments
471 return out;
472}
473
474static bool ExecuteCommands(const std::vector<const CRPCCommand*>& commands, const JSONRPCRequest& request, UniValue& result)
475{
476 for (const auto& command : commands) {
477 if (ExecuteCommand(*command, request, result, &command == &commands.back())) {
478 return true;
479 }
480 }
481 return false;
482}
483
485{
486 // Return immediately if in warmup
487 {
489 if (fRPCInWarmup)
490 throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
491 }
492
493 // Find method
494 auto it = mapCommands.find(request.strMethod);
495 if (it != mapCommands.end()) {
496 UniValue result;
497 if (ExecuteCommands(it->second, request, result)) {
498 return result;
499 }
500 }
501 throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
502}
503
504static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& request, UniValue& result, bool last_handler)
505{
506 try {
507 RPCCommandExecution execution(request.strMethod);
508 // Execute, convert arguments to array if necessary
509 if (request.params.isObject()) {
510 return command.actor(transformNamedArguments(request, command.argNames), result, last_handler);
511 } else {
512 return command.actor(request, result, last_handler);
513 }
514 } catch (const UniValue::type_error& e) {
515 throw JSONRPCError(RPC_TYPE_ERROR, e.what());
516 } catch (const std::exception& e) {
517 throw JSONRPCError(RPC_MISC_ERROR, e.what());
518 }
519}
520
521std::vector<std::string> CRPCTable::listCommands() const
522{
523 std::vector<std::string> commandList;
524 commandList.reserve(mapCommands.size());
525 for (const auto& i : mapCommands) commandList.emplace_back(i.first);
526 return commandList;
527}
528
530{
531 JSONRPCRequest request = args_request;
533
535 for (const auto& cmd : mapCommands) {
536 UniValue result;
537 if (ExecuteCommands(cmd.second, request, result)) {
538 for (const auto& values : result.getValues()) {
539 ret.push_back(values);
540 }
541 }
542 }
543 return ret;
544}
545
547{
548 if (!timerInterface)
549 timerInterface = iface;
550}
551
553{
554 timerInterface = iface;
555}
556
558{
559 if (timerInterface == iface)
560 timerInterface = nullptr;
561}
562
563void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds)
564{
565 if (!timerInterface)
566 throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
568 deadlineTimers.erase(name);
569 LogDebug(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name());
570 deadlineTimers.emplace(name, std::unique_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000)));
571}
572
ArgsManager gArgs
Definition: args.cpp:42
int ret
const auto cmd
const auto command
#define CHECK_NONFATAL(condition)
Identity function.
Definition: check.h:81
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:253
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:267
std::vector< std::string > listCommands() const
Returns a list of registered commands.
Definition: server.cpp:521
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
Definition: server.cpp:484
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:260
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:529
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
std::string utf8string() const
Return a UTF-8 representation of the path as a std::string, for compatibility with code using std::st...
Definition: fs.h:63
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:184
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:202
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:546
bool IsDeprecatedRPCEnabled(const std::string &method)
Definition: server.cpp:341
void SetRPCWarmupFinished()
Definition: server.cpp:326
static RPCHelpMan uptime()
Definition: server.cpp:181
void StartRPC()
Definition: server.cpp:280
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
Definition: server.cpp:557
static RPCHelpMan getrpcinfo()
Definition: server.cpp:200
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
Definition: server.cpp:563
static bool ExecuteCommands(const std::vector< const CRPCCommand * > &commands, const JSONRPCRequest &request, UniValue &result)
Definition: server.cpp:474
bool RPCIsInWarmup(std::string *outStatus)
Definition: server.cpp:333
static RPCTimerInterface * timerInterface
Definition: server.cpp:37
static bool ExecuteCommand(const CRPCCommand &command, const JSONRPCRequest &request, UniValue &result, bool last_handler)
Definition: server.cpp:504
void StopRPC()
Definition: server.cpp:297
static RPCHelpMan stop()
Definition: server.cpp:155
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:370
static GlobalMutex g_deadline_timers_mutex
Definition: server.cpp:39
bool IsRPCRunning()
Query whether RPC is running.
Definition: server.cpp:310
void InterruptRPC()
Definition: server.cpp:286
UniValue JSONRPCExec(const JSONRPCRequest &jreq, bool catch_errors)
Definition: server.cpp:348
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:245
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
Definition: server.cpp:320
CRPCTable tableRPC
Definition: server.cpp:573
void RPCSetTimerInterface(RPCTimerInterface *iface)
Set the factory function for timers.
Definition: server.cpp:552
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
Definition: server.cpp:315
NodeContext & EnsureAnyNodeContext(const std::any &context)
Definition: server_util.cpp:21
std::string DefaultHint
Hint for default value.
Definition: util.h:217
@ 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:170
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
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:47
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1165
bilingual_str _(ConstevalStringLiteral str)
Translation function.
Definition: translation.h:80
const UniValue NullUniValue
Definition: univalue.cpp:16
std::string Capitalize(std::string str)
Capitalizes the first character of the given string.
assert(!tx.IsCoinBase())