26 #ifdef HAVE_MALLOC_INFO 35 "\nSet the local time to given timestamp (-regtest only)\n",
38 "Pass 0 to go back to using the system time."},
45 throw std::runtime_error(
"setmocktime is for regression testing (-regtest mode) only");
56 const int64_t time{request.params[0].getInt<int64_t>()};
61 auto node_context = util::AnyPtr<NodeContext>(request.context);
63 for (
const auto& chain_client : node_context->chain_clients) {
64 chain_client->setMockTime(time);
73 #if defined(USE_SYSCALL_SANDBOX) 77 "invokedisallowedsyscall",
78 "\nInvoke a disallowed syscall to trigger a syscall sandbox violation. Used for testing purposes.\n",
85 throw std::runtime_error(
"invokedisallowedsyscall is used for testing only.");
87 TestDisallowedSandboxCall();
92 #endif // USE_SYSCALL_SANDBOX 97 "\nBump the scheduler into the future (-regtest only)\n",
106 throw std::runtime_error(
"mockscheduler is for regression testing (-regtest mode) only");
111 int64_t delta_seconds = request.params[0].getInt<int64_t>();
112 if (delta_seconds <= 0 || delta_seconds > 3600) {
113 throw std::runtime_error(
"delta_time must be between 1 and 3600 seconds (1 hr)");
116 auto node_context =
CHECK_NONFATAL(util::AnyPtr<NodeContext>(request.context));
119 node_context->scheduler->MockForward(std::chrono::seconds(delta_seconds));
139 #ifdef HAVE_MALLOC_INFO 140 static std::string RPCMallocInfo()
144 FILE *f = open_memstream(&ptr, &size);
149 std::string rv(ptr, size);
164 "Returns an object containing information about memory usage.\n",
167 " - \"stats\" returns general statistics about memory usage in the daemon.\n" 168 " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+)."},
179 {
RPCResult::Type::NUM,
"locked",
"Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk."},
195 std::string mode = request.params[0].
isNull() ?
"stats" : request.params[0].get_str();
196 if (mode ==
"stats") {
200 }
else if (mode ==
"mallocinfo") {
201 #ifdef HAVE_MALLOC_INFO 202 return RPCMallocInfo();
215 for (
unsigned int i = 0; i < cats.
size(); ++i) {
216 std::string cat = cats[i].
get_str();
234 "Gets and sets the logging configuration.\n" 235 "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" 236 "When called with arguments, adds or removes categories from debug logging and return the lists above.\n" 237 "The arguments are evaluated in order \"include\", \"exclude\".\n" 238 "If an item is both included and excluded, it will thus end up being excluded.\n" 240 "In addition, the following are available as category names with special meanings:\n" 241 " - \"all\", \"1\" : represent all logging categories.\n" 242 " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n" 267 if (request.params[0].isArray()) {
270 if (request.params[1].isArray()) {
274 uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
282 for (
const auto& logCatActive :
LogInstance().LogCategoriesList()) {
283 result.
pushKV(logCatActive.category, logCatActive.active);
294 "\nSimply echo back the input arguments. This command is for testing.\n" 295 "\nIt will return an internal bug report when arg9='trigger_internal_bug' is passed.\n" 296 "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in " 297 "bitcoin-cli and the GUI. There is no server-side difference.",
314 if (request.params[9].isStr()) {
315 CHECK_NONFATAL(request.params[9].get_str() !=
"trigger_internal_bug");
318 return request.params;
330 "\nEcho back the input argument, passing it through a spawned process in a multiprocess build.\n" 331 "This command is for testing.\n",
338 std::unique_ptr<interfaces::Echo>
echo;
348 auto init =
ipc->spawnProcess(
"bitcoin-node");
359 return echo->echo(request.params[0].get_str());
367 if (!index_name.empty() && index_name != summary.name)
return ret_summary;
370 entry.
pushKV(
"synced", summary.synced);
371 entry.
pushKV(
"best_block_height", summary.best_block_height);
372 ret_summary.
pushKV(summary.name, entry);
379 "\nReturns the status of one or all available indices currently running in the node.\n",
403 const std::string index_name = request.params[0].isNull() ?
"" : request.params[0].get_str();
433 #if defined(USE_SYSCALL_SANDBOX) 434 {
"hidden", &invokedisallowedsyscall},
435 #endif // USE_SYSCALL_SANDBOX 437 for (
const auto& c : commands) {
438 t.appendCommand(c.name, &c);
void EnableCategory(LogFlags flag)
static UniValue SummaryToJSON(const IndexSummary &&summary, std::string index_name)
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
BCLog::Logger & LogInstance()
static LockedPoolManager & Instance()
Return the current instance, or create it once.
void pushKVs(UniValue obj)
static RPCHelpMan setmocktime()
static void EnableOrDisableLogCategories(UniValue cats, bool enable)
#define CHECK_NONFATAL(condition)
Identity function.
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
static RPCHelpMan logging()
const std::string & get_str() const
const UniValue & get_array() const
static RPCHelpMan echoipc()
Invalid, missing or duplicate parameter.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
NodeContext struct containing references to chain state and connection state.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
virtual std::unique_ptr< Echo > makeEcho()
UniValue JSONRPCError(int code, const std::string &message)
static UniValue RPCLockedMemoryInfo()
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
static RPCHelpMan getmemoryinfo()
std::unique_ptr< interfaces::Init > init
Special type to disable type checks (for testing only)
uint32_t GetCategoryMask() const
void UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
void DisableCategory(LogFlags flag)
static RPCHelpMan echo(const std::string &name)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Optional arg that is a named argument and has a default value of null.
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
static RPCHelpMan echojson()
Optional argument with default value omitted because they are implicitly clear.
bool IsTestChain() const
If this chain is exclusively used for testing.
const CChainParams & Params()
Return the currently selected parameters.
void pushKV(std::string key, UniValue val)
static RPCHelpMan getindexinfo()
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
Stats stats() const
Get pool usage statistics.
Initial interface created when a process is first started, and used to give and get access to other i...
Special dictionary with keys that are not literals.
static RPCHelpMan mockscheduler()
void RegisterNodeRPCCommands(CRPCTable &t)
bool IsMockableChain() const
If this chain allows time to be mocked.
Interface providing access to interprocess-communication (IPC) functionality.
NodeContext & EnsureAnyNodeContext(const std::any &context)
std::string LogCategoriesString() const
Returns a string with the log categories in alphabetical order.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
IndexSummary GetSummary() const
Get a summary of the index and its state.