Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 171 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockcount", | "getblockcount", | ||||
"\nReturns the number of blocks in the longest blockchain.\n", | "Returns the number of blocks in the longest blockchain.\n", | ||||
{}, | {}, | ||||
RPCResult{"n (numeric) The current block count\n"}, | RPCResult{"n (numeric) The current block count\n"}, | ||||
RPCExamples{HelpExampleCli("getblockcount", "") + | RPCExamples{HelpExampleCli("getblockcount", "") + | ||||
HelpExampleRpc("getblockcount", "")}, | HelpExampleRpc("getblockcount", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getbestblockhash", | "getbestblockhash", | ||||
"\nReturns the hash of the best (tip) block in the longest " | "Returns the hash of the best (tip) block in the longest " | ||||
"blockchain.\n", | "blockchain.\n", | ||||
{}, | {}, | ||||
RPCResult{"\"hex\" (string) the block hash, hex-encoded\n"}, | RPCResult{"\"hex\" (string) the block hash, hex-encoded\n"}, | ||||
RPCExamples{HelpExampleCli("getbestblockhash", "") + | RPCExamples{HelpExampleCli("getbestblockhash", "") + | ||||
HelpExampleRpc("getbestblockhash", "")}, | HelpExampleRpc("getbestblockhash", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getfinalizedblockhash", | "getfinalizedblockhash", | ||||
"\nReturns the hash of the currently finalized block\n", | "Returns the hash of the currently finalized block\n", | ||||
{}, | {}, | ||||
RPCResult{"\"hex\" (string) the block hash hex-encoded\n"}, | RPCResult{"\"hex\" (string) the block hash hex-encoded\n"}, | ||||
RPCExamples{HelpExampleCli("getfinalizedblockhash", "") + | RPCExamples{HelpExampleCli("getfinalizedblockhash", "") + | ||||
HelpExampleRpc("getfinalizedblockhash", "")}, | HelpExampleRpc("getfinalizedblockhash", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
Show All 12 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"waitfornewblock", | "waitfornewblock", | ||||
"\nWaits for a specific new block and returns useful info about it.\n" | "Waits for a specific new block and returns useful 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, /* default */ "0", | {"timeout", RPCArg::Type::NUM, /* default */ "0", | ||||
"Time in milliseconds to wait for a response. 0 indicates no " | "Time in milliseconds to wait for a response. 0 indicates no " | ||||
"timeout."}, | "timeout."}, | ||||
}, | }, | ||||
RPCResult{"{ (json object)\n" | RPCResult{"{ (json object)\n" | ||||
" \"hash\" : { (string) The blockhash\n" | " \"hash\" : { (string) The blockhash\n" | ||||
Show All 32 Lines | static UniValue waitfornewblock(const Config &config, | ||||
ret.pushKV("height", block.height); | ret.pushKV("height", block.height); | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue waitforblock(const Config &config, | static UniValue waitforblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"waitforblock", | "waitforblock", | ||||
"\nWaits for a specific new block and returns useful info about it.\n" | "Waits for a specific new block and returns useful 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, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"Block hash to wait for."}, | "Block hash to wait for."}, | ||||
{"timeout", RPCArg::Type::NUM, /* default */ "0", | {"timeout", RPCArg::Type::NUM, /* default */ "0", | ||||
"Time in milliseconds to wait for a response. 0 indicates no " | "Time in milliseconds to wait for a response. 0 indicates no " | ||||
"timeout."}, | "timeout."}, | ||||
}, | }, | ||||
Show All 39 Lines | static UniValue waitforblock(const Config &config, | ||||
ret.pushKV("height", block.height); | ret.pushKV("height", block.height); | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue waitforblockheight(const Config &config, | static UniValue waitforblockheight(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"waitforblockheight", | "waitforblockheight", | ||||
"\nWaits for (at least) block height and returns the height and " | "Waits for (at least) block height and returns the height and " | ||||
"hash\nof the current tip.\n" | "hash\nof 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, RPCArg::Optional::NO, | {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"Block height to wait for."}, | "Block height to wait for."}, | ||||
{"timeout", RPCArg::Type::NUM, /* default */ "0", | {"timeout", RPCArg::Type::NUM, /* default */ "0", | ||||
"Time in milliseconds to wait for a response. 0 indicates no " | "Time in milliseconds to wait for a response. 0 indicates no " | ||||
"timeout."}, | "timeout."}, | ||||
Show All 36 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"syncwithvalidationinterfacequeue", | "syncwithvalidationinterfacequeue", | ||||
"\nWaits for the validation interface queue to catch up on everything " | "Waits for the validation interface queue to catch up on everything " | ||||
"that was there when we entered this function.\n", | "that was there when we entered this function.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("syncwithvalidationinterfacequeue", "") + | RPCExamples{HelpExampleCli("syncwithvalidationinterfacequeue", "") + | ||||
HelpExampleRpc("syncwithvalidationinterfacequeue", "")}, | HelpExampleRpc("syncwithvalidationinterfacequeue", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
SyncWithValidationInterfaceQueue(); | SyncWithValidationInterfaceQueue(); | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue getdifficulty(const Config &config, | static UniValue getdifficulty(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getdifficulty", | "getdifficulty", | ||||
"\nReturns the proof-of-work difficulty as a multiple of the minimum " | "Returns the proof-of-work difficulty as a multiple of the minimum " | ||||
"difficulty.\n", | "difficulty.\n", | ||||
{}, | {}, | ||||
RPCResult{"n.nnn (numeric) the proof-of-work difficulty as a " | RPCResult{"n.nnn (numeric) the proof-of-work difficulty as a " | ||||
"multiple of the minimum difficulty.\n"}, | "multiple of the minimum difficulty.\n"}, | ||||
RPCExamples{HelpExampleCli("getdifficulty", "") + | RPCExamples{HelpExampleCli("getdifficulty", "") + | ||||
HelpExampleRpc("getdifficulty", "")}, | HelpExampleRpc("getdifficulty", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 126 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getrawmempool", | "getrawmempool", | ||||
"\nReturns all transaction ids in memory pool as a json array of " | "Returns all transaction ids in memory pool as a json array of " | ||||
"string transaction ids.\n" | "string transaction ids.\n" | ||||
"\nHint: use getmempoolentry to fetch a specific transaction from the " | "\nHint: use getmempoolentry to fetch a specific transaction from the " | ||||
"mempool.\n", | "mempool.\n", | ||||
{ | { | ||||
{"verbose", RPCArg::Type::BOOL, /* default */ "false", | {"verbose", RPCArg::Type::BOOL, /* default */ "false", | ||||
"True for a json object, false for array of transaction ids"}, | "True for a json object, false for array of transaction ids"}, | ||||
}, | }, | ||||
RPCResult{"for verbose = false", | RPCResult{"for verbose = false", | ||||
Show All 19 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolancestors", | "getmempoolancestors", | ||||
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n", | "If txid is in the mempool, returns all in-mempool ancestors.\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction id (must be in mempool)"}, | "The transaction id (must be in mempool)"}, | ||||
{"verbose", RPCArg::Type::BOOL, /* default */ "false", | {"verbose", RPCArg::Type::BOOL, /* default */ "false", | ||||
"True for a json object, false for array of transaction ids"}, | "True for a json object, false for array of transaction ids"}, | ||||
}, | }, | ||||
{ | { | ||||
RPCResult{"for verbose = false", | RPCResult{"for verbose = false", | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (!fVerbose) { | ||||
return o; | return o; | ||||
} | } | ||||
} | } | ||||
static UniValue getmempooldescendants(const Config &config, | static UniValue getmempooldescendants(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempooldescendants", | "getmempooldescendants", | ||||
"\nIf txid is in the mempool, returns all in-mempool descendants.\n", | "If txid is in the mempool, returns all in-mempool descendants.\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction id (must be in mempool)"}, | "The transaction id (must be in mempool)"}, | ||||
{"verbose", RPCArg::Type::BOOL, /* default */ "false", | {"verbose", RPCArg::Type::BOOL, /* default */ "false", | ||||
"True for a json object, false for array of transaction ids"}, | "True for a json object, false for array of transaction ids"}, | ||||
}, | }, | ||||
{ | { | ||||
RPCResult{"for verbose = false", | RPCResult{"for verbose = false", | ||||
▲ Show 20 Lines • Show All 53 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolentry", | "getmempoolentry", | ||||
"\nReturns mempool data for given transaction\n", | "Returns mempool data for given transaction\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction id (must be in mempool)"}, | "The transaction id (must be in mempool)"}, | ||||
}, | }, | ||||
RPCResult{"{ (json object)\n" + | RPCResult{"{ (json object)\n" + | ||||
EntryDescriptionString() + "}\n"}, | EntryDescriptionString() + "}\n"}, | ||||
RPCExamples{HelpExampleCli("getmempoolentry", "\"mytxid\"") + | RPCExamples{HelpExampleCli("getmempoolentry", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempoolentry", "\"mytxid\"")}, | HelpExampleRpc("getmempoolentry", "\"mytxid\"")}, | ||||
Show All 15 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockhash", | "getblockhash", | ||||
"\nReturns hash of block in best-block-chain at height provided.\n", | "Returns hash of block in best-block-chain at height provided.\n", | ||||
{ | { | ||||
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The height index"}, | "The height index"}, | ||||
}, | }, | ||||
RPCResult{"\"hash\" (string) The block hash\n"}, | RPCResult{"\"hash\" (string) The block hash\n"}, | ||||
RPCExamples{HelpExampleCli("getblockhash", "1000") + | RPCExamples{HelpExampleCli("getblockhash", "1000") + | ||||
HelpExampleRpc("getblockhash", "1000")}, | HelpExampleRpc("getblockhash", "1000")}, | ||||
} | } | ||||
Show All 9 Lines | static UniValue getblockhash(const Config &config, | ||||
CBlockIndex *pblockindex = ::ChainActive()[nHeight]; | CBlockIndex *pblockindex = ::ChainActive()[nHeight]; | ||||
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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockheader", | "getblockheader", | ||||
"\nIf verbose is false, returns a string that is serialized, " | "If verbose is false, returns a string that is serialized, " | ||||
"hex-encoded data for blockheader 'hash'.\n" | "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 about " | ||||
"blockheader <hash>.\n", | "blockheader <hash>.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The block hash"}, | "The block hash"}, | ||||
{"verbose", RPCArg::Type::BOOL, /* default */ "true", | {"verbose", RPCArg::Type::BOOL, /* default */ "true", | ||||
"true for a json object, false for the hex-encoded data"}, | "true for a json object, false for the hex-encoded data"}, | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static CBlockUndo GetUndoChecked(const CBlockIndex *pblockindex) { | ||||
} | } | ||||
return blockUndo; | return blockUndo; | ||||
} | } | ||||
static UniValue getblock(const Config &config, const JSONRPCRequest &request) { | static UniValue getblock(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblock", | "getblock", | ||||
"\nIf verbosity is 0 or false, returns a string that is serialized, " | "If verbosity is 0 or false, returns a string that is serialized, " | ||||
"hex-encoded data for block 'hash'.\n" | "hex-encoded data for block 'hash'.\n" | ||||
"If verbosity is 1 or true, returns an Object with information about " | "If verbosity is 1 or true, returns an Object with information about " | ||||
"block <hash>.\n" | "block <hash>.\n" | ||||
"If verbosity is 2, returns an Object with information about block " | "If verbosity is 2, returns an Object with information about block " | ||||
"<hash> and information about each transaction.\n", | "<hash> and information about each transaction.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The block hash"}, | "The block hash"}, | ||||
▲ Show 20 Lines • Show All 162 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"gettxoutsetinfo", | "gettxoutsetinfo", | ||||
"\nReturns statistics about the unspent transaction output set.\n" | "Returns statistics about the unspent transaction output set.\n" | ||||
"Note this call may take some time.\n", | "Note this call may take some time.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\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 " | ||||
Show All 27 Lines | if (GetUTXOStats(pcoinsdbview.get(), stats)) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"gettxout", | "gettxout", | ||||
"\nReturns details about an unspent transaction output.\n", | "Returns details about an unspent transaction output.\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction id"}, | "The transaction id"}, | ||||
{"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"}, | {"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"}, | ||||
{"include_mempool", RPCArg::Type::BOOL, /* default */ "true", | {"include_mempool", RPCArg::Type::BOOL, /* default */ "true", | ||||
"Whether to include the mempool. Note that an unspent output that " | "Whether to include the mempool. Note that an unspent output that " | ||||
"is spent in the mempool won't appear."}, | "is spent in the mempool won't appear."}, | ||||
}, | }, | ||||
▲ 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); | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"verifychain", | "verifychain", | ||||
"\nVerifies blockchain database.\n", | "Verifies blockchain database.\n", | ||||
{ | { | ||||
{"checklevel", RPCArg::Type::NUM, | {"checklevel", RPCArg::Type::NUM, | ||||
/* default */ strprintf("%d, range=0-4", nCheckLevel), | /* default */ strprintf("%d, range=0-4", nCheckLevel), | ||||
"How thorough the block verification is."}, | "How thorough the block verification is."}, | ||||
{"nblocks", RPCArg::Type::NUM, | {"nblocks", RPCArg::Type::NUM, | ||||
/* default */ strprintf("%d, 0=all", nCheckDepth), | /* default */ strprintf("%d, 0=all", nCheckDepth), | ||||
"The number of blocks to check."}, | "The number of blocks to check."}, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 362 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolinfo", | "getmempoolinfo", | ||||
"\nReturns details on the active state of the TX memory pool.\n", | "Returns details on the active state of the TX memory pool.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\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 " | ||||
Show All 14 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"preciousblock", | "preciousblock", | ||||
"\nTreats a block as if it were received before others with the same " | "Treats a block as if it were received before others with the same " | ||||
"work.\n" | "work.\n" | ||||
"\nA later preciousblock call can override the effect of an earlier " | "\nA later preciousblock call can override the effect of an earlier " | ||||
"one.\n" | "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, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to mark as precious"}, | "the hash of the block to mark as precious"}, | ||||
}, | }, | ||||
Show All 22 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"finalizeblock", | "finalizeblock", | ||||
"\nTreats a block as final. It cannot be reorged. Any chain\n" | "Treats 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 PUT YOU OUT OF CONSENSUS.\n" | "work chain, it can effectively PUT YOU OUT OF CONSENSUS.\n" | ||||
"USE WITH CAUTION!\n", | "USE WITH CAUTION!\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to mark as invalid"}, | "the hash of the block to mark as invalid"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
Show All 27 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"invalidateblock", | "invalidateblock", | ||||
"\nPermanently marks a block as invalid, as if it violated a consensus " | "Permanently marks a block as invalid, as if it violated a consensus " | ||||
"rule.\n", | "rule.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to mark as invalid"}, | "the hash of the block to mark as invalid"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | ||||
HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | ||||
Show All 22 Lines | static UniValue invalidateblock(const Config &config, | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
UniValue parkblock(const Config &config, const JSONRPCRequest &request) { | UniValue parkblock(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"parkblock", | "parkblock", | ||||
"\nMarks a block as parked.\n", | "Marks a block as parked.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to park"}, | "the hash of the block to park"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("parkblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("parkblock", "\"blockhash\"") + | ||||
HelpExampleRpc("parkblock", "\"blockhash\"")}, | HelpExampleRpc("parkblock", "\"blockhash\"")}, | ||||
} | } | ||||
Show All 23 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"reconsiderblock", | "reconsiderblock", | ||||
"\nRemoves invalidity status of a block and its descendants, " | "Removes 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, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to reconsider"}, | "the hash of the block to reconsider"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("reconsiderblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("reconsiderblock", "\"blockhash\"") + | ||||
Show All 21 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"unparkblock", | "unparkblock", | ||||
"\nRemoves parked status of a block and its descendants, reconsider " | "Removes parked status of a block and its descendants, reconsider " | ||||
"them for activation.\n" | "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, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hash of the block to unpark"}, | "the hash of the block to unpark"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("unparkblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("unparkblock", "\"blockhash\"") + | ||||
Show All 24 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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getchaintxstats", | "getchaintxstats", | ||||
"\nCompute statistics about the total number and rate of transactions " | "Compute statistics about the total number and rate of transactions " | ||||
"in the chain.\n", | "in the chain.\n", | ||||
{ | { | ||||
{"nblocks", RPCArg::Type::NUM, /* default */ "one month", | {"nblocks", RPCArg::Type::NUM, /* default */ "one month", | ||||
"Size of the window in number of blocks"}, | "Size of the window in number of blocks"}, | ||||
{"blockhash", RPCArg::Type::STR_HEX, /* default */ "chain tip", | {"blockhash", RPCArg::Type::STR_HEX, /* default */ "chain tip", | ||||
"The hash of the block that ends the window."}, | "The hash of the block that ends the window."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
// outpoint (needed for the utxo index) + nHeight + fCoinBase | // outpoint (needed for the utxo index) + nHeight + fCoinBase | ||||
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) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockstats", | "getblockstats", | ||||
"\nCompute per block statistics for a given window. All amounts are " | "Compute per block statistics for a given window. All amounts are " | ||||
"in " + | "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", | ||||
{ | { | ||||
{"hash_or_height", | {"hash_or_height", | ||||
RPCArg::Type::NUM, | RPCArg::Type::NUM, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | static UniValue getblockstats(const Config &config, | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue savemempool(const Config &config, | static UniValue savemempool(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"savemempool", | "savemempool", | ||||
"\nDumps the mempool to disk. It will fail until the previous dump is " | "Dumps the mempool to disk. It will fail until the previous dump is " | ||||
"fully loaded.\n", | "fully loaded.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("savemempool", "") + | RPCExamples{HelpExampleCli("savemempool", "") + | ||||
HelpExampleRpc("savemempool", "")}, | HelpExampleRpc("savemempool", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | ~CoinsViewScanReserver() { | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
static UniValue scantxoutset(const Config &config, | static UniValue scantxoutset(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"scantxoutset", | "scantxoutset", | ||||
"\nEXPERIMENTAL warning: this call may be removed or changed in future " | "EXPERIMENTAL warning: this call may be removed or changed in future " | ||||
"releases.\n" | "releases.\n" | ||||
"\nScans the unspent transaction output set for entries that match " | "\nScans the unspent transaction output set for entries that match " | ||||
"certain output descriptors.\n" | "certain output descriptors.\n" | ||||
"Examples of output descriptors are:\n" | "Examples of output descriptors are:\n" | ||||
" addr(<address>) Outputs whose scriptPubKey " | " addr(<address>) Outputs whose scriptPubKey " | ||||
"corresponds to the specified address (does not include P2PK)\n" | "corresponds to the specified address (does not include P2PK)\n" | ||||
" raw(<hex script>) Outputs whose scriptPubKey " | " raw(<hex script>) Outputs whose scriptPubKey " | ||||
"equals the specified hex scripts\n" | "equals the specified hex scripts\n" | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | static UniValue scantxoutset(const Config &config, | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue getblockfilter(const Config &config, | static UniValue getblockfilter(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockfilter", | "getblockfilter", | ||||
"\nRetrieve a BIP 157 content filter for a particular block.\n", | "Retrieve a BIP 157 content filter for a particular block.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The hash of the block"}, | "The hash of the block"}, | ||||
{"filtertype", RPCArg::Type::STR, /*default*/ "basic", | {"filtertype", RPCArg::Type::STR, /*default*/ "basic", | ||||
"The type name of the filter"}, | "The type name of the filter"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{"{\n" | ||||
" \"filter\" : (string) the hex-encoded filter data\n" | " \"filter\" : (string) the hex-encoded filter data\n" | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |