Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 31 Lines | |||||
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, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The bitcoin address to validate"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin " | |||||
"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 " | ||||
"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" | ||||
Show All 30 Lines | static UniValue validateaddress(const Config &config, | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue createmultisig(const Config &config, | static UniValue createmultisig(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
std::string msg = | std::string msg = | ||||
"createmultisig nrequired [\"key\",...]\n" | RPCHelpMan{ | ||||
"\nCreates a multi-signature address with n signature of m keys " | "createmultisig", | ||||
"required.\n" | "\nCreates a multi-signature address with n signature of m " | ||||
"It returns a json object with the address and redeemScript.\n" | "keys required.\n" | ||||
"\nArguments:\n" | "It returns a json object with the address and redeemScript.\n", | ||||
"1. nrequired (numeric, required) The number of required " | { | ||||
"signatures out of the n keys.\n" | {"nrequired", RPCArg::Type::NUM, /* opt */ false, | ||||
"2. \"keys\" (string, required) A json array of hex-encoded " | /* default_val */ "", | ||||
"public keys\n" | "The number of required signatures out of the n keys."}, | ||||
" [\n" | {"keys", | ||||
" \"key\" (string) The hex-encoded public key\n" | RPCArg::Type::ARR, | ||||
" ,...\n" | /* opt */ false, | ||||
" ]\n" | /* default_val */ "", | ||||
"A json array of hex-encoded public keys.", | |||||
{ | |||||
{"key", RPCArg::Type::STR_HEX, /* opt */ false, | |||||
/* default_val */ "", "The hex-encoded public key"}, | |||||
}}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"address\":\"multisigaddress\", (string) The 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" | ||||
▲ Show 20 Lines • Show All 48 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( | ||||
RPCHelpMan{"verifymessage", | RPCHelpMan{ | ||||
"verifymessage", | |||||
"\nVerify a signed message\n", | "\nVerify a signed message\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
{"signature", RPCArg::Type::STR, false}, | /* default_val */ "", | ||||
{"message", RPCArg::Type::STR, false}, | "The bitcoin address to use for the signature."}, | ||||
{"signature", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The signature provided by the signer in base 64 encoding " | |||||
"(see signmessage)."}, | |||||
{"message", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", "The message that was signed."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin address to " | |||||
"use for the signature.\n" | |||||
"2. \"signature\" (string, required) The signature provided " | |||||
"by the signer in base 64 encoding (see signmessage).\n" | |||||
"3. \"message\" (string, required) The message that was " | |||||
"signed.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"true|false (boolean) If the signature is verified or not.\n" | "true|false (boolean) If the signature is verified or not.\n" | ||||
"\nExamples:\n" | "\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", | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
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{"signmessagewithprivkey", | 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}, | {"privkey", RPCArg::Type::STR, /* opt */ false, | ||||
{"message", RPCArg::Type::STR, false}, | /* default_val */ "", | ||||
"The private key to sign the message with."}, | |||||
{"message", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The message to create a signature of."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"privkey\" (string, required) The private key to sign " | |||||
"the message with.\n" | |||||
"2. \"message\" (string, required) The message to create a " | |||||
"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" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\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" + | ||||
Show All 23 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(RPCHelpMan{ | ||||
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, false}, | {"timestamp", RPCArg::Type::NUM, /* opt */ false, | ||||
}} | /* default_val */ "", | ||||
.ToString() + | "Unix seconds-since-epoch timestamp\n" | ||||
"\nArguments:\n" | " Pass 0 to go back to using the system time."}, | ||||
"1. timestamp (integer, required) Unix seconds-since-epoch " | }}.ToString()); | ||||
"timestamp\n" | |||||
" 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( | ||||
"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 20 Lines • Show All 41 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( | ||||
RPCHelpMan{"getmemoryinfo", | RPCHelpMan{ | ||||
"getmemoryinfo", | |||||
"Returns an object containing information about memory " | "Returns an object containing information about memory " | ||||
"usage.\n", | "usage.\n", | ||||
{ | { | ||||
{"mode", RPCArg::Type::STR, true}, | {"mode", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | |||||
"determines what kind of information is returned. This " | |||||
"argument is optional, the default mode is \"stats\".\n" | |||||
" - \"stats\" returns general statistics about memory " | |||||
"usage in the daemon.\n" | |||||
" - \"mallocinfo\" returns an XML string describing " | |||||
"low-level heap state (only available if compiled with " | |||||
"glibc 2.10+)."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"Arguments:\n" | |||||
"1. \"mode\" determines what kind of information is returned. This " | |||||
"argument is optional, the default mode is \"stats\".\n" | |||||
" - \"stats\" returns general statistics about memory usage in " | |||||
"the daemon.\n" | |||||
" - \"mallocinfo\" returns an XML string describing low-level " | |||||
"heap state (only available if compiled with glibc 2.10+).\n" | |||||
"\nResult (mode \"stats\"):\n" | "\nResult (mode \"stats\"):\n" | ||||
"{\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 bytes used\n" | ||||
" \"free\": xxxxx, (numeric) Number of bytes available " | " \"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 " | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
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", RPCArg::Type::STR, true}, | {"include", | ||||
{"exclude", RPCArg::Type::STR, true}, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of categories to add debug logging", | |||||
{ | |||||
{"include_category", RPCArg::Type::STR, | |||||
/* opt */ false, /* default_val */ "", | |||||
"the valid logging category"}, | |||||
}}, | |||||
{"exclude", | |||||
RPCArg::Type::ARR, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of categories to remove debug logging", | |||||
{ | |||||
{"exclude_category", RPCArg::Type::STR, | |||||
/* opt */ false, /* default_val */ "", | |||||
"the valid logging category"}, | |||||
}}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"include\" (array of strings, optional) A json array " | |||||
"of categories to add debug logging\n" | |||||
" [\n" | |||||
" \"category\" (string) the valid logging category\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"2. \"exclude\" (array of strings, optional) A json array " | |||||
"of categories to remove debug logging\n" | |||||
" [\n" | |||||
" \"category\" (string) the valid logging category\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object where keys are the logging " | "{ (json object where keys are the logging " | ||||
"categories, and values indicates its status\n" | "categories, and values indicates its status\n" | ||||
" \"category\": 0|1, (numeric) if being debug logged or not. " | " \"category\": 0|1, (numeric) if being debug logged or not. " | ||||
"0:inactive, 1:active\n" | "0:inactive, 1:active\n" | ||||
" ...\n" | " ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |