Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue getblockcount(const Config &config, | static UniValue getblockcount(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockcount\n" | RPCHelpMan{ | ||||
"\nReturns the number of blocks in the longest blockchain.\n" | "getblockcount", | ||||
"\nReturns the number of blocks in the longest blockchain.\n", | |||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"n (numeric) The current block count\n" | "n (numeric) The current block count\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getblockcount", "") + | HelpExampleCli("getblockcount", "") + | ||||
HelpExampleRpc("getblockcount", "")); | HelpExampleRpc("getblockcount", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return ::ChainActive().Height(); | return ::ChainActive().Height(); | ||||
} | } | ||||
static UniValue getbestblockhash(const Config &config, | static UniValue getbestblockhash(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getbestblockhash\n" | RPCHelpMan{"getbestblockhash", | ||||
"\nReturns the hash of the best (tip) block in the " | "\nReturns the hash of the best (tip) block in the " | ||||
"longest blockchain.\n" | "longest blockchain.\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) the block hash hex-encoded\n" | "\"hex\" (string) the block hash hex-encoded\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getbestblockhash", "") + | HelpExampleCli("getbestblockhash", "") + | ||||
HelpExampleRpc("getbestblockhash", "")); | HelpExampleRpc("getbestblockhash", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return ::ChainActive().Tip()->GetBlockHash().GetHex(); | return ::ChainActive().Tip()->GetBlockHash().GetHex(); | ||||
} | } | ||||
UniValue getfinalizedblockhash(const Config &config, | UniValue getfinalizedblockhash(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getfinalizedblockhash\n" | RPCHelpMan{"getfinalizedblockhash", | ||||
"\nReturns the hash of the currently finalized block\n" | "\nReturns the hash of the currently finalized block\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) the block hash hex-encoded\n"); | "\"hex\" (string) the block hash hex-encoded\n"); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *blockIndexFinalized = GetFinalizedBlock(); | const CBlockIndex *blockIndexFinalized = GetFinalizedBlock(); | ||||
if (blockIndexFinalized) { | if (blockIndexFinalized) { | ||||
return blockIndexFinalized->GetBlockHash().GetHex(); | return blockIndexFinalized->GetBlockHash().GetHex(); | ||||
Show All 9 Lines | void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex) { | ||||
} | } | ||||
cond_blockchange.notify_all(); | cond_blockchange.notify_all(); | ||||
} | } | ||||
static UniValue waitfornewblock(const Config &config, | static UniValue waitfornewblock(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( | ||||
"waitfornewblock (timeout)\n" | RPCHelpMan{"waitfornewblock", | ||||
"\nWaits for a specific new block and returns " | "\nWaits for a specific new block and returns useful " | ||||
"useful info about it.\n" | "info about it.\n" | ||||
"\nReturns the current block on timeout or exit.\n" | "\nReturns the current block on timeout or exit.\n", | ||||
{ | |||||
{"timeout", RPCArg::Type::NUM, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. timeout (int, optional, default=0) Time in " | "1. timeout (int, optional, default=0) Time in " | ||||
"milliseconds to wait for a response. 0 indicates " | "milliseconds to wait for a response. 0 indicates " | ||||
"no timeout.\n" | "no timeout.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object)\n" | "{ (json object)\n" | ||||
" \"hash\" : { (string) The blockhash\n" | " \"hash\" : { (string) The blockhash\n" | ||||
" \"height\" : { (int) Block height\n" | " \"height\" : { (int) Block height\n" | ||||
Show All 32 Lines | static UniValue waitfornewblock(const Config &config, | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue waitforblock(const Config &config, | static UniValue waitforblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"waitforblock <blockhash> (timeout)\n" | RPCHelpMan{"waitforblock", | ||||
"\nWaits for a specific new block and returns useful info about " | "\nWaits for a specific new block and returns useful " | ||||
"it.\n" | "info about it.\n" | ||||
"\nReturns the current block on timeout or exit.\n" | "\nReturns the current block on timeout or exit.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
{"timeout", RPCArg::Type::NUM, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (required, string) Block hash to wait for.\n" | "1. \"blockhash\" (required, string) Block hash to wait for.\n" | ||||
"2. timeout (int, optional, default=0) Time in milliseconds " | "2. timeout (int, optional, default=0) Time in milliseconds " | ||||
"to wait for a response. 0 indicates no timeout.\n" | "to wait for a response. 0 indicates no timeout.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object)\n" | "{ (json object)\n" | ||||
" \"hash\" : { (string) The blockhash\n" | " \"hash\" : { (string) The blockhash\n" | ||||
" \"height\" : { (int) Block height\n" | " \"height\" : { (int) Block height\n" | ||||
Show All 37 Lines | static UniValue waitforblock(const Config &config, | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue waitforblockheight(const Config &config, | static UniValue waitforblockheight(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"waitforblockheight height ( timeout )\n" | RPCHelpMan{"waitforblockheight", | ||||
"\nWaits for (at least) block height and returns the height and " | "\nWaits for (at least) block height and returns the " | ||||
"hash\n" | "height and hash\nof the current tip.\n" | ||||
"of the current tip.\n" | "\nReturns the current block on timeout or exit.\n", | ||||
"\nReturns the current block on timeout or exit.\n" | { | ||||
{"height", RPCArg::Type::NUM, false}, | |||||
{"timeout", RPCArg::Type::NUM, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. height (int, required) Block height to wait for (int)\n" | "1. height (int, required) Block height to wait for (int)\n" | ||||
"2. timeout (int, optional, default=0) Time in milliseconds to " | "2. timeout (int, optional, default=0) Time in milliseconds to " | ||||
"wait for a response. 0 indicates no timeout.\n" | "wait for a response. 0 indicates no timeout.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object)\n" | "{ (json object)\n" | ||||
" \"hash\" : { (string) The blockhash\n" | " \"hash\" : { (string) The blockhash\n" | ||||
" \"height\" : { (int) Block height\n" | " \"height\" : { (int) Block height\n" | ||||
Show All 32 Lines | static UniValue waitforblockheight(const Config &config, | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue | static UniValue | ||||
syncwithvalidationinterfacequeue(const Config &config, | syncwithvalidationinterfacequeue(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() > 0) { | if (request.fHelp || request.params.size() > 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"syncwithvalidationinterfacequeue\n" | RPCHelpMan{ | ||||
"syncwithvalidationinterfacequeue", | |||||
"\nWaits for the validation interface queue to catch up on " | "\nWaits for the validation interface queue to catch up on " | ||||
"everything that was there when we entered this function.\n" | "everything that was there when we entered this function.\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("syncwithvalidationinterfacequeue", "") + | HelpExampleCli("syncwithvalidationinterfacequeue", "") + | ||||
HelpExampleRpc("syncwithvalidationinterfacequeue", "")); | HelpExampleRpc("syncwithvalidationinterfacequeue", "")); | ||||
} | } | ||||
SyncWithValidationInterfaceQueue(); | SyncWithValidationInterfaceQueue(); | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue getdifficulty(const Config &config, | static UniValue getdifficulty(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error("getdifficulty\n" | throw std::runtime_error( | ||||
RPCHelpMan{"getdifficulty", | |||||
"\nReturns the proof-of-work difficulty as a " | "\nReturns the proof-of-work difficulty as a " | ||||
"multiple of the minimum difficulty.\n" | "multiple of the minimum difficulty.\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"n.nnn (numeric) the proof-of-work " | "n.nnn (numeric) the proof-of-work " | ||||
"difficulty as a multiple of the minimum " | "difficulty as a multiple of the minimum " | ||||
"difficulty.\n" | "difficulty.\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getdifficulty", "") + | HelpExampleCli("getdifficulty", "") + | ||||
HelpExampleRpc("getdifficulty", "")); | HelpExampleRpc("getdifficulty", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return GetDifficulty(::ChainActive().Tip()); | return GetDifficulty(::ChainActive().Tip()); | ||||
} | } | ||||
static std::string EntryDescriptionString() { | static std::string EntryDescriptionString() { | ||||
return " \"size\" : n, (numeric) transaction size.\n" | return " \"size\" : n, (numeric) transaction size.\n" | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if (verbose) { | ||||
return a; | return a; | ||||
} | } | ||||
} | } | ||||
static UniValue getrawmempool(const Config &config, | static UniValue getrawmempool(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( | ||||
"getrawmempool ( verbose )\n" | RPCHelpMan{"getrawmempool", | ||||
"\nReturns all transaction ids in memory pool as a json array of " | "\nReturns all transaction ids in memory pool as a json " | ||||
"string transaction ids.\n" | "array of string transaction ids.\n", | ||||
{ | |||||
{"verbose", RPCArg::Type::BOOL, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nHint: use getmempoolentry to fetch a specific transaction from " | "\nHint: use getmempoolentry to fetch a specific transaction from " | ||||
"the mempool.\n" | "the mempool.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. verbose (boolean, optional, default=false) True for a json " | "1. verbose (boolean, optional, default=false) True for a json " | ||||
"object, false for array of transaction ids\n" | "object, false for array of transaction ids\n" | ||||
"\nResult: (for verbose = false):\n" | "\nResult: (for verbose = false):\n" | ||||
"[ (json array of string)\n" | "[ (json array of string)\n" | ||||
" \"transactionid\" (string) The transaction id\n" | " \"transactionid\" (string) The transaction id\n" | ||||
Show All 18 Lines | static UniValue getrawmempool(const Config &config, | ||||
return MempoolToJSON(::g_mempool, fVerbose); | return MempoolToJSON(::g_mempool, fVerbose); | ||||
} | } | ||||
static UniValue getmempoolancestors(const Config &config, | static UniValue getmempoolancestors(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempoolancestors txid ( verbose )\n" | RPCHelpMan{"getmempoolancestors", | ||||
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n" | "\nIf txid is in the mempool, returns all in-mempool " | ||||
"ancestors.\n", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, false}, | |||||
{"verbose", RPCArg::Type::BOOL, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) The transaction id " | "1. \"txid\" (string, required) The transaction id " | ||||
"(must be in mempool)\n" | "(must be in mempool)\n" | ||||
"2. verbose (boolean, optional, default=false) " | "2. verbose (boolean, optional, default=false) " | ||||
"True for a json object, false for array of transaction ids\n" | "True for a json object, false for array of transaction ids\n" | ||||
"\nResult (for verbose = false):\n" | "\nResult (for verbose = false):\n" | ||||
"[ (json array of strings)\n" | "[ (json array of strings)\n" | ||||
" \"transactionid\" (string) The transaction id of an " | " \"transactionid\" (string) The transaction id of an " | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static UniValue getmempoolancestors(const Config &config, | ||||
} | } | ||||
} | } | ||||
static UniValue getmempooldescendants(const Config &config, | static UniValue getmempooldescendants(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempooldescendants txid ( verbose )\n" | RPCHelpMan{"getmempooldescendants", | ||||
"\nIf txid is in the mempool, returns all in-mempool descendants.\n" | "\nIf txid is in the mempool, returns all in-mempool " | ||||
"descendants.\n", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, false}, | |||||
{"verbose", RPCArg::Type::BOOL, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) The transaction id " | "1. \"txid\" (string, required) The transaction id " | ||||
"(must be in mempool)\n" | "(must be in mempool)\n" | ||||
"2. verbose (boolean, optional, default=false) " | "2. verbose (boolean, optional, default=false) " | ||||
"True for a json object, false for array of transaction ids\n" | "True for a json object, false for array of transaction ids\n" | ||||
"\nResult (for verbose = false):\n" | "\nResult (for verbose = false):\n" | ||||
"[ (json array of strings)\n" | "[ (json array of strings)\n" | ||||
" \"transactionid\" (string) The transaction id of an " | " \"transactionid\" (string) The transaction id of an " | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (!fVerbose) { | ||||
return o; | return o; | ||||
} | } | ||||
} | } | ||||
static UniValue getmempoolentry(const Config &config, | static UniValue getmempoolentry(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( | ||||
"getmempoolentry txid\n" | RPCHelpMan{"getmempoolentry", | ||||
"\nReturns mempool data for given transaction\n" | "\nReturns mempool data for given transaction\n", | ||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) " | "1. \"txid\" (string, required) " | ||||
"The transaction id (must be in mempool)\n" | "The transaction id (must be in mempool)\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object)\n" + | "{ (json object)\n" + | ||||
EntryDescriptionString() + | EntryDescriptionString() + | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
Show All 16 Lines | static UniValue getmempoolentry(const Config &config, | ||||
entryToJSON(::g_mempool, info, e); | entryToJSON(::g_mempool, info, e); | ||||
return info; | return info; | ||||
} | } | ||||
static UniValue getblockhash(const Config &config, | static UniValue getblockhash(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( | ||||
"getblockhash height\n" | RPCHelpMan{"getblockhash", | ||||
"\nReturns hash of block in best-block-chain at height provided.\n" | "\nReturns hash of block in best-block-chain at height " | ||||
"provided.\n", | |||||
{ | |||||
{"height", RPCArg::Type::NUM, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. height (numeric, required) The height index\n" | "1. height (numeric, required) The height index\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hash\" (string) The block hash\n" | "\"hash\" (string) The block hash\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getblockhash", "1000") + | HelpExampleCli("getblockhash", "1000") + | ||||
HelpExampleRpc("getblockhash", "1000")); | HelpExampleRpc("getblockhash", "1000")); | ||||
} | } | ||||
Show All 9 Lines | static UniValue getblockhash(const Config &config, | ||||
return pblockindex->GetBlockHash().GetHex(); | return pblockindex->GetBlockHash().GetHex(); | ||||
} | } | ||||
static UniValue getblockheader(const Config &config, | static UniValue getblockheader(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockheader \"blockhash\" ( verbose )\n" | RPCHelpMan{"getblockheader", | ||||
"\nIf verbose is false, returns a string that is serialized, " | "\nIf verbose is false, returns a string that is " | ||||
"hex-encoded data for blockheader 'hash'.\n" | "serialized, hex-encoded data for blockheader 'hash'.\n" | ||||
"If verbose is true, returns an Object with information about " | "If verbose is true, returns an Object with information " | ||||
"blockheader <hash>.\n" | "about blockheader <hash>.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
{"verbose", RPCArg::Type::BOOL, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) The block hash\n" | "1. \"blockhash\" (string, required) The block hash\n" | ||||
"2. verbose (boolean, optional, default=true) true for a " | "2. verbose (boolean, optional, default=true) true for a " | ||||
"json object, false for the hex-encoded data\n" | "json object, false for the hex-encoded data\n" | ||||
"\nResult (for verbose = true):\n" | "\nResult (for verbose = true):\n" | ||||
"{\n" | "{\n" | ||||
" \"hash\" : \"hash\", (string) the block hash (same as " | " \"hash\" : \"hash\", (string) the block hash (same as " | ||||
"provided)\n" | "provided)\n" | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | static CBlock GetBlockChecked(const Config &config, | ||||
return block; | return block; | ||||
} | } | ||||
static UniValue getblock(const Config &config, const JSONRPCRequest &request) { | static UniValue getblock(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblock \"blockhash\" ( verbosity )\n" | RPCHelpMan{ | ||||
"getblock", | |||||
"\nIf verbosity is 0 or false, returns a string that is " | "\nIf verbosity is 0 or false, returns a string that is " | ||||
"serialized, hex-encoded data for block 'hash'.\n" | "serialized, hex-encoded data for block 'hash'.\n" | ||||
"If verbosity is 1 or true, returns an Object with information " | "If verbosity is 1 or true, returns an Object with information " | ||||
"about block <hash>.\n" | "about block <hash>.\n" | ||||
"If verbosity is 2, returns an Object with information about block " | "If verbosity is 2, returns an Object with information about " | ||||
"<hash> and information about each transaction.\n" | "block <hash> and information about each transaction.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
{"verbosity", RPCArg::Type::NUM, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) The block hash\n" | "1. \"blockhash\" (string, required) The block hash\n" | ||||
"2. verbosity (numeric, optional, default=1) 0 for " | "2. verbosity (numeric, optional, default=1) 0 for " | ||||
"hex-encoded data, 1 for a json object, and 2 for json object with " | "hex-encoded data, 1 for a json object, and 2 for json object with " | ||||
"transaction data\n" | "transaction data\n" | ||||
"\nResult (for verbosity = 0):\n" | "\nResult (for verbosity = 0):\n" | ||||
"\"data\" (string) A string that is serialized, " | "\"data\" (string) A string that is serialized, " | ||||
"hex-encoded data for block 'hash'.\n" | "hex-encoded data for block 'hash'.\n" | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats) { | ||||
stats.nDiskSize = view->EstimateSize(); | stats.nDiskSize = view->EstimateSize(); | ||||
return true; | return true; | ||||
} | } | ||||
static UniValue pruneblockchain(const Config &config, | static UniValue pruneblockchain(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( | ||||
"pruneblockchain height\n" | RPCHelpMan{"pruneblockchain", | ||||
"", | |||||
{ | |||||
{"height", RPCArg::Type::NUM, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"height\" (numeric, required) The block height to prune " | "1. \"height\" (numeric, required) The block height to prune " | ||||
"up to. May be set to a discrete height, or a unix timestamp\n" | "up to. May be set to a discrete height, or a unix timestamp\n" | ||||
" to prune blocks whose block time is at least 2 " | " to prune blocks whose block time is at least 2 " | ||||
"hours older than the provided timestamp.\n" | "hours older than the provided timestamp.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"n (numeric) Height of the last block pruned.\n" | "n (numeric) Height of the last block pruned.\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | static UniValue pruneblockchain(const Config &config, | ||||
PruneBlockFilesManual(height); | PruneBlockFilesManual(height); | ||||
return uint64_t(height); | return uint64_t(height); | ||||
} | } | ||||
static UniValue gettxoutsetinfo(const Config &config, | static UniValue gettxoutsetinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"gettxoutsetinfo\n" | RPCHelpMan{"gettxoutsetinfo", | ||||
"\nReturns statistics about the unspent transaction output set.\n" | "\nReturns statistics about the unspent transaction " | ||||
"Note this call may take some time.\n" | "output set.\n" | ||||
"Note this call may take some time.\n", | |||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"height\":n, (numeric) The current block height (index)\n" | " \"height\":n, (numeric) The current block height (index)\n" | ||||
" \"bestblock\": \"hex\", (string) the best block hash hex\n" | " \"bestblock\": \"hex\", (string) the best block hash hex\n" | ||||
" \"transactions\": n, (numeric) The number of transactions\n" | " \"transactions\": n, (numeric) The number of transactions\n" | ||||
" \"txouts\": n, (numeric) The number of output " | " \"txouts\": n, (numeric) The number of output " | ||||
"transactions\n" | "transactions\n" | ||||
" \"bogosize\": n, (numeric) A database-independent " | " \"bogosize\": n, (numeric) A database-independent " | ||||
Show All 26 Lines | static UniValue gettxoutsetinfo(const Config &config, | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"gettxout \"txid\" n ( include_mempool )\n" | RPCHelpMan{ | ||||
"\nReturns details about an unspent transaction output.\n" | "gettxout", | ||||
"\nReturns details about an unspent transaction output.\n", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, false}, | |||||
{"n", RPCArg::Type::NUM, false}, | |||||
{"include_mempool", RPCArg::Type::BOOL, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) The transaction id\n" | "1. \"txid\" (string, required) The transaction id\n" | ||||
"2. \"n\" (numeric, required) vout number\n" | "2. \"n\" (numeric, required) vout number\n" | ||||
"3. \"include_mempool\" (boolean, optional) Whether to include " | "3. \"include_mempool\" (boolean, optional) Whether to include " | ||||
"the mempool. Default: true." | "the mempool. Default: true." | ||||
" Note that an unspent output that is spent in the mempool " | " Note that an unspent output that is spent in the mempool " | ||||
"won't appear.\n" | "won't appear.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static UniValue verifychain(const Config &config, | static UniValue verifychain(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL); | int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL); | ||||
int nCheckDepth = gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS); | int nCheckDepth = gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS); | ||||
if (request.fHelp || request.params.size() > 2) { | if (request.fHelp || request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"verifychain ( checklevel nblocks )\n" | RPCHelpMan{"verifychain", | ||||
"\nVerifies blockchain database.\n" | "\nVerifies blockchain database.\n", | ||||
{ | |||||
{"checklevel", RPCArg::Type::NUM, true}, | |||||
{"nblocks", RPCArg::Type::NUM, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. checklevel (numeric, optional, 0-4, default=" + | "1. checklevel (numeric, optional, 0-4, default=" + | ||||
strprintf("%d", nCheckLevel) + | strprintf("%d", nCheckLevel) + | ||||
") How thorough the block verification is.\n" | ") How thorough the block verification is.\n" | ||||
"2. nblocks (numeric, optional, default=" + | "2. nblocks (numeric, optional, default=" + | ||||
strprintf("%d", nCheckDepth) + | strprintf("%d", nCheckDepth) + | ||||
", 0=all) The number of blocks to check.\n" | ", 0=all) The number of blocks to check.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static void BIP9SoftForkDescPushBack(UniValue &softforks, | ||||
softforks.pushKV(VersionBitsDeploymentInfo[id].name, rv); | softforks.pushKV(VersionBitsDeploymentInfo[id].name, rv); | ||||
} | } | ||||
UniValue getblockchaininfo(const Config &config, | UniValue getblockchaininfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockchaininfo\n" | RPCHelpMan{"getblockchaininfo", | ||||
"Returns an object containing various state info regarding " | "Returns an object containing various state info " | ||||
"blockchain processing.\n" | "regarding blockchain processing.\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"chain\": \"xxxx\", (string) current network name " | " \"chain\": \"xxxx\", (string) current network name " | ||||
"as defined in BIP70 (main, test, regtest)\n" | "as defined in BIP70 (main, test, regtest)\n" | ||||
" \"blocks\": xxxxxx, (numeric) the current number of " | " \"blocks\": xxxxxx, (numeric) the current number of " | ||||
"blocks processed in the server\n" | "blocks processed in the server\n" | ||||
" \"headers\": xxxxxx, (numeric) the current number of " | " \"headers\": xxxxxx, (numeric) the current number of " | ||||
"headers we have validated\n" | "headers we have validated\n" | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | bool operator()(const CBlockIndex *a, const CBlockIndex *b) const { | ||||
return a < b; | return a < b; | ||||
} | } | ||||
}; | }; | ||||
static UniValue getchaintips(const Config &config, | static UniValue getchaintips(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getchaintips\n" | RPCHelpMan{ | ||||
"getchaintips", | |||||
"Return information about all known tips in the block tree," | "Return information about all known tips in the block tree, " | ||||
" including the main chain as well as orphaned branches.\n" | "including the main chain as well as orphaned branches.\n", | ||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"height\": xxxx, (numeric) height of the chain tip\n" | " \"height\": xxxx, (numeric) height of the chain tip\n" | ||||
" \"hash\": \"xxxx\", (string) block hash of the tip\n" | " \"hash\": \"xxxx\", (string) block hash of the tip\n" | ||||
" \"branchlen\": 0 (numeric) zero for main chain\n" | " \"branchlen\": 0 (numeric) zero for main chain\n" | ||||
" \"status\": \"active\" (string) \"active\" for the main " | " \"status\": \"active\" (string) \"active\" for the main " | ||||
"chain\n" | "chain\n" | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | UniValue MempoolInfoToJSON(const CTxMemPool &pool) { | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue getmempoolinfo(const Config &config, | static UniValue getmempoolinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempoolinfo\n" | RPCHelpMan{"getmempoolinfo", | ||||
"\nReturns details on the active state of the TX memory pool.\n" | "\nReturns details on the active state of the TX memory " | ||||
"pool.\n", | |||||
{}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"loaded\": true|false (boolean) True if the mempool is " | " \"loaded\": true|false (boolean) True if the mempool is " | ||||
"fully loaded\n" | "fully loaded\n" | ||||
" \"size\": xxxxx, (numeric) Current tx count\n" | " \"size\": xxxxx, (numeric) Current tx count\n" | ||||
" \"bytes\": xxxxx, (numeric) Transaction size.\n" | " \"bytes\": xxxxx, (numeric) Transaction size.\n" | ||||
" \"usage\": xxxxx, (numeric) Total memory usage for " | " \"usage\": xxxxx, (numeric) Total memory usage for " | ||||
"the mempool\n" | "the mempool\n" | ||||
Show All 13 Lines | static UniValue getmempoolinfo(const Config &config, | ||||
return MempoolInfoToJSON(::g_mempool); | return MempoolInfoToJSON(::g_mempool); | ||||
} | } | ||||
static UniValue preciousblock(const Config &config, | static UniValue preciousblock(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( | ||||
"preciousblock \"blockhash\"\n" | RPCHelpMan{"preciousblock", | ||||
"\nTreats a block as if it were received before others with the " | "\nTreats a block as if it were received before others " | ||||
"same work.\n" | "with the same work.\n" | ||||
"\nA later preciousblock call can override the effect of an " | "\nA later preciousblock call can override the effect " | ||||
"earlier one.\n" | "of an earlier one.\n" | ||||
"\nThe effects of preciousblock are not retained across restarts.\n" | "\nThe effects of preciousblock are not retained across " | ||||
"restarts.\n", | |||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the hash of the block to " | "1. \"blockhash\" (string, required) the hash of the block to " | ||||
"mark as precious\n" | "mark as precious\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("preciousblock", "\"blockhash\"") + | HelpExampleCli("preciousblock", "\"blockhash\"") + | ||||
HelpExampleRpc("preciousblock", "\"blockhash\"")); | HelpExampleRpc("preciousblock", "\"blockhash\"")); | ||||
} | } | ||||
Show All 17 Lines | static UniValue preciousblock(const Config &config, | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
UniValue finalizeblock(const Config &config, const JSONRPCRequest &request) { | UniValue finalizeblock(const Config &config, 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( | ||||
"finalizeblock \"blockhash\"\n" | RPCHelpMan{ | ||||
"finalizeblock", | |||||
"\nTreats a block as final. It cannot be reorged. Any chain\n" | "\nTreats a block as final. It cannot be reorged. Any chain\n" | ||||
"that does not contain this block is invalid. Used on a less\n" | "that does not contain this block is invalid. Used on a less\n" | ||||
"work chain, it can effectively PUTS YOU OUT OF CONSENSUS.\n" | "work chain, it can effectively PUTS YOU OUT OF CONSENSUS.\n" | ||||
"USE WITH CAUTION!\n" | "USE WITH CAUTION!\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("finalizeblock", "\"blockhash\"") + | HelpExampleCli("finalizeblock", "\"blockhash\"") + | ||||
HelpExampleRpc("finalizeblock", "\"blockhash\"")); | HelpExampleRpc("finalizeblock", "\"blockhash\"")); | ||||
} | } | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
BlockHash hash(uint256S(strHash)); | BlockHash hash(uint256S(strHash)); | ||||
Show All 19 Lines | UniValue finalizeblock(const Config &config, const JSONRPCRequest &request) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue invalidateblock(const Config &config, | static UniValue invalidateblock(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( | ||||
"invalidateblock \"blockhash\"\n" | RPCHelpMan{"invalidateblock", | ||||
"\nPermanently marks a block as invalid, as if it " | "\nPermanently marks a block as invalid, as if it " | ||||
"violated a consensus rule.\n" | "violated a consensus rule.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the hash of " | "1. \"blockhash\" (string, required) the hash of " | ||||
"the block to mark as invalid\n" | "the block to mark as invalid\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("invalidateblock", "\"blockhash\"") + | HelpExampleCli("invalidateblock", "\"blockhash\"") + | ||||
HelpExampleRpc("invalidateblock", "\"blockhash\"")); | HelpExampleRpc("invalidateblock", "\"blockhash\"")); | ||||
} | } | ||||
Show All 19 Lines | if (!state.IsValid()) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); | throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
UniValue parkblock(const Config &config, const JSONRPCRequest &request) { | UniValue parkblock(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error("parkblock \"blockhash\"\n" | throw std::runtime_error( | ||||
"\nMarks a block as parked.\n" | RPCHelpMan{"parkblock", | ||||
"\nMarks a block as parked.\n", | |||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the " | "1. \"blockhash\" (string, required) the " | ||||
"hash of the block to park\n" | "hash of the block to park\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("parkblock", "\"blockhash\"") + | HelpExampleCli("parkblock", "\"blockhash\"") + | ||||
HelpExampleRpc("parkblock", "\"blockhash\"")); | HelpExampleRpc("parkblock", "\"blockhash\"")); | ||||
} | } | ||||
const std::string strHash = request.params[0].get_str(); | const std::string strHash = request.params[0].get_str(); | ||||
const BlockHash hash(uint256S(strHash)); | const BlockHash hash(uint256S(strHash)); | ||||
CValidationState state; | CValidationState state; | ||||
CBlockIndex *pblockindex; | CBlockIndex *pblockindex; | ||||
{ | { | ||||
Show All 16 Lines | UniValue parkblock(const Config &config, const JSONRPCRequest &request) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue reconsiderblock(const Config &config, | static UniValue reconsiderblock(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( | ||||
"reconsiderblock \"blockhash\"\n" | RPCHelpMan{ | ||||
"reconsiderblock", | |||||
"\nRemoves invalidity status of a block and its descendants, " | "\nRemoves invalidity status of a block and its descendants, " | ||||
"reconsider them for activation.\n" | "reconsider them for activation.\n" | ||||
"This can be used to undo the effects of invalidateblock.\n" | "This can be used to undo the effects of invalidateblock.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the hash of the block to " | "1. \"blockhash\" (string, required) the hash of the block to " | ||||
"reconsider\n" | "reconsider\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("reconsiderblock", "\"blockhash\"") + | HelpExampleCli("reconsiderblock", "\"blockhash\"") + | ||||
HelpExampleRpc("reconsiderblock", "\"blockhash\"")); | HelpExampleRpc("reconsiderblock", "\"blockhash\"")); | ||||
} | } | ||||
Show All 18 Lines | static UniValue reconsiderblock(const Config &config, | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
UniValue unparkblock(const Config &config, const JSONRPCRequest &request) { | UniValue unparkblock(const Config &config, 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( | ||||
"unparkblock \"blockhash\"\n" | RPCHelpMan{"unparkblock", | ||||
"\nRemoves parked status of a block and its descendants, " | "\nRemoves parked status of a block and its " | ||||
"reconsider them for activation.\n" | "descendants, reconsider them for activation.\n" | ||||
"This can be used to undo the effects of parkblock.\n" | "This can be used to undo the effects of parkblock.\n", | ||||
{ | |||||
{"blockhash", RPCArg::Type::STR_HEX, false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the hash of the block to " | "1. \"blockhash\" (string, required) the hash of the block to " | ||||
"unpark\n" | "unpark\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("unparkblock", "\"blockhash\"") + | HelpExampleCli("unparkblock", "\"blockhash\"") + | ||||
HelpExampleRpc("unparkblock", "\"blockhash\"")); | HelpExampleRpc("unparkblock", "\"blockhash\"")); | ||||
} | } | ||||
Show All 20 Lines | UniValue unparkblock(const Config &config, const JSONRPCRequest &request) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue getchaintxstats(const Config &config, | static UniValue getchaintxstats(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( | ||||
"getchaintxstats ( nblocks \"blockhash\" )\n" | RPCHelpMan{"getchaintxstats", | ||||
"\nCompute statistics about the total number and rate of " | "\nCompute statistics about the total number and rate " | ||||
"transactions in the chain.\n" | "of transactions in the chain.\n", | ||||
{ | |||||
{"nblocks", RPCArg::Type::NUM, true}, | |||||
{"blockhash", RPCArg::Type::STR_HEX, true}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. nblocks (numeric, optional) Size of the window in number " | "1. nblocks (numeric, optional) Size of the window in number " | ||||
"of blocks (default: one month).\n" | "of blocks (default: one month).\n" | ||||
"2. \"blockhash\" (string, optional) The hash of the block that " | "2. \"blockhash\" (string, optional) The hash of the block that " | ||||
"ends the window.\n" | "ends the window.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"time\": xxxxx, (numeric) The " | " \"time\": xxxxx, (numeric) The " | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
static constexpr size_t PER_UTXO_OVERHEAD = | static constexpr size_t PER_UTXO_OVERHEAD = | ||||
sizeof(COutPoint) + sizeof(uint32_t) + sizeof(bool); | sizeof(COutPoint) + sizeof(uint32_t) + sizeof(bool); | ||||
static UniValue getblockstats(const Config &config, | static UniValue getblockstats(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 4) { | request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockstats hash_or_height ( stats )\n" | RPCHelpMan{ | ||||
"\nCompute per block statistics for a given window. All amounts " | "getblockstats", | ||||
"are in " + | "\nCompute per block statistics for a given window. All " | ||||
"amounts are in " + | |||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
".\n" | ".\n" | ||||
"It won't work for some heights with pruning.\n" | "It won't work for some heights with pruning.\n" | ||||
"It won't work without -txindex for utxo_size_inc, *fee or " | "It won't work without -txindex for utxo_size_inc, *fee or " | ||||
"*feerate stats.\n" | "*feerate stats.\n", | ||||
{ | |||||
{"hash_or_height", RPCArg::Type::NUM, false}, | |||||
{"stats", | |||||
RPCArg::Type::ARR, | |||||
{ | |||||
{"height", RPCArg::Type::STR, true}, | |||||
{"time", RPCArg::Type::STR, true}, | |||||
}, | |||||
true, | |||||
"stats"}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"hash_or_height\" (string or numeric, required) The block " | "1. \"hash_or_height\" (string or numeric, required) The block " | ||||
"hash or height of the target block\n" | "hash or height of the target block\n" | ||||
"2. \"stats\" (array, optional) Values to plot, by " | "2. \"stats\" (array, optional) Values to plot, by " | ||||
"default all values (see result below)\n" | "default all values (see result below)\n" | ||||
" [\n" | " [\n" | ||||
" \"height\", (string, optional) Selected statistic\n" | " \"height\", (string, optional) Selected statistic\n" | ||||
" \"time\", (string, optional) Selected statistic\n" | " \"time\", (string, optional) Selected statistic\n" | ||||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | for (const std::string &stat : stats) { | ||||
ret.pushKV(stat, value); | ret.pushKV(stat, value); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue savemempool(const Config &config, | static UniValue savemempool(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error("savemempool\n" | throw std::runtime_error( | ||||
"\nDumps the mempool to disk. It will fail " | RPCHelpMan{"savemempool", | ||||
"until the previous dump is fully loaded.\n" | "\nDumps the mempool to disk. It will fail until the " | ||||
"\nExamples:\n" + | "previous dump is fully loaded.\n", | ||||
HelpExampleCli("savemempool", "") + | {}} | ||||
.ToString() + | |||||
"\nExamples:\n" + HelpExampleCli("savemempool", "") + | |||||
HelpExampleRpc("savemempool", "")); | HelpExampleRpc("savemempool", "")); | ||||
} | } | ||||
if (!::g_mempool.IsLoaded()) { | if (!::g_mempool.IsLoaded()) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet"); | throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet"); | ||||
} | } | ||||
if (!DumpMempool(::g_mempool)) { | if (!DumpMempool(::g_mempool)) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk"); | throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk"); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
}; | }; | ||||
static UniValue scantxoutset(const Config &config, | static UniValue scantxoutset(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"scantxoutset \"action\" [scanobjects,...]\n" | RPCHelpMan{"scantxoutset", | ||||
"\nEXPERIMENTAL warning: this call may be removed or changed in " | "\nEXPERIMENTAL warning: this call may be removed or " | ||||
"future releases.\n" | "changed in future releases.\n" | ||||
"\nScans the unspent transaction output set for entries that match " | "\nScans the unspent transaction output set for entries " | ||||
"certain output descriptors.\n" | "that match certain output descriptors.\n" | ||||
"Examples of output descriptors are:\n" | "Examples of output descriptors are:\n" | ||||
" addr(<address>) Outputs whose " | " addr(<address>) Outputs whose " | ||||
"scriptPubKey corresponds to the specified address (does not " | "scriptPubKey corresponds to the specified address " | ||||
"include P2PK)\n" | "(does not include P2PK)\n" | ||||
" raw(<hex script>) Outputs whose " | " raw(<hex script>) Outputs whose " | ||||
"scriptPubKey equals the specified hex scripts\n" | "scriptPubKey equals the specified hex scripts\n" | ||||
" combo(<pubkey>) P2PK and P2PKH outputs " | " combo(<pubkey>) P2PK and " | ||||
"P2PKH outputs for the given pubkey\n" | |||||
" pkh(<pubkey>) P2PKH outputs " | |||||
"for the given pubkey\n" | "for the given pubkey\n" | ||||
" pkh(<pubkey>) P2PKH outputs for the " | " sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig " | ||||
"given pubkey\n" | "outputs for the given threshold and pubkeys\n" | ||||
" sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs " | "\nIn the above, <pubkey> either refers to a fixed " | ||||
"for the given threshold and pubkeys\n" | "public key in hexadecimal notation, or to an xpub/xprv " | ||||
"\nIn the above, <pubkey> either refers to a fixed public key in " | "optionally followed by one\n" | ||||
"hexadecimal notation, or to an xpub/xprv optionally followed by " | "or more path elements separated by \"/\", and " | ||||
"one\n" | "optionally ending in \"/*\" (unhardened), or \"/*'\" " | ||||
"or more path elements separated by \"/\", and optionally ending " | "or \"/*h\" (hardened) to specify all\n" | ||||
"in \"/*\" (unhardened), or \"/*'\" or \"/*h\" (hardened) to " | |||||
"specify all\n" | |||||
"unhardened or hardened child keys.\n" | "unhardened or hardened child keys.\n" | ||||
"In the latter case, a range needs to be specified by below if " | "In the latter case, a range needs to be specified by " | ||||
"different from 1000.\n" | "below if different from 1000.\n" | ||||
"For more information on output descriptors, see the documentation " | "For more information on output descriptors, see the " | ||||
"in the doc/descriptors.md file.\n" | "documentation in the doc/descriptors.md file.\n", | ||||
{ | |||||
{"action", RPCArg::Type::STR, false}, | |||||
{"scanobjects", | |||||
RPCArg::Type::ARR, | |||||
{ | |||||
{"descriptor", | |||||
RPCArg::Type::OBJ, | |||||
{ | |||||
{"desc", RPCArg::Type::STR, false}, | |||||
{"range", RPCArg::Type::NUM, true}, | |||||
}, | |||||
false, | |||||
"scanobjects"}, | |||||
}, | |||||
false}, | |||||
}} | |||||
.ToString() + | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"action\" (string, required) The action " | "1. \"action\" (string, required) The action " | ||||
"to execute\n" | "to execute\n" | ||||
" \"start\" for starting a " | " \"start\" for starting a " | ||||
"scan\n" | "scan\n" | ||||
" \"abort\" for aborting the " | " \"abort\" for aborting the " | ||||
"current scan (returns true when abort was successful)\n" | "current scan (returns true when abort was successful)\n" | ||||
" \"status\" for progress " | " \"status\" for progress " | ||||
▲ Show 20 Lines • Show All 211 Lines • Show Last 20 Lines |