Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 27 Lines | |||||
#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( | ||||
"validateaddress \"address\"\n" | RPCHelpMan{ | ||||
"\nReturn information about the given bitcoin address.\n" | "validateaddress", | ||||
"\nReturn information about the given bitcoin address.\n", | |||||
{ | |||||
{"address", RPCArg::Type::STR, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"address\" (string, required) The bitcoin " | "1. \"address\" (string, required) The bitcoin " | ||||
"address to validate\n" | "address to validate\n" | ||||
"\nResult:\n" | "\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 " | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | static UniValue createmultisig(const Config &config, | ||||
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( | ||||
"verifymessage \"address\" \"signature\" \"message\"\n" | RPCHelpMan{"verifymessage", | ||||
"\nVerify a signed message\n" | "\nVerify a signed message\n", | ||||
{ | |||||
{"address", RPCArg::Type::STR, false}, | |||||
{"signature", RPCArg::Type::STR, false}, | |||||
{"message", RPCArg::Type::STR, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"address\" (string, required) The bitcoin address to " | "1. \"address\" (string, required) The bitcoin address to " | ||||
"use for the signature.\n" | "use for the signature.\n" | ||||
"2. \"signature\" (string, required) The signature provided " | "2. \"signature\" (string, required) The signature provided " | ||||
"by the signer in base 64 encoding (see signmessage).\n" | "by the signer in base 64 encoding (see signmessage).\n" | ||||
"3. \"message\" (string, required) The message that was " | "3. \"message\" (string, required) The message that was " | ||||
"signed.\n" | "signed.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 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( | ||||
"signmessagewithprivkey \"privkey\" \"message\"\n" | RPCHelpMan{"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, false}, | |||||
{"message", RPCArg::Type::STR, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"privkey\" (string, required) The private key to sign " | "1. \"privkey\" (string, required) The private key to sign " | ||||
"the message with.\n" | "the message with.\n" | ||||
"2. \"message\" (string, required) The message to create a " | "2. \"message\" (string, required) The message to create a " | ||||
"signature of.\n" | "signature of.\n" | ||||
"\nResult:\n" | "\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" | ||||
Show All 29 Lines | static UniValue signmessagewithprivkey(const Config &config, | ||||
return EncodeBase64(vchSig.data(), vchSig.size()); | return EncodeBase64(vchSig.data(), vchSig.size()); | ||||
} | } | ||||
static UniValue setmocktime(const Config &config, | static UniValue setmocktime(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( | ||||
"setmocktime timestamp\n" | RPCHelpMan{ | ||||
"\nSet the local time to given timestamp (-regtest only)\n" | "setmocktime", | ||||
"\nSet the local time to given timestamp (-regtest only)\n", | |||||
{ | |||||
{"timestamp", RPCArg::Type::NUM, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. timestamp (integer, required) Unix seconds-since-epoch " | "1. timestamp (integer, required) Unix seconds-since-epoch " | ||||
"timestamp\n" | "timestamp\n" | ||||
" Pass 0 to go back to using the system time."); | " Pass 0 to go back to using the system time."); | ||||
} | } | ||||
if (!config.GetChainParams().MineBlocksOnDemand()) { | if (!config.GetChainParams().MineBlocksOnDemand()) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
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( | ||||
"getmemoryinfo (\"mode\")\n" | RPCHelpMan{"getmemoryinfo", | ||||
"Returns an object containing information about memory usage.\n" | "Returns an object containing information about memory " | ||||
"usage.\n", | |||||
{ | |||||
{"mode", RPCArg::Type::STR, true}, | |||||
}} | |||||
.ToString() + | |||||
"Arguments:\n" | "Arguments:\n" | ||||
"1. \"mode\" determines what kind of information is returned. This " | "1. \"mode\" 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 usage in " | " - \"stats\" returns general statistics about memory usage in " | ||||
"the daemon.\n" | "the daemon.\n" | ||||
" - \"mallocinfo\" returns an XML string describing low-level " | " - \"mallocinfo\" returns an XML string describing low-level " | ||||
"heap state (only available if compiled with glibc 2.10+).\n" | "heap state (only available if compiled with glibc 2.10+).\n" | ||||
"\nResult (mode \"stats\"):\n" | "\nResult (mode \"stats\"):\n" | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < cats.size(); ++i) { | ||||
"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( | ||||
"logging ( <include> <exclude> )\n" | RPCHelpMan{ | ||||
"logging", | |||||
"Gets and sets the logging configuration.\n" | "Gets and sets the logging configuration.\n" | ||||
"When called without an argument, returns the list of categories " | "When called without an argument, returns the list of " | ||||
"with status that are currently being debug logged or not.\n" | "categories with status that are currently being debug logged " | ||||
"When called with arguments, adds or removes categories from debug " | "or not.\n" | ||||
"logging and return the lists above.\n" | "When called with arguments, adds or removes categories from " | ||||
"The arguments are evaluated in order \"include\", \"exclude\".\n" | "debug logging and return the lists above.\n" | ||||
"The arguments are evaluated in order \"include\", " | |||||
"\"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 names with " | "In addition, the following are available as category " | ||||
"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 are " | " - \"none\", \"0\" : even if other logging categories " | ||||
"specified, ignore all of them.\n" | "are specified, ignore all of them.\n", | ||||
{ | |||||
{"include", RPCArg::Type::STR, true}, | |||||
{"exclude", RPCArg::Type::STR, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"include\" (array of strings, optional) A json array " | "1. \"include\" (array of strings, optional) A json array " | ||||
"of categories to add debug logging\n" | "of categories to add debug logging\n" | ||||
" [\n" | " [\n" | ||||
" \"category\" (string) the valid logging category\n" | " \"category\" (string) the valid logging category\n" | ||||
" ,...\n" | " ,...\n" | ||||
" ]\n" | " ]\n" | ||||
"2. \"exclude\" (array of strings, optional) A json array " | "2. \"exclude\" (array of strings, optional) A json array " | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static UniValue logging(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
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( | ||||
"echo|echojson \"message\" ...\n" | RPCHelpMan{ | ||||
"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 has " | "\nThe difference between echo and echojson is that echojson " | ||||
"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() + | |||||
""); | |||||
} | } | ||||
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 |