Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 26 Lines | |||||
#include <cstdint> | #include <cstdint> | ||||
#ifdef HAVE_MALLOC_INFO | #ifdef HAVE_MALLOC_INFO | ||||
#include <malloc.h> | #include <malloc.h> | ||||
#endif | #endif | ||||
static UniValue validateaddress(const Config &config, | static UniValue validateaddress(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"validateaddress", | "validateaddress", | ||||
"\nReturn information about the given bitcoin address.\n", | "\nReturn information about the given bitcoin address.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, /* opt */ false, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The bitcoin address to validate"}, | /* default_val */ "", "The bitcoin address to validate"}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"{\n" | "{\n" | ||||
" \"isvalid\" : true|false, (boolean) If the address is " | " \"isvalid\" : true|false, (boolean) If the address is " | ||||
"valid or not. If not, this is the only property returned.\n" | "valid or not. If not, this is the only property returned.\n" | ||||
" \"address\" : \"address\", (string) The bitcoin address " | " \"address\" : \"address\", (string) The bitcoin " | ||||
"address " | |||||
"validated\n" | "validated\n" | ||||
" \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | " \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | ||||
"scriptPubKey generated by the address\n" | "scriptPubKey generated by the address\n" | ||||
" \"isscript\" : true|false, (boolean) If the key is a " | " \"isscript\" : true|false, (boolean) If the key is a " | ||||
"script\n" | "script\n" | ||||
"}\n" | "}\n"}, | ||||
"\nExamples:\n" + | RPCExamples{ | ||||
HelpExampleCli("validateaddress", | HelpExampleCli("validateaddress", | ||||
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + | "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + | ||||
HelpExampleRpc("validateaddress", | HelpExampleRpc("validateaddress", | ||||
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")); | "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | ||||
bool isValid = IsValidDestination(dest); | bool isValid = IsValidDestination(dest); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("isvalid", isValid); | ret.pushKV("isvalid", isValid); | ||||
Show All 32 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"A json array of hex-encoded public keys.", | "A json array of hex-encoded public keys.", | ||||
{ | { | ||||
{"key", RPCArg::Type::STR_HEX, /* opt */ false, | {"key", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "The hex-encoded public key"}, | /* default_val */ "", "The hex-encoded public key"}, | ||||
}}, | }}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{"{\n" | ||||
"\nResult:\n" | " \"address\":\"multisigaddress\", (string) The " | ||||
"{\n" | "value of the new " | ||||
" \"address\":\"multisigaddress\", (string) The value of the new " | |||||
"multisig address.\n" | "multisig address.\n" | ||||
" \"redeemScript\":\"script\" (string) The string value of " | " \"redeemScript\":\"script\" (string) The " | ||||
"string value of " | |||||
"the hex-encoded redemption script.\n" | "the hex-encoded redemption script.\n" | ||||
"}\n" | "}\n"}, | ||||
RPCExamples{ | |||||
"\nExamples:\n" | |||||
"\nCreate a multisig address from 2 public keys\n" + | "\nCreate a multisig address from 2 public keys\n" + | ||||
HelpExampleCli("createmultisig", | HelpExampleCli( | ||||
"createmultisig", | |||||
"2 " | "2 " | ||||
"\"[" | "\"[" | ||||
"\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd3" | "\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd3" | ||||
"42cf11ae157a7ace5fd\\\"," | "42cf11ae157a7ace5fd\\\"," | ||||
"\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e1" | "\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e1" | ||||
"7e107ef3f6aa5a61626\\\"]\"") + | "7e107ef3f6aa5a61626\\\"]\"") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("createmultisig", | HelpExampleRpc( | ||||
"createmultisig", | |||||
"2, " | "2, " | ||||
"\"[" | "\"[" | ||||
"\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd3" | "\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd3" | ||||
"42cf11ae157a7ace5fd\\\"," | "42cf11ae157a7ace5fd\\\"," | ||||
"\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e1" | "\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e1" | ||||
"7e107ef3f6aa5a61626\\\"]\""); | "7e107ef3f6aa5a61626\\\"]\"")}, | ||||
} | |||||
.ToString(); | |||||
throw std::runtime_error(msg); | throw std::runtime_error(msg); | ||||
} | } | ||||
int required = request.params[0].get_int(); | int required = request.params[0].get_int(); | ||||
// Get the public keys | // Get the public keys | ||||
const UniValue &keys = request.params[1].get_array(); | const UniValue &keys = request.params[1].get_array(); | ||||
std::vector<CPubKey> pubkeys; | std::vector<CPubKey> pubkeys; | ||||
Show All 22 Lines | static UniValue createmultisig(const Config &config, | ||||
result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue verifymessage(const Config &config, | static UniValue verifymessage(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 3) { | if (request.fHelp || request.params.size() != 3) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"verifymessage", | "verifymessage", | ||||
"\nVerify a signed message\n", | "\nVerify a signed message\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, /* opt */ false, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"The bitcoin address to use for the signature."}, | "The bitcoin address to use for the signature."}, | ||||
{"signature", RPCArg::Type::STR, /* opt */ false, | {"signature", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"The signature provided by the signer in base 64 encoding " | "The signature provided by the signer in base 64 encoding " | ||||
"(see signmessage)."}, | "(see signmessage)."}, | ||||
{"message", RPCArg::Type::STR, /* opt */ false, | {"message", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The message that was signed."}, | /* default_val */ "", "The message that was signed."}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{"true|false (boolean) If the signature is verified or " | ||||
"\nResult:\n" | "not.\n"}, | ||||
"true|false (boolean) If the signature is verified or not.\n" | RPCExamples{ | ||||
"\nExamples:\n" | |||||
"\nUnlock the wallet for 30 seconds\n" + | "\nUnlock the wallet for 30 seconds\n" + | ||||
HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + | HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + | ||||
"\nCreate the signature\n" + | "\nCreate the signature\n" + | ||||
HelpExampleCli( | HelpExampleCli( | ||||
"signmessage", | "signmessage", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + | ||||
"\nVerify the signature\n" + | "\nVerify the signature\n" + | ||||
HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | HelpExampleCli("verifymessage", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | |||||
"XX\" \"signature\" \"my " | "XX\" \"signature\" \"my " | ||||
"message\"") + | "message\"") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | HelpExampleRpc("verifymessage", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | |||||
"XX\", \"signature\", \"my " | "XX\", \"signature\", \"my " | ||||
"message\"")); | "message\"")}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string strAddress = request.params[0].get_str(); | std::string strAddress = request.params[0].get_str(); | ||||
std::string strSign = request.params[1].get_str(); | std::string strSign = request.params[1].get_str(); | ||||
std::string strMessage = request.params[2].get_str(); | std::string strMessage = request.params[2].get_str(); | ||||
Show All 26 Lines | static UniValue verifymessage(const Config &config, | ||||
} | } | ||||
return (pubkey.GetID() == *keyID); | return (pubkey.GetID() == *keyID); | ||||
} | } | ||||
static UniValue signmessagewithprivkey(const Config &config, | static UniValue signmessagewithprivkey(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 2) { | if (request.fHelp || request.params.size() != 2) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{"signmessagewithprivkey", | "signmessagewithprivkey", | ||||
"\nSign a message with the private key of an address\n", | "\nSign a message with the private key of an address\n", | ||||
{ | { | ||||
{"privkey", RPCArg::Type::STR, /* opt */ false, | {"privkey", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"The private key to sign the message with."}, | "The private key to sign the message with."}, | ||||
{"message", RPCArg::Type::STR, /* opt */ false, | {"message", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", "The message to create a signature of."}, | ||||
"The message to create a signature of."}, | }, | ||||
}} | RPCResult{ | ||||
.ToString() + | |||||
"\nResult:\n" | |||||
"\"signature\" (string) The signature of the message " | "\"signature\" (string) The signature of the message " | ||||
"encoded in base 64\n" | "encoded in base 64\n"}, | ||||
"\nExamples:\n" | RPCExamples{"\nCreate the signature\n" + | ||||
"\nCreate the signature\n" + | |||||
HelpExampleCli("signmessagewithprivkey", | HelpExampleCli("signmessagewithprivkey", | ||||
"\"privkey\" \"my message\"") + | "\"privkey\" \"my message\"") + | ||||
"\nVerify the signature\n" + | "\nVerify the signature\n" + | ||||
HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | HelpExampleCli("verifymessage", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" | |||||
"XX\" \"signature\" \"my " | "XX\" \"signature\" \"my " | ||||
"message\"") + | "message\"") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("signmessagewithprivkey", | HelpExampleRpc("signmessagewithprivkey", | ||||
"\"privkey\", \"my message\"")); | "\"privkey\", \"my message\"")}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
std::string strPrivkey = request.params[0].get_str(); | std::string strPrivkey = request.params[0].get_str(); | ||||
std::string strMessage = request.params[1].get_str(); | std::string strMessage = request.params[1].get_str(); | ||||
CKey key = DecodeSecret(strPrivkey); | CKey key = DecodeSecret(strPrivkey); | ||||
if (!key.IsValid()) { | if (!key.IsValid()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); | ||||
Show All 17 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"setmocktime", | "setmocktime", | ||||
"\nSet the local time to given timestamp (-regtest only)\n", | "\nSet the local time to given timestamp (-regtest only)\n", | ||||
{ | { | ||||
{"timestamp", RPCArg::Type::NUM, /* opt */ false, | {"timestamp", RPCArg::Type::NUM, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"Unix seconds-since-epoch timestamp\n" | "Unix seconds-since-epoch timestamp\n" | ||||
" Pass 0 to go back to using the system time."}, | " Pass 0 to go back to using the system time."}, | ||||
}}.ToString()); | }, | ||||
RPCResults{}, | |||||
RPCExamples{""}, | |||||
} | |||||
.ToString()); | |||||
} | } | ||||
if (!config.GetChainParams().MineBlocksOnDemand()) { | if (!config.GetChainParams().MineBlocksOnDemand()) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"setmocktime for regression testing (-regtest mode) only"); | "setmocktime for regression testing (-regtest mode) only"); | ||||
} | } | ||||
// For now, don't change mocktime if we're in the middle of validation, as | // For now, don't change mocktime if we're in the middle of validation, as | ||||
Show All 40 Lines | |||||
#endif | #endif | ||||
static UniValue getmemoryinfo(const Config &config, | static UniValue getmemoryinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
/* Please, avoid using the word "pool" here in the RPC interface or help, | /* Please, avoid using the word "pool" here in the RPC interface or help, | ||||
* as users will undoubtedly confuse it with the other "memory pool" | * as users will undoubtedly confuse it with the other "memory pool" | ||||
*/ | */ | ||||
if (request.fHelp || request.params.size() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"getmemoryinfo", | "getmemoryinfo", | ||||
"Returns an object containing information about memory " | "Returns an object containing information about memory " | ||||
"usage.\n", | "usage.\n", | ||||
{ | { | ||||
{"mode", RPCArg::Type::STR, /* opt */ true, | {"mode", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"determines what kind of information is returned. This " | "determines what kind of information is returned. This " | ||||
"argument is optional, the default mode is \"stats\".\n" | "argument is optional, the default mode is \"stats\".\n" | ||||
" - \"stats\" returns general statistics about memory " | " - \"stats\" returns general statistics about memory " | ||||
"usage in the daemon.\n" | "usage in the daemon.\n" | ||||
" - \"mallocinfo\" returns an XML string describing " | " - \"mallocinfo\" returns an XML string describing " | ||||
"low-level heap state (only available if compiled with " | "low-level heap state (only available if compiled with " | ||||
"glibc 2.10+)."}, | "glibc 2.10+)."}, | ||||
}} | }, | ||||
.ToString() + | { | ||||
"\nResult (mode \"stats\"):\n" | RPCResult{"mode \"stats\"", | ||||
"{\n" | "{\n" | ||||
" \"locked\": { (json object) Information about " | " \"locked\": { (json object) " | ||||
"Information about " | |||||
"locked memory manager\n" | "locked memory manager\n" | ||||
" \"used\": xxxxx, (numeric) Number of bytes used\n" | " \"used\": xxxxx, (numeric) Number of " | ||||
" \"free\": xxxxx, (numeric) Number of bytes available " | "bytes used\n" | ||||
" \"free\": xxxxx, (numeric) Number of " | |||||
"bytes available " | |||||
"in current arenas\n" | "in current arenas\n" | ||||
" \"total\": xxxxxxx, (numeric) Total number of bytes " | " \"total\": xxxxxxx, (numeric) Total " | ||||
"number of bytes " | |||||
"managed\n" | "managed\n" | ||||
" \"locked\": xxxxxx, (numeric) Amount of bytes that " | " \"locked\": xxxxxx, (numeric) Amount of " | ||||
"succeeded locking. If this number is smaller than total, locking " | "bytes that " | ||||
"pages failed at some point and key data could be swapped to " | "succeeded locking. If this number is smaller than " | ||||
"total, locking " | |||||
"pages failed at some point and key data could be " | |||||
"swapped to " | |||||
"disk.\n" | "disk.\n" | ||||
" \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n" | " \"chunks_used\": xxxxx, (numeric) Number " | ||||
" \"chunks_free\": xxxxx, (numeric) Number unused chunks\n" | "allocated chunks\n" | ||||
" \"chunks_free\": xxxxx, (numeric) Number " | |||||
"unused chunks\n" | |||||
" }\n" | " }\n" | ||||
"}\n" | "}\n"}, | ||||
"\nResult (mode \"mallocinfo\"):\n" | RPCResult{"mode \"mallocinfo\"", | ||||
"\"<malloc version=\"1\">...\"\n" | "\"<malloc version=\"1\">...\"\n"}, | ||||
"\nExamples:\n" + | }, | ||||
HelpExampleCli("getmemoryinfo", "") + | RPCExamples{HelpExampleCli("getmemoryinfo", "") + | ||||
HelpExampleRpc("getmemoryinfo", "")); | HelpExampleRpc("getmemoryinfo", "")}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
std::string mode = | std::string mode = | ||||
request.params[0].isNull() ? "stats" : request.params[0].get_str(); | request.params[0].isNull() ? "stats" : request.params[0].get_str(); | ||||
if (mode == "stats") { | if (mode == "stats") { | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("locked", RPCLockedMemoryInfo()); | obj.pushKV("locked", RPCLockedMemoryInfo()); | ||||
return obj; | return obj; | ||||
Show All 26 Lines | for (size_t i = 0; i < cats.size(); ++i) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"unknown logging category " + cat); | "unknown logging category " + cat); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static UniValue logging(const Config &config, const JSONRPCRequest &request) { | static UniValue logging(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() > 2) { | if (request.fHelp || request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"logging", | "logging", | ||||
"Gets and sets the logging configuration.\n" | "Gets and sets the logging configuration.\n" | ||||
"When called without an argument, returns the list of " | "When called without an argument, returns the list of " | ||||
"categories with status that are currently being debug logged " | "categories with status that are currently being debug logged " | ||||
"or not.\n" | "or not.\n" | ||||
"When called with arguments, adds or removes categories from " | "When called with arguments, adds or removes categories from " | ||||
"debug logging and return the lists above.\n" | "debug logging and return the lists above.\n" | ||||
"The arguments are evaluated in order \"include\", " | "The arguments are evaluated in order \"include\", " | ||||
"\"exclude\".\n" | "\"exclude\".\n" | ||||
"If an item is both included and excluded, it will thus end up " | "If an item is both included and excluded, it will thus end up " | ||||
"being excluded.\n" | "being excluded.\n" | ||||
"The valid logging categories are: " + | "The valid logging categories are: " + | ||||
ListLogCategories() + | ListLogCategories() + | ||||
"\n" | "\n" | ||||
"In addition, the following are available as category " | "In addition, the following are available as category " | ||||
"names with special meanings:\n" | "names with special meanings:\n" | ||||
" - \"all\", \"1\" : represent all logging categories.\n" | " - \"all\", \"1\" : represent all logging categories.\n" | ||||
" - \"none\", \"0\" : even if other logging categories " | " - \"none\", \"0\" : even if other logging categories " | ||||
"are specified, ignore all of them.\n", | "are specified, ignore all of them.\n", | ||||
{ | { | ||||
{"include", | {"include", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"A json array of categories to add debug logging", | "A json array of categories to add debug logging", | ||||
{ | { | ||||
{"include_category", RPCArg::Type::STR, | {"include_category", RPCArg::Type::STR, | ||||
/* opt */ false, /* default_val */ "", | /* opt */ false, /* default_val */ "", | ||||
"the valid logging category"}, | "the valid logging category"}, | ||||
}}, | }}, | ||||
{"exclude", | {"exclude", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"A json array of categories to remove debug logging", | "A json array of categories to remove debug logging", | ||||
{ | { | ||||
{"exclude_category", RPCArg::Type::STR, | {"exclude_category", RPCArg::Type::STR, | ||||
/* opt */ false, /* default_val */ "", | /* opt */ false, /* default_val */ "", | ||||
"the valid logging category"}, | "the valid logging category"}, | ||||
}}, | }}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{"{ (json object where keys are the " | ||||
"\nResult:\n" | "logging categories, and values indicates its status\n" | ||||
"{ (json object where keys are the logging " | " \"category\": 0|1, (numeric) if being debug logged " | ||||
"categories, and values indicates its status\n" | "or not. 0:inactive, 1:active\n" | ||||
" \"category\": 0|1, (numeric) if being debug logged or not. " | |||||
"0:inactive, 1:active\n" | |||||
" ...\n" | " ...\n" | ||||
"}\n" | "}\n"}, | ||||
"\nExamples:\n" + | RPCExamples{HelpExampleCli("logging", | ||||
HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + | "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + | ||||
HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"")); | HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"")}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
uint32_t original_log_categories = LogInstance().GetCategoryMask(); | uint32_t original_log_categories = LogInstance().GetCategoryMask(); | ||||
if (request.params[0].isArray()) { | if (request.params[0].isArray()) { | ||||
EnableOrDisableLogCategories(request.params[0], true); | EnableOrDisableLogCategories(request.params[0], true); | ||||
} | } | ||||
if (request.params[1].isArray()) { | if (request.params[1].isArray()) { | ||||
Show All 29 Lines | for (const auto &logCatActive : vLogCatActive) { | ||||
result.pushKV(logCatActive.category, logCatActive.active); | result.pushKV(logCatActive.category, logCatActive.active); | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue echo(const Config &config, const JSONRPCRequest &request) { | static UniValue echo(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp) { | if (request.fHelp) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"echo|echojson ...", | "echo|echojson ...", | ||||
"\nSimply echo back the input arguments. This command is for " | "\nSimply echo back the input arguments. This command is for " | ||||
"testing.\n" | "testing.\n" | ||||
"\nThe difference between echo and echojson is that echojson " | "\nThe difference between echo and echojson is that echojson " | ||||
"has argument conversion enabled in the client-side table in " | "has argument conversion enabled in the client-side table in " | ||||
"bitcoin-cli and the GUI. There is no server-side difference.", | "bitcoin-cli and the GUI. There is no server-side difference.", | ||||
{}} | {}, | ||||
.ToString() + | RPCResults{}, | ||||
""); | RPCExamples{""}, | ||||
} | |||||
.ToString()); | |||||
} | } | ||||
return request.params; | return request.params; | ||||
} | } | ||||
static UniValue getinfo_deprecated(const Config &config, | static UniValue getinfo_deprecated(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, | throw JSONRPCError(RPC_METHOD_NOT_FOUND, | ||||
Show All 35 Lines |