6#include <bitcoin-build-config.h>
22#include <validation.h>
30#include <unordered_map>
56 std::list<RPCCommandExecutionInfo>::iterator
it;
74 std::vector<std::pair<std::string, const CRPCCommand*> >
vCommands;
78 vCommands.emplace_back(entry.second.front()->category + entry.first, entry.second.front());
86 std::string strMethod =
pcmd->name;
89 jreq.strMethod = strMethod;
99 if (
strHelp.find(
'\n') != std::string::npos)
102 if (category !=
pcmd->category)
104 if (!category.empty())
106 category =
pcmd->category;
123 "List all commands, or get help for a specified command.\n",
134 auto command{
self.MaybeArg<std::string_view>(
"command")};
135 if (
command ==
"dump_all_command_conversions") {
176 "Returns the total uptime of the server.\n",
196 "Returns details of the RPC server.\n",
221 entry.
pushKV(
"method", info.method);
264 auto new_end = std::remove(it->second.begin(), it->second.end(),
pcmd);
265 if (it->second.end() !=
new_end) {
266 it->second.erase(
new_end, it->second.end());
354 }
catch (
const std::exception&
e) {
376 std::unordered_map<std::string, const UniValue*>
argsIn;
377 for (
size_t i=0; i<keys.size(); ++i) {
410 if (options.exists(
fr->first)) {
413 options.pushKVEnd(
fr->first, *
fr->second);
419 if (!options.empty() ||
fr !=
argsIn.end()) {
420 for (
int i = 0; i <
hole; ++i) {
437 if (!options.empty()) {
440 out.params.push_back(*
fr->second);
443 if (!options.empty()) {
444 out.params.push_back(std::move(options));
460 for (
size_t i{out.params.size()}; i <
named_args.size(); ++i) {
514 }
catch (
const std::exception&
e) {
#define CHECK_NONFATAL(condition)
Identity function.
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
std::map< std::string, std::vector< const CRPCCommand * > > mapCommands
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
std::string help(std::string_view name, const JSONRPCRequest &helpreq) const
std::vector< std::string > listCommands() const
Returns a list of registered commands.
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
UniValue dumpArgMap(const JSONRPCRequest &request) const
Return all named arguments that need to be converted by the client from string to another JSON type.
Different type to mark Mutex at global scope.
enum JSONRPCRequest::Mode mode
void push_back(UniValue val)
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
void pushKV(std::string key, UniValue val)
SteadyClock::duration GetUptime()
Monotonic uptime (not affected by system time changes).
#define LogDebug(category,...)
BCLog::Logger & LogInstance()
std::vector< std::string > SplitString(std::string_view str, char sep)
UniValue JSONRPCError(int code, const std::string &message)
UniValue JSONRPCReplyObj(UniValue result, UniValue error, std::optional< UniValue > id, JSONRPCVersion jsonrpc_version)
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
@ RPC_MISC_ERROR
General application defined errors.
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_IN_WARMUP
Client still warming up.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
static const CRPCCommand vRPCCommands[]
static const int64_t values[]
A selection of numbers that do not trigger int64_t overflow when added/subtracted.
bool IsDeprecatedRPCEnabled(const std::string &method)
void SetRPCWarmupFinished()
static RPCHelpMan uptime()
static RPCHelpMan getrpcinfo()
static bool ExecuteCommands(const std::vector< const CRPCCommand * > &commands, const JSONRPCRequest &request, UniValue &result)
bool RPCIsInWarmup(std::string *outStatus)
static bool ExecuteCommand(const CRPCCommand &command, const JSONRPCRequest &request, UniValue &result, bool last_handler)
static std::atomic< bool > g_rpc_running
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...
bool IsRPCRunning()
Query whether RPC is running.
void SetRPCWarmupStarting()
UniValue JSONRPCExec(const JSONRPCRequest &jreq, bool catch_errors)
static GlobalMutex g_rpc_warmup_mutex
static RPCServerInfo g_rpc_server_info
static const CRPCCommand vRPCCommands[]
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
bool IsRPCRunning()
Query whether RPC is running.
NodeContext & EnsureAnyNodeContext(const std::any &context)
std::string DefaultHint
Hint for default value.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
bool hidden
For testing only.
RPCCommandExecution(const std::string &method)
std::list< RPCCommandExecutionInfo >::iterator it
SteadyClock::time_point start
@ ANY
Special type to disable type checks (for testing only)
std::list< RPCCommandExecutionInfo > active_commands GUARDED_BY(mutex)
consteval auto _(util::TranslatedLiteral str)
const UniValue NullUniValue
std::string Capitalize(std::string str)
Capitalizes the first character of the given string.
void UninterruptibleSleep(const std::chrono::microseconds &n)
constexpr int64_t TicksSeconds(Duration d)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.