Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | |||||
static UniValue getblockcount(const Config &config, | static UniValue getblockcount(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockcount", | "getblockcount", | ||||
"\nReturns the height of the most-work fully-validated chain.\n" | "\nReturns the height of the most-work fully-validated chain.\n" | ||||
"The genesis block has height 0.\n", | "The genesis block has height 0.\n", | ||||
{}, | {}, | ||||
RPCResult{"n (numeric) The current block count\n"}, | RPCResult{RPCResult::Type::NUM, "", "The current block count"}, | ||||
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", | ||||
"Returns the hash of the best (tip) block in the " | "Returns the hash of the best (tip) block in the " | ||||
"most-work fully-validated chain.\n", | "most-work fully-validated chain.\n", | ||||
{}, | {}, | ||||
RPCResult{"\"hex\" (string) the block hash, hex-encoded\n"}, | RPCResult{RPCResult::Type::STR_HEX, "", "the block hash, hex-encoded"}, | ||||
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", | ||||
"Returns 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{RPCResult::Type::STR_HEX, "", "the block hash, hex-encoded"}, | ||||
RPCExamples{HelpExampleCli("getfinalizedblockhash", "") + | RPCExamples{HelpExampleCli("getfinalizedblockhash", "") + | ||||
HelpExampleRpc("getfinalizedblockhash", "")}, | HelpExampleRpc("getfinalizedblockhash", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *blockIndexFinalized = | const CBlockIndex *blockIndexFinalized = | ||||
::ChainstateActive().GetFinalizedBlock(); | ::ChainstateActive().GetFinalizedBlock(); | ||||
Show All 18 Lines | RPCHelpMan{ | ||||
"waitfornewblock", | "waitfornewblock", | ||||
"Waits 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{RPCResult::Type::OBJ, | ||||
" \"hash\" : { (string) The blockhash\n" | "", | ||||
" \"height\" : { (int) Block height\n" | "", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR_HEX, "hash", "The blockhash"}, | |||||
{RPCResult::Type::NUM, "height", "Block height"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("waitfornewblock", "1000") + | RPCExamples{HelpExampleCli("waitfornewblock", "1000") + | ||||
HelpExampleRpc("waitfornewblock", "1000")}, | HelpExampleRpc("waitfornewblock", "1000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
int timeout = 0; | int timeout = 0; | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
timeout = request.params[0].get_int(); | timeout = request.params[0].get_int(); | ||||
Show All 33 Lines | RPCHelpMan{ | ||||
"\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."}, | ||||
}, | }, | ||||
RPCResult{"{ (json object)\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"hash\" : { (string) The blockhash\n" | "", | ||||
" \"height\" : { (int) Block height\n" | "", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR_HEX, "hash", "The blockhash"}, | |||||
{RPCResult::Type::NUM, "height", "Block height"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("waitforblock", | RPCExamples{HelpExampleCli("waitforblock", | ||||
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9" | "\"0000000000079f8ef3d2c688c244eb7a4570b24c9" | ||||
"ed7b4a8c619eb02596f8862\", 1000") + | "ed7b4a8c619eb02596f8862\", 1000") + | ||||
HelpExampleRpc("waitforblock", | HelpExampleRpc("waitforblock", | ||||
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9" | "\"0000000000079f8ef3d2c688c244eb7a4570b24c9" | ||||
"ed7b4a8c619eb02596f8862\", 1000")}, | "ed7b4a8c619eb02596f8862\", 1000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
Show All 39 Lines | RPCHelpMan{ | ||||
"\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."}, | ||||
}, | }, | ||||
RPCResult{"{ (json object)\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"hash\" : { (string) The blockhash\n" | "", | ||||
" \"height\" : { (int) Block height\n" | "", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR_HEX, "hash", "The blockhash"}, | |||||
{RPCResult::Type::NUM, "height", "Block height"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("waitforblockheight", "\"100\", 1000") + | RPCExamples{HelpExampleCli("waitforblockheight", "\"100\", 1000") + | ||||
HelpExampleRpc("waitforblockheight", "\"100\", 1000")}, | HelpExampleRpc("waitforblockheight", "\"100\", 1000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
int timeout = 0; | int timeout = 0; | ||||
int height = request.params[0].get_int(); | int height = request.params[0].get_int(); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
static UniValue getdifficulty(const Config &config, | static UniValue getdifficulty(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getdifficulty", | "getdifficulty", | ||||
"Returns 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{RPCResult::Type::NUM, "", | ||||
"multiple of the minimum difficulty.\n"}, | "the proof-of-work difficulty as a multiple of the minimum " | ||||
"difficulty."}, | |||||
RPCExamples{HelpExampleCli("getdifficulty", "") + | RPCExamples{HelpExampleCli("getdifficulty", "") + | ||||
HelpExampleRpc("getdifficulty", "")}, | HelpExampleRpc("getdifficulty", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return GetDifficulty(::ChainActive().Tip()); | return GetDifficulty(::ChainActive().Tip()); | ||||
} | } | ||||
static std::string EntryDescriptionString() { | static std::vector<RPCResult> MempoolEntryDescription() { | ||||
return " \"size\" : n, (numeric) transaction size.\n" | return { | ||||
" \"fee\" : n, (numeric) transaction fee in " + | RPCResult{RPCResult::Type::NUM, "size", "transaction size."}, | ||||
CURRENCY_UNIT + "(DEPRECATED)" + | RPCResult{RPCResult::Type::STR_AMOUNT, "fee", | ||||
"\n" | "transaction fee in " + CURRENCY_UNIT + " (DEPRECATED)"}, | ||||
" \"modifiedfee\" : n, (numeric) transaction fee with fee " | RPCResult{RPCResult::Type::STR_AMOUNT, "modifiedfee", | ||||
"deltas used for mining priority (DEPRECATED)\n" | "transaction fee with fee deltas used for mining priority " | ||||
" \"time\" : n, (numeric) local time transaction " | "(DEPRECATED)"}, | ||||
"entered pool in seconds since 1 Jan 1970 GMT\n" | RPCResult{RPCResult::Type::NUM_TIME, "time", | ||||
" \"height\" : n, (numeric) block height when " | "local time transaction entered pool in seconds since 1 Jan " | ||||
"transaction entered pool\n" | "1970 GMT"}, | ||||
" \"descendantcount\" : n, (numeric) number of in-mempool " | RPCResult{RPCResult::Type::NUM, "height", | ||||
"descendant transactions (including this one)\n" | "block height when transaction entered pool"}, | ||||
" \"descendantsize\" : n, (numeric) transaction size " | RPCResult{RPCResult::Type::NUM, "descendantcount", | ||||
"of in-mempool descendants (including this one)\n" | "number of in-mempool descendant transactions (including " | ||||
" \"descendantfees\" : n, (numeric) modified fees (see above) " | "this one)"}, | ||||
"of in-mempool descendants (including this one) (DEPRECATED)\n" | RPCResult{RPCResult::Type::NUM, "descendantsize", | ||||
" \"ancestorcount\" : n, (numeric) number of in-mempool " | "transaction size of in-mempool descendants " | ||||
"ancestor transactions (including this one)\n" | "(including this one)"}, | ||||
" \"ancestorsize\" : n, (numeric) transaction size " | RPCResult{RPCResult::Type::STR_AMOUNT, "descendantfees", | ||||
"of in-mempool ancestors (including this one)\n" | "modified fees (see above) of in-mempool descendants " | ||||
" \"ancestorfees\" : n, (numeric) modified fees (see above) " | "(including this one) (DEPRECATED)"}, | ||||
"of in-mempool ancestors (including this one) (DEPRECATED)\n" | RPCResult{ | ||||
" \"fees\" : {\n" | RPCResult::Type::NUM, "ancestorcount", | ||||
" \"base\" : n, (numeric) transaction fee in " + | "number of in-mempool ancestor transactions (including this one)"}, | ||||
CURRENCY_UNIT + | RPCResult{ | ||||
"\n" | RPCResult::Type::NUM, "ancestorsize", | ||||
" \"modified\" : n, (numeric) transaction fee with fee " | "transaction size of in-mempool ancestors (including this one)"}, | ||||
"deltas used for mining priority in " + | RPCResult{RPCResult::Type::STR_AMOUNT, "ancestorfees", | ||||
CURRENCY_UNIT + | "modified fees (see above) of in-mempool ancestors " | ||||
"\n" | "(including this one) (DEPRECATED)"}, | ||||
" \"ancestor\" : n, (numeric) modified fees (see above) " | RPCResult{RPCResult::Type::OBJ, | ||||
"of in-mempool ancestors (including this one) in " + | "fees", | ||||
CURRENCY_UNIT + | "", | ||||
"\n" | { | ||||
" \"descendant\" : n, (numeric) modified fees (see above) " | RPCResult{RPCResult::Type::STR_AMOUNT, "base", | ||||
"of in-mempool descendants (including this one) in " + | "transaction fee in " + CURRENCY_UNIT}, | ||||
CURRENCY_UNIT + | RPCResult{RPCResult::Type::STR_AMOUNT, "modified", | ||||
"\n" | "transaction fee with fee deltas used for " | ||||
" }\n" | "mining priority in " + | ||||
" \"depends\" : [ (array) unconfirmed transactions " | CURRENCY_UNIT}, | ||||
"used as inputs for this transaction\n" | RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", | ||||
" \"transactionid\", (string) parent transaction id\n" | "modified fees (see above) of in-mempool " | ||||
" ... ]\n" | "ancestors (including this one) in " + | ||||
" \"spentby\" : [ (array) unconfirmed transactions " | CURRENCY_UNIT}, | ||||
"spending outputs from this transaction\n" | RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", | ||||
" \"transactionid\", (string) child transaction id\n" | "modified fees (see above) of in-mempool " | ||||
" ... ]\n"; | "descendants (including this one) in " + | ||||
CURRENCY_UNIT}, | |||||
}}, | |||||
RPCResult{ | |||||
RPCResult::Type::ARR, | |||||
"depends", | |||||
"unconfirmed transactions used as inputs for this transaction", | |||||
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", | |||||
"parent transaction id"}}}, | |||||
RPCResult{ | |||||
RPCResult::Type::ARR, | |||||
"spentby", | |||||
"unconfirmed transactions spending outputs from this transaction", | |||||
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", | |||||
"child transaction id"}}}, | |||||
}; | |||||
} | } | ||||
static void entryToJSON(const CTxMemPool &pool, UniValue &info, | static void entryToJSON(const CTxMemPool &pool, UniValue &info, | ||||
const CTxMemPoolEntry &e) | const CTxMemPoolEntry &e) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | ||||
AssertLockHeld(pool.cs); | AssertLockHeld(pool.cs); | ||||
UniValue fees(UniValue::VOBJ); | UniValue fees(UniValue::VOBJ); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Returns 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", | ||||
"[ (json array of string)\n" | RPCResult::Type::ARR, | ||||
" \"transactionid\" (string) The transaction id\n" | "", | ||||
" ,...\n" | "", | ||||
"]\n" | { | ||||
"\nResult: (for verbose = true):\n" | {RPCResult::Type::STR_HEX, "", "The transaction id"}, | ||||
"{ (json object)\n" | }}, | ||||
" \"transactionid\" : { (json object)\n" + | RPCResult{"for verbose = true", | ||||
EntryDescriptionString() + | RPCResult::Type::OBJ, | ||||
" }, ...\n" | "", | ||||
"}\n"}, | "", | ||||
{ | |||||
{RPCResult::Type::OBJ_DYN, "transactionid", "", | |||||
MempoolEntryDescription()}, | |||||
}}, | |||||
}, | |||||
RPCExamples{HelpExampleCli("getrawmempool", "true") + | RPCExamples{HelpExampleCli("getrawmempool", "true") + | ||||
HelpExampleRpc("getrawmempool", "true")}, | HelpExampleRpc("getrawmempool", "true")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
fVerbose = request.params[0].get_bool(); | fVerbose = request.params[0].get_bool(); | ||||
Show All 9 Lines | RPCHelpMan{ | ||||
"If 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{ | ||||
"[ (json array of strings)\n" | "for verbose = false", | ||||
" \"transactionid\" (string) The transaction " | RPCResult::Type::ARR, | ||||
"id of an in-mempool ancestor transaction\n" | "", | ||||
" ,...\n" | "", | ||||
"]\n"}, | {{RPCResult::Type::STR_HEX, "", | ||||
RPCResult{"for verbose = true", | "The transaction id of an in-mempool ancestor transaction"}}}, | ||||
"{ (json object)\n" | RPCResult{"for verbose = true", RPCResult::Type::OBJ_DYN, | ||||
" \"transactionid\" : { (json object)\n" + | "transactionid", "", MempoolEntryDescription()}, | ||||
EntryDescriptionString() + | |||||
" }, ...\n" | |||||
"}\n"}, | |||||
}, | }, | ||||
RPCExamples{HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | RPCExamples{HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempoolancestors", "\"mytxid\"")}, | HelpExampleRpc("getmempoolancestors", "\"mytxid\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{ | { | ||||
{"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", | ||||
"[ (json array of strings)\n" | RPCResult::Type::ARR, | ||||
" \"transactionid\" (string) The transaction " | "", | ||||
"id of an in-mempool descendant transaction\n" | "", | ||||
" ,...\n" | {{RPCResult::Type::STR_HEX, "", | ||||
"]\n"}, | "The transaction id of an in-mempool descendant " | ||||
"transaction"}}}, | |||||
RPCResult{"for verbose = true", | RPCResult{"for verbose = true", | ||||
"{ (json object)\n" | RPCResult::Type::OBJ, | ||||
" \"transactionid\" : { (json object)\n" + | "", | ||||
EntryDescriptionString() + | "", | ||||
" }, ...\n" | { | ||||
"}\n"}, | {RPCResult::Type::OBJ_DYN, "transactionid", "", | ||||
MempoolEntryDescription()}, | |||||
}}, | |||||
}, | }, | ||||
RPCExamples{HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | RPCExamples{HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempooldescendants", "\"mytxid\"")}, | HelpExampleRpc("getmempooldescendants", "\"mytxid\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
Show All 40 Lines | static UniValue getmempoolentry(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolentry", | "getmempoolentry", | ||||
"Returns 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{RPCResult::Type::OBJ_DYN, "", "", MempoolEntryDescription()}, | ||||
EntryDescriptionString() + "}\n"}, | |||||
RPCExamples{HelpExampleCli("getmempoolentry", "\"mytxid\"") + | RPCExamples{HelpExampleCli("getmempoolentry", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempoolentry", "\"mytxid\"")}, | HelpExampleRpc("getmempoolentry", "\"mytxid\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
TxId txid(ParseHashV(request.params[0], "parameter 1")); | TxId txid(ParseHashV(request.params[0], "parameter 1")); | ||||
const CTxMemPool &mempool = EnsureMemPool(request.context); | const CTxMemPool &mempool = EnsureMemPool(request.context); | ||||
Show All 15 Lines | static UniValue getblockhash(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockhash", | "getblockhash", | ||||
"Returns 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{RPCResult::Type::STR_HEX, "", "The block hash"}, | ||||
RPCExamples{HelpExampleCli("getblockhash", "1000") + | RPCExamples{HelpExampleCli("getblockhash", "1000") + | ||||
HelpExampleRpc("getblockhash", "1000")}, | HelpExampleRpc("getblockhash", "1000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
int nHeight = request.params[0].get_int(); | int nHeight = request.params[0].get_int(); | ||||
Show All 17 Lines | RPCHelpMan{ | ||||
{"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"}, | ||||
}, | }, | ||||
{ | { | ||||
RPCResult{ | RPCResult{ | ||||
"for verbose = true", | "for verbose = true", | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"hash\" : \"hash\", (string) the block hash (same as " | "", | ||||
"provided)\n" | "", | ||||
" \"confirmations\" : n, (numeric) The number of " | { | ||||
"confirmations, or -1 if the block is not on the main chain\n" | {RPCResult::Type::STR_HEX, "hash", | ||||
" \"height\" : n, (numeric) The block height or " | "the block hash (same as provided)"}, | ||||
"index\n" | {RPCResult::Type::NUM, "confirmations", | ||||
" \"version\" : n, (numeric) The block version\n" | "The number of confirmations, or -1 if the block is not " | ||||
" \"versionHex\" : \"00000000\", (string) The block version " | "on the main chain"}, | ||||
"formatted in hexadecimal\n" | {RPCResult::Type::NUM, "height", | ||||
" \"merkleroot\" : \"xxxx\", (string) The merkle root\n" | "The block height or index"}, | ||||
" \"time\" : ttt, (numeric) The block time expressed " | {RPCResult::Type::NUM, "version", "The block version"}, | ||||
"in " + | {RPCResult::Type::STR_HEX, "versionHex", | ||||
UNIX_EPOCH_TIME + | "The block version formatted in hexadecimal"}, | ||||
"\n" | {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"}, | ||||
" \"mediantime\" : ttt, (numeric) The median block " | {RPCResult::Type::NUM_TIME, "time", | ||||
"time expressed in " + | "The block time expressed in " + UNIX_EPOCH_TIME}, | ||||
UNIX_EPOCH_TIME + | {RPCResult::Type::NUM_TIME, "mediantime", | ||||
"\n" | "The median block time expressed in " + UNIX_EPOCH_TIME}, | ||||
" \"nonce\" : n, (numeric) The nonce\n" | {RPCResult::Type::NUM, "nonce", "The nonce"}, | ||||
" \"bits\" : \"1d00ffff\", (string) The bits\n" | {RPCResult::Type::STR_HEX, "bits", "The bits"}, | ||||
" \"difficulty\" : x.xxx, (numeric) The difficulty\n" | {RPCResult::Type::NUM, "difficulty", "The difficulty"}, | ||||
" \"chainwork\" : \"0000...1f3\" (string) Expected " | {RPCResult::Type::STR_HEX, "chainwork", | ||||
"number of hashes required to produce the current chain " | "Expected number of hashes required to produce the " | ||||
"(in hex)\n" | "current chain"}, | ||||
" \"nTx\" : n, (numeric) The number of " | {RPCResult::Type::NUM, "nTx", | ||||
"transactions in the block.\n" | "The number of transactions in the block"}, | ||||
" \"previousblockhash\" : \"hash\", (string) The hash of " | {RPCResult::Type::STR_HEX, "previousblockhash", | ||||
"the previous block\n" | "The hash of the previous block"}, | ||||
" \"nextblockhash\" : \"hash\", (string) The hash of " | {RPCResult::Type::STR_HEX, "nextblockhash", | ||||
"the next block\n" | "The hash of the next block"}, | ||||
"}\n"}, | }}, | ||||
RPCResult{"for verbose=false", | RPCResult{"for verbose=false", RPCResult::Type::STR_HEX, "", | ||||
"\"data\" (string) A string that is " | "A string that is serialized, hex-encoded data for block " | ||||
"serialized, hex-encoded data for block 'hash'.\n"}, | "'hash'"}, | ||||
}, | }, | ||||
RPCExamples{HelpExampleCli("getblockheader", | RPCExamples{HelpExampleCli("getblockheader", | ||||
"\"00000000c937983704a73af28acdec37b049d214a" | "\"00000000c937983704a73af28acdec37b049d214a" | ||||
"dbda81d7e2a3dd146f6ed09\"") + | "dbda81d7e2a3dd146f6ed09\"") + | ||||
HelpExampleRpc("getblockheader", | HelpExampleRpc("getblockheader", | ||||
"\"00000000c937983704a73af28acdec37b049d214a" | "\"00000000c937983704a73af28acdec37b049d214a" | ||||
"dbda81d7e2a3dd146f6ed09\"")}, | "dbda81d7e2a3dd146f6ed09\"")}, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The block hash"}, | "The block hash"}, | ||||
{"verbosity", RPCArg::Type::NUM, /* default */ "1", | {"verbosity", RPCArg::Type::NUM, /* default */ "1", | ||||
"0 for hex-encoded data, 1 for a json object, and 2 for json " | "0 for hex-encoded data, 1 for a json object, and 2 for json " | ||||
"object with transaction data"}, | "object with transaction data"}, | ||||
}, | }, | ||||
{ | { | ||||
RPCResult{"for verbosity = 0", | RPCResult{"for verbosity = 0", RPCResult::Type::STR_HEX, "", | ||||
"\"data\" (string) A string that is " | "A string that is serialized, hex-encoded data for block " | ||||
"serialized, hex-encoded data for block 'hash'.\n"}, | "'hash'"}, | ||||
RPCResult{ | RPCResult{ | ||||
"for verbosity = 1", | "for verbosity = 1", | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"hash\" : \"hash\", (string) The block hash (same as " | "", | ||||
"provided)\n" | "", | ||||
" \"confirmations\" : n, (numeric) The number of " | { | ||||
"confirmations, or -1 if the block is not on the main chain\n" | {RPCResult::Type::STR_HEX, "hash", | ||||
" \"size\" : n, (numeric) The block size\n" | "the block hash (same as provided)"}, | ||||
" \"height\" : n, (numeric) The block height or " | {RPCResult::Type::NUM, "confirmations", | ||||
"index\n" | "The number of confirmations, or -1 if the block is not " | ||||
" \"version\" : n, (numeric) The block version\n" | "on the main chain"}, | ||||
" \"versionHex\" : \"00000000\", (string) The block version " | {RPCResult::Type::NUM, "size", "The block size"}, | ||||
"formatted in hexadecimal\n" | {RPCResult::Type::NUM, "height", | ||||
" \"merkleroot\" : \"xxxx\", (string) The merkle root\n" | "The block height or index"}, | ||||
" \"tx\" : [ (array of string) The transaction " | {RPCResult::Type::NUM, "version", "The block version"}, | ||||
"ids\n" | {RPCResult::Type::STR_HEX, "versionHex", | ||||
" \"transactionid\" (string) The transaction id\n" | "The block version formatted in hexadecimal"}, | ||||
" ,...\n" | {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"}, | ||||
" ],\n" | {RPCResult::Type::ARR, | ||||
" \"time\" : ttt, (numeric) The block time expressed " | "tx", | ||||
"in " + | "The transaction ids", | ||||
UNIX_EPOCH_TIME + | {{RPCResult::Type::STR_HEX, "", "The transaction id"}}}, | ||||
"\n" | {RPCResult::Type::NUM_TIME, "time", | ||||
" \"mediantime\" : ttt, (numeric) The median block " | "The block time expressed in " + UNIX_EPOCH_TIME}, | ||||
"time expressed in " + | {RPCResult::Type::NUM_TIME, "mediantime", | ||||
UNIX_EPOCH_TIME + | "The median block time expressed in " + UNIX_EPOCH_TIME}, | ||||
"\n" | {RPCResult::Type::NUM, "nonce", "The nonce"}, | ||||
" \"nonce\" : n, (numeric) The nonce\n" | {RPCResult::Type::STR_HEX, "bits", "The bits"}, | ||||
" \"bits\" : \"1d00ffff\", (string) The bits\n" | {RPCResult::Type::NUM, "difficulty", "The difficulty"}, | ||||
" \"difficulty\" : x.xxx, (numeric) The difficulty\n" | {RPCResult::Type::STR_HEX, "chainwork", | ||||
" \"chainwork\" : \"xxxx\", (string) Expected number of " | "Expected number of hashes required to produce the chain " | ||||
"hashes required to produce the chain up to this block (in " | "up to this block (in hex)"}, | ||||
"hex)\n" | {RPCResult::Type::NUM, "nTx", | ||||
" \"nTx\" : n, (numeric) The number of " | "The number of transactions in the block"}, | ||||
"transactions in the block.\n" | {RPCResult::Type::STR_HEX, "previousblockhash", | ||||
" \"previousblockhash\" : \"hash\", (string) The hash of " | "The hash of the previous block"}, | ||||
"the previous block\n" | {RPCResult::Type::STR_HEX, "nextblockhash", | ||||
" \"nextblockhash\" : \"hash\" (string) The hash of " | "The hash of the next block"}, | ||||
"the next block\n" | }}, | ||||
"}\n"}, | |||||
RPCResult{"for verbosity = 2", | RPCResult{"for verbosity = 2", | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" ..., Same output as verbosity = 1\n" | "", | ||||
" \"tx\" : [ (array of Objects) The " | "", | ||||
"transactions in the format of the getrawtransaction " | { | ||||
"RPC; different from verbosity = 1 \"tx\" result\n" | {RPCResult::Type::ELISION, "", | ||||
" ...\n" | "Same output as verbosity = 1"}, | ||||
" ],\n" | {RPCResult::Type::ARR, | ||||
" ... Same output as verbosity = 1\n" | "tx", | ||||
"}\n"}, | "", | ||||
{ | |||||
{RPCResult::Type::OBJ, | |||||
"", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::ELISION, "", | |||||
"The transactions in the format of the " | |||||
"getrawtransaction RPC. Different from " | |||||
"verbosity = 1 \"tx\" result"}, | |||||
}}, | |||||
}}, | |||||
{RPCResult::Type::ELISION, "", | |||||
"Same output as verbosity = 1"}, | |||||
}}, | |||||
}, | }, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d" | HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d" | ||||
"214adbda81d7e2a3dd146f6ed09\"") + | "214adbda81d7e2a3dd146f6ed09\"") + | ||||
HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d" | HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d" | ||||
"214adbda81d7e2a3dd146f6ed09\"")}, | "214adbda81d7e2a3dd146f6ed09\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The block height to prune up to. May be set to a discrete " | "The block height to prune up to. May be set to a discrete " | ||||
"height, or to a " + | "height, or to a " + | ||||
UNIX_EPOCH_TIME + | UNIX_EPOCH_TIME + | ||||
"\n" | "\n" | ||||
" to prune blocks whose block time is at " | " to prune blocks whose block time is at " | ||||
"least 2 hours older than the provided timestamp."}, | "least 2 hours older than the provided timestamp."}, | ||||
}, | }, | ||||
RPCResult{"n (numeric) Height of the last block pruned.\n"}, | RPCResult{RPCResult::Type::NUM, "", "Height of the last block pruned"}, | ||||
RPCExamples{HelpExampleCli("pruneblockchain", "1000") + | RPCExamples{HelpExampleCli("pruneblockchain", "1000") + | ||||
HelpExampleRpc("pruneblockchain", "1000")}, | HelpExampleRpc("pruneblockchain", "1000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
if (!fPruneMode) { | if (!fPruneMode) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_MISC_ERROR, | RPC_MISC_ERROR, | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
static UniValue gettxoutsetinfo(const Config &config, | static UniValue gettxoutsetinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"gettxoutsetinfo", | "gettxoutsetinfo", | ||||
"Returns 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{RPCResult::Type::OBJ, | ||||
"{\n" | "", | ||||
" \"height\":n, (numeric) The current block height (index)\n" | "", | ||||
" \"bestblock\": \"hex\", (string) the best block hash hex\n" | { | ||||
" \"transactions\": n, (numeric) The number of transactions\n" | {RPCResult::Type::NUM, "height", | ||||
" \"txouts\": n, (numeric) The number of output " | "The current block height (index)"}, | ||||
"transactions\n" | {RPCResult::Type::STR_HEX, "bestblock", | ||||
" \"bogosize\": n, (numeric) A database-independent " | "The hash of the block at the tip of the chain"}, | ||||
"metric for UTXO set size\n" | {RPCResult::Type::NUM, "transactions", | ||||
" \"hash_serialized\": \"hash\", (string) The serialized hash\n" | "The number of transactions with unspent outputs"}, | ||||
" \"disk_size\": n, (numeric) The estimated size of the " | {RPCResult::Type::NUM, "txouts", | ||||
"chainstate on disk\n" | "The number of unspent transaction outputs"}, | ||||
" \"total_amount\": x.xxx (numeric) The total amount\n" | {RPCResult::Type::NUM, "bogosize", | ||||
"}\n"}, | "A meaningless metric for UTXO set size"}, | ||||
{RPCResult::Type::STR_HEX, "hash_serialized", | |||||
"The serialized hash"}, | |||||
{RPCResult::Type::NUM, "disk_size", | |||||
"The estimated size of the chainstate on disk"}, | |||||
{RPCResult::Type::STR_AMOUNT, "total_amount", | |||||
"The total amount"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("gettxoutsetinfo", "") + | RPCExamples{HelpExampleCli("gettxoutsetinfo", "") + | ||||
HelpExampleRpc("gettxoutsetinfo", "")}, | HelpExampleRpc("gettxoutsetinfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
CCoinsStats stats; | CCoinsStats stats; | ||||
Show All 24 Lines | RPCHelpMan{ | ||||
{"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."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"bestblock\" : \"hash\", (string) the block hash\n" | "", | ||||
" \"confirmations\" : n, (numeric) The number of " | "", | ||||
"confirmations\n" | { | ||||
" \"value\" : x.xxx, (numeric) The transaction value " | {RPCResult::Type::STR_HEX, "bestblock", | ||||
"in " + | "The hash of the block at the tip of the chain"}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::NUM, "confirmations", | ||||
"\n" | "The number of confirmations"}, | ||||
" \"scriptPubKey\" : { (json object)\n" | {RPCResult::Type::STR_AMOUNT, "value", | ||||
" \"asm\" : \"code\", (string) \n" | "The transaction value in " + CURRENCY_UNIT}, | ||||
" \"hex\" : \"hex\", (string) \n" | {RPCResult::Type::OBJ, | ||||
" \"reqSigs\" : n, (numeric) Number of required " | "scriptPubKey", | ||||
"signatures\n" | "", | ||||
" \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" | { | ||||
" \"addresses\" : [ (array of string) array of " | {RPCResult::Type::STR_HEX, "asm", ""}, | ||||
"bitcoin addresses\n" | {RPCResult::Type::STR_HEX, "hex", ""}, | ||||
" \"address\" (string) bitcoin address\n" | {RPCResult::Type::NUM, "reqSigs", | ||||
" ,...\n" | "Number of required signatures"}, | ||||
" ]\n" | {RPCResult::Type::STR_HEX, "type", | ||||
" },\n" | "The type, eg pubkeyhash"}, | ||||
" \"coinbase\" : true|false (boolean) Coinbase or not\n" | {RPCResult::Type::ARR, | ||||
"}\n"}, | "addresses", | ||||
"array of bitcoin addresses", | |||||
{{RPCResult::Type::STR, "address", "bitcoin address"}}}, | |||||
}}, | |||||
{RPCResult::Type::BOOL, "coinbase", "Coinbase or not"}, | |||||
}}, | |||||
RPCExamples{"\nGet unspent transactions\n" + | RPCExamples{"\nGet unspent transactions\n" + | ||||
HelpExampleCli("listunspent", "") + "\nView the details\n" + | HelpExampleCli("listunspent", "") + "\nView the details\n" + | ||||
HelpExampleCli("gettxout", "\"txid\" 1") + | HelpExampleCli("gettxout", "\"txid\" 1") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("gettxout", "\"txid\", 1")}, | HelpExampleRpc("gettxout", "\"txid\", 1")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{ | { | ||||
{"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."}, | ||||
}, | }, | ||||
RPCResult{"true|false (boolean) Verified or not\n"}, | RPCResult{RPCResult::Type::BOOL, "", "Verified or not"}, | ||||
RPCExamples{HelpExampleCli("verifychain", "") + | RPCExamples{HelpExampleCli("verifychain", "") + | ||||
HelpExampleRpc("verifychain", "")}, | HelpExampleRpc("verifychain", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
UniValue getblockchaininfo(const Config &config, | UniValue getblockchaininfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblockchaininfo", | "getblockchaininfo", | ||||
"Returns an object containing various state info regarding blockchain " | "Returns an object containing various state info regarding blockchain " | ||||
"processing.\n", | "processing.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"chain\": \"xxxx\", (string) current network name " | "", | ||||
"as defined in BIP70 (main, test, regtest)\n" | "", | ||||
" \"blocks\": xxxxxx, the height of the most-work " | { | ||||
"fully-validated chain. The genesis block has height 0\n" | {RPCResult::Type::STR, "chain", | ||||
" \"headers\": xxxxxx, (numeric) the current number of " | "current network name (main, test, regtest)"}, | ||||
"headers we have validated\n" | {RPCResult::Type::NUM, "blocks", | ||||
" \"bestblockhash\": \"...\", (string) the hash of the " | "the height of the most-work fully-validated chain. The " | ||||
"currently best block\n" | "genesis block has height 0"}, | ||||
" \"difficulty\": xxxxxx, (numeric) the current " | {RPCResult::Type::NUM, "headers", | ||||
"difficulty\n" | "the current number of headers we have validated"}, | ||||
" \"mediantime\": xxxxxx, (numeric) median time for the " | {RPCResult::Type::STR, "bestblockhash", | ||||
"current best block\n" | "the hash of the currently best block"}, | ||||
" \"verificationprogress\": xxxx, (numeric) estimate of " | {RPCResult::Type::NUM, "difficulty", "the current difficulty"}, | ||||
"verification progress [0..1]\n" | {RPCResult::Type::NUM, "mediantime", | ||||
" \"initialblockdownload\": xxxx, (bool) (debug information) " | "median time for the current best block"}, | ||||
"estimate of whether this node is in Initial Block Download mode.\n" | {RPCResult::Type::NUM, "verificationprogress", | ||||
" \"chainwork\": \"xxxx\" (string) total amount of work " | "estimate of verification progress [0..1]"}, | ||||
"in active chain, in hexadecimal\n" | {RPCResult::Type::BOOL, "initialblockdownload", | ||||
" \"size_on_disk\": xxxxxx, (numeric) the estimated size of " | "(debug information) estimate of whether this node is in " | ||||
"the block and undo files on disk\n" | "Initial Block Download mode"}, | ||||
" \"pruned\": xx, (boolean) if the blocks are " | {RPCResult::Type::STR_HEX, "chainwork", | ||||
"subject to pruning\n" | "total amount of work in active chain, in hexadecimal"}, | ||||
" \"pruneheight\": xxxxxx, (numeric) lowest-height " | {RPCResult::Type::NUM, "size_on_disk", | ||||
"complete block stored (only present if pruning is enabled)\n" | "the estimated size of the block and undo files on disk"}, | ||||
" \"automatic_pruning\": xx, (boolean) whether automatic " | {RPCResult::Type::BOOL, "pruned", | ||||
"pruning is enabled (only present if pruning is enabled)\n" | "if the blocks are subject to pruning"}, | ||||
" \"prune_target_size\": xxxxxx, (numeric) the target size used " | {RPCResult::Type::NUM, "pruneheight", | ||||
"by pruning (only present if automatic pruning is enabled)\n" | "lowest-height complete block stored (only present if pruning " | ||||
" \"softforks\": { (object) status of softforks in " | "is enabled)"}, | ||||
"progress\n" | {RPCResult::Type::BOOL, "automatic_pruning", | ||||
" \"xxxx\" : { (string) name of the softfork\n" | "whether automatic pruning is enabled (only present if " | ||||
" \"type\" : \"bip9\", (string) currently only set to " | "pruning is enabled)"}, | ||||
"\"bip9\"\n" | {RPCResult::Type::NUM, "prune_target_size", | ||||
" \"bip9\" : { (object) status of bip9 " | "the target size used by pruning (only present if automatic " | ||||
"softforks (only for \"bip9\" type)\n" | "pruning is enabled)"}, | ||||
" \"status\": \"xxxx\", (string) one of \"defined\", " | {RPCResult::Type::OBJ_DYN, | ||||
"\"started\", \"locked_in\", \"active\", \"failed\"\n" | "softforks", | ||||
" \"bit\": xx, (numeric) the bit (0-28) in the " | "status of softforks", | ||||
"block version field used to signal this softfork (only for " | { | ||||
"\"started\" status)\n" | {RPCResult::Type::OBJ, | ||||
" \"start_time\": xx, (numeric) the minimum median " | "xxxx", | ||||
"time past of a block at which the bit gains its meaning\n" | "name of the softfork", | ||||
" \"timeout\": xx, (numeric) the median time past " | { | ||||
"of a block at which the deployment is considered failed if not " | {RPCResult::Type::STR, "type", | ||||
"yet locked in\n" | "one of \"buried\", \"bip9\""}, | ||||
" \"since\": xx, (numeric) height of the first " | {RPCResult::Type::OBJ, | ||||
"block to which the status applies\n" | "bip9", | ||||
" \"statistics\": { (object) numeric statistics " | "status of bip9 softforks (only for \"bip9\" type)", | ||||
"about BIP9 signalling for a softfork (only for \"started\" " | { | ||||
"status)\n" | {RPCResult::Type::STR, "status", | ||||
" \"period\": xx, (numeric) the length in blocks " | "one of \"defined\", \"started\", " | ||||
"of the BIP9 signalling period \n" | "\"locked_in\", \"active\", \"failed\""}, | ||||
" \"threshold\": xx, (numeric) the number of blocks " | {RPCResult::Type::NUM, "bit", | ||||
"with the version bit set required to activate the feature \n" | "the bit (0-28) in the block version field " | ||||
" \"elapsed\": xx, (numeric) the number of blocks " | "used to signal this softfork (only for " | ||||
"elapsed since the beginning of the current period \n" | "\"started\" status)"}, | ||||
" \"count\": xx, (numeric) the number of blocks " | {RPCResult::Type::NUM_TIME, "start_time", | ||||
"with the version bit set in the current period \n" | "the minimum median time past of a block at " | ||||
" \"possible\": xx (boolean) returns false if " | "which the bit gains its meaning"}, | ||||
"there are not enough blocks left in this period to pass " | {RPCResult::Type::NUM_TIME, "timeout", | ||||
"activation threshold\n" | "the median time past of a block at which the " | ||||
" },\n" | "deployment is considered failed if not yet " | ||||
" \"active\": xx, (boolean) true if the rules are " | "locked in"}, | ||||
"enforced for the mempool and the next block\n" | {RPCResult::Type::NUM, "since", | ||||
" }\n" | "height of the first block to which the status " | ||||
" }\n" | "applies"}, | ||||
" }\n" | {RPCResult::Type::OBJ, | ||||
" \"warnings\" : \"...\", (string) any network and " | "statistics", | ||||
"blockchain warnings.\n" | "numeric statistics about BIP9 signalling for " | ||||
"}\n"}, | "a softfork", | ||||
{ | |||||
{RPCResult::Type::NUM, "period", | |||||
"the length in blocks of the BIP9 " | |||||
"signalling period"}, | |||||
{RPCResult::Type::NUM, "threshold", | |||||
"the number of blocks with the version " | |||||
"bit set required to activate the " | |||||
"feature"}, | |||||
{RPCResult::Type::NUM, "elapsed", | |||||
"the number of blocks elapsed since the " | |||||
"beginning of the current period"}, | |||||
{RPCResult::Type::NUM, "count", | |||||
"the number of blocks with the version " | |||||
"bit set in the current period"}, | |||||
{RPCResult::Type::BOOL, "possible", | |||||
"returns false if there are not enough " | |||||
"blocks left in this period to pass " | |||||
"activation threshold"}, | |||||
}}, | |||||
}}, | |||||
{RPCResult::Type::NUM, "height", | |||||
"height of the first block which the rules are or " | |||||
"will be enforced (only for \"buried\" type, or " | |||||
"\"bip9\" type with \"active\" status)"}, | |||||
{RPCResult::Type::BOOL, "active", | |||||
"true if the rules are enforced for the mempool and " | |||||
"the next block"}, | |||||
}}, | |||||
}}, | |||||
{RPCResult::Type::STR, "warnings", | |||||
"any network and blockchain warnings"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getblockchaininfo", "") + | RPCExamples{HelpExampleCli("getblockchaininfo", "") + | ||||
HelpExampleRpc("getblockchaininfo", "")}, | HelpExampleRpc("getblockchaininfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
static UniValue getchaintips(const Config &config, | static UniValue getchaintips(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getchaintips", | "getchaintips", | ||||
"Return information about all known tips in the block tree, including " | "Return information about all known tips in the block tree, including " | ||||
"the main chain as well as orphaned branches.\n", | "the main chain as well as orphaned branches.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"[\n" | RPCResult::Type::ARR, | ||||
" {\n" | "", | ||||
" \"height\": xxxx, (numeric) height of the chain tip\n" | "", | ||||
" \"hash\": \"xxxx\", (string) block hash of the tip\n" | {{RPCResult::Type::OBJ, | ||||
" \"branchlen\": 0 (numeric) zero for main chain\n" | "", | ||||
" \"status\": \"active\" (string) \"active\" for the main " | "", | ||||
"chain\n" | { | ||||
" },\n" | {RPCResult::Type::NUM, "height", "height of the chain tip"}, | ||||
" {\n" | {RPCResult::Type::STR_HEX, "hash", "block hash of the tip"}, | ||||
" \"height\": xxxx,\n" | {RPCResult::Type::NUM, "branchlen", | ||||
" \"hash\": \"xxxx\",\n" | "zero for main chain, otherwise length of branch connecting " | ||||
" \"branchlen\": 1 (numeric) length of branch " | "the tip to the main chain"}, | ||||
"connecting the tip to the main chain\n" | {RPCResult::Type::STR, "status", | ||||
" \"status\": \"xxxx\" (string) status of the chain " | "status of the chain, \"active\" for the main chain\n" | ||||
"(active, valid-fork, valid-headers, headers-only, invalid)\n" | |||||
" }\n" | |||||
"]\n" | |||||
"Possible values for status:\n" | "Possible values for status:\n" | ||||
"1. \"invalid\" This branch contains at least one " | "1. \"invalid\" This branch contains at " | ||||
"invalid block\n" | "least one invalid block\n" | ||||
"2. \"parked\" This branch contains at least one " | "2. \"parked\" This branch contains at " | ||||
"parked block\n" | "least one parked block\n" | ||||
"3. \"headers-only\" Not all blocks for this branch are " | "3. \"headers-only\" Not all blocks for this " | ||||
"available, but the headers are valid\n" | "branch are available, but the headers are valid\n" | ||||
"4. \"valid-headers\" All blocks are available for this " | "4. \"valid-headers\" All blocks are available for " | ||||
"branch, but they were never fully validated\n" | "this branch, but they were never fully validated\n" | ||||
"5. \"valid-fork\" This branch is not part of the " | "5. \"valid-fork\" This branch is not part of " | ||||
"active chain, but is fully validated\n" | "the active chain, but is fully validated\n" | ||||
"6. \"active\" This is the tip of the active main " | "6. \"active\" This is the tip of the " | ||||
"chain, which is certainly valid\n"}, | "active main chain, which is certainly valid"}, | ||||
}}}}, | |||||
RPCExamples{HelpExampleCli("getchaintips", "") + | RPCExamples{HelpExampleCli("getchaintips", "") + | ||||
HelpExampleRpc("getchaintips", "")}, | HelpExampleRpc("getchaintips", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
static UniValue getmempoolinfo(const Config &config, | static UniValue getmempoolinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolinfo", | "getmempoolinfo", | ||||
"Returns 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" | RPCResult::Type::OBJ, | ||||
" \"loaded\": true|false (boolean) True if the mempool is " | "", | ||||
"fully loaded\n" | "", | ||||
" \"size\": xxxxx, (numeric) Current tx count\n" | { | ||||
" \"bytes\": xxxxx, (numeric) Transaction size.\n" | {RPCResult::Type::BOOL, "loaded", | ||||
" \"usage\": xxxxx, (numeric) Total memory usage for " | "True if the mempool is fully loaded"}, | ||||
"the mempool\n" | {RPCResult::Type::NUM, "size", "Current tx count"}, | ||||
" \"maxmempool\": xxxxx, (numeric) Maximum memory usage " | {RPCResult::Type::NUM, "bytes", "Sum of all transaction sizes"}, | ||||
"for the mempool\n" | {RPCResult::Type::NUM, "usage", | ||||
" \"mempoolminfee\": xxxxx (numeric) Minimum fee rate in " + | "Total memory usage for the mempool"}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::NUM, "maxmempool", | ||||
"/kB for tx to be accepted. Is the maximum of minrelaytxfee and " | "Maximum memory usage for the mempool"}, | ||||
"minimum mempool fee\n" | {RPCResult::Type::STR_AMOUNT, "mempoolminfee", | ||||
" \"minrelaytxfee\": xxxxx (numeric) Current minimum relay " | "Minimum fee rate in " + CURRENCY_UNIT + | ||||
"fee for transactions\n" | "/kB for tx to be accepted. Is the maximum of " | ||||
"}\n"}, | "minrelaytxfee and minimum mempool fee"}, | ||||
{RPCResult::Type::STR_AMOUNT, "minrelaytxfee", | |||||
"Current minimum relay fee for transactions"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getmempoolinfo", "") + | RPCExamples{HelpExampleCli("getmempoolinfo", "") + | ||||
HelpExampleRpc("getmempoolinfo", "")}, | HelpExampleRpc("getmempoolinfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
return MempoolInfoToJSON(EnsureMemPool(request.context)); | return MempoolInfoToJSON(EnsureMemPool(request.context)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Compute 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{RPCResult::Type::OBJ, | ||||
"{\n" | "", | ||||
" \"time\": xxxxx, (numeric) The " | "", | ||||
"timestamp for the final block in the window, expressed in " + | { | ||||
UNIX_EPOCH_TIME + | {RPCResult::Type::NUM_TIME, "time", | ||||
".\n" | "The timestamp for the final block in the window, " | ||||
" \"txcount\": xxxxx, (numeric) The total " | "expressed in " + | ||||
"number of transactions in the chain up to that point.\n" | UNIX_EPOCH_TIME}, | ||||
" \"window_final_block_hash\": \"...\", (string) The hash of " | {RPCResult::Type::NUM, "txcount", | ||||
"the final block in the window.\n" | "The total number of transactions in the chain up to " | ||||
" \"window_final_block_height\": xxxxx, (numeric) The height " | "that point"}, | ||||
"of the final block in the window.\n" | {RPCResult::Type::STR_HEX, "window_final_block_hash", | ||||
" \"window_block_count\": xxxxx, (numeric) Size of the " | "The hash of the final block in the window"}, | ||||
"window in number of blocks.\n" | {RPCResult::Type::NUM, "window_final_block_height", | ||||
" \"window_tx_count\": xxxxx, (numeric) The number " | "The height of the final block in the window."}, | ||||
"of transactions in the window. Only returned if " | {RPCResult::Type::NUM, "window_block_count", | ||||
"\"window_block_count\" is > 0.\n" | "Size of the window in number of blocks"}, | ||||
" \"window_interval\": xxxxx, (numeric) The elapsed " | {RPCResult::Type::NUM, "window_tx_count", | ||||
"time in the window in seconds. Only returned if " | "The number of transactions in the window. Only " | ||||
"\"window_block_count\" is > 0.\n" | "returned if \"window_block_count\" is > 0"}, | ||||
" \"txrate\": x.xx, (numeric) The average " | {RPCResult::Type::NUM, "window_interval", | ||||
"rate of transactions per second in the window. Only returned if " | "The elapsed time in the window in seconds. Only " | ||||
"\"window_interval\" is > 0.\n" | "returned if \"window_block_count\" is > 0"}, | ||||
"}\n"}, | {RPCResult::Type::NUM, "txrate", | ||||
"The average rate of transactions per second in the " | |||||
"window. Only returned if \"window_interval\" is > 0"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getchaintxstats", "") + | RPCExamples{HelpExampleCli("getchaintxstats", "") + | ||||
HelpExampleRpc("getchaintxstats", "2016")}, | HelpExampleRpc("getchaintxstats", "2016")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
const CBlockIndex *pindex; | const CBlockIndex *pindex; | ||||
// By default: 1 month | // By default: 1 month | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{"height", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | {"height", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | ||||
"Selected statistic"}, | "Selected statistic"}, | ||||
{"time", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | {"time", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | ||||
"Selected statistic"}, | "Selected statistic"}, | ||||
}, | }, | ||||
"stats"}, | "stats"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{ (json object)\n" | RPCResult::Type::OBJ, | ||||
" \"avgfee\": x.xxx, (numeric) Average fee in the block\n" | "", | ||||
" \"avgfeerate\": x.xxx, (numeric) Average feerate (in " + | "", | ||||
CURRENCY_UNIT + | { | ||||
" per byte)\n" | {RPCResult::Type::NUM, "avgfee", "Average fee in the block"}, | ||||
" \"avgtxsize\": xxxxx, (numeric) Average transaction size\n" | {RPCResult::Type::NUM, "avgfeerate", | ||||
" \"blockhash\": xxxxx, (string) The block hash (to check " | "Average feerate (in satoshis per virtual byte)"}, | ||||
"for potential reorgs)\n" | {RPCResult::Type::NUM, "avgtxsize", "Average transaction size"}, | ||||
" \"height\": xxxxx, (numeric) The height of the block\n" | {RPCResult::Type::STR_HEX, "blockhash", | ||||
" \"ins\": xxxxx, (numeric) The number of inputs " | "The block hash (to check for potential reorgs)"}, | ||||
"(excluding coinbase)\n" | {RPCResult::Type::NUM, "height", "The height of the block"}, | ||||
" \"maxfee\": xxxxx, (numeric) Maximum fee in the block\n" | {RPCResult::Type::NUM, "ins", | ||||
" \"maxfeerate\": xxxxx, (numeric) Maximum feerate (in " + | "The number of inputs (excluding coinbase)"}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::NUM, "maxfee", "Maximum fee in the block"}, | ||||
" per byte)\n" | {RPCResult::Type::NUM, "maxfeerate", | ||||
" \"maxtxsize\": xxxxx, (numeric) Maximum transaction size\n" | "Maximum feerate (in satoshis per virtual byte)"}, | ||||
" \"medianfee\": x.xxx, (numeric) Truncated median fee in " | {RPCResult::Type::NUM, "maxtxsize", "Maximum transaction size"}, | ||||
"the block\n" | {RPCResult::Type::NUM, "medianfee", | ||||
" \"medianfeerate\": x.xxx, (numeric) Truncated median feerate " | "Truncated median fee in the block"}, | ||||
"(in " + | {RPCResult::Type::NUM, "medianfeerate", | ||||
CURRENCY_UNIT + | "Truncated median feerate (in " + CURRENCY_UNIT + | ||||
" per byte)\n" | " per byte)"}, | ||||
" \"mediantime\": xxxxx, (numeric) The block median time " | {RPCResult::Type::NUM, "mediantime", | ||||
"past\n" | "The block median time past"}, | ||||
" \"mediantxsize\": xxxxx, (numeric) Truncated median " | {RPCResult::Type::NUM, "mediantxsize", | ||||
"transaction size\n" | "Truncated median transaction size"}, | ||||
" \"minfee\": x.xxx, (numeric) Minimum fee in the block\n" | {RPCResult::Type::NUM, "minfee", "Minimum fee in the block"}, | ||||
" \"minfeerate\": xx.xx, (numeric) Minimum feerate (in " + | {RPCResult::Type::NUM, "minfeerate", | ||||
CURRENCY_UNIT + | "Minimum feerate (in satoshis per virtual byte)"}, | ||||
" per byte)\n" | {RPCResult::Type::NUM, "mintxsize", "Minimum transaction size"}, | ||||
" \"mintxsize\": xxxxx, (numeric) Minimum transaction size\n" | {RPCResult::Type::NUM, "outs", "The number of outputs"}, | ||||
" \"outs\": xxxxx, (numeric) The number of outputs\n" | {RPCResult::Type::NUM, "subsidy", "The block subsidy"}, | ||||
" \"subsidy\": x.xxx, (numeric) The block subsidy\n" | {RPCResult::Type::NUM, "time", "The block time"}, | ||||
" \"time\": xxxxx, (numeric) The block time\n" | {RPCResult::Type::NUM, "total_out", | ||||
" \"total_out\": x.xxx, (numeric) Total amount in all " | "Total amount in all outputs (excluding coinbase and thus " | ||||
"outputs (excluding coinbase and thus reward [ie subsidy + " | "reward [ie subsidy + totalfee])"}, | ||||
"totalfee])\n" | {RPCResult::Type::NUM, "total_size", | ||||
" \"total_size\": xxxxx, (numeric) Total size of all " | "Total size of all non-coinbase transactions"}, | ||||
"non-coinbase transactions\n" | {RPCResult::Type::NUM, "totalfee", "The fee total"}, | ||||
" \"totalfee\": x.xxx, (numeric) The fee total\n" | {RPCResult::Type::NUM, "txs", | ||||
" \"txs\": xxxxx, (numeric) The number of " | "The number of transactions (excluding coinbase)"}, | ||||
"transactions (excluding coinbase)\n" | {RPCResult::Type::NUM, "utxo_increase", | ||||
" \"utxo_increase\": xxxxx, (numeric) The increase/decrease in " | "The increase/decrease in the number of unspent outputs"}, | ||||
"the number of unspent outputs\n" | {RPCResult::Type::NUM, "utxo_size_inc", | ||||
" \"utxo_size_inc\": xxxxx, (numeric) The increase/decrease in " | "The increase/decrease in size for the utxo index (not " | ||||
"size for the utxo index (not discounting op_return and similar)\n" | "discounting op_return and similar)"}, | ||||
"}\n"}, | }}, | ||||
RPCExamples{HelpExampleCli("getblockstats", | RPCExamples{HelpExampleCli("getblockstats", | ||||
"1000 '[\"minfeerate\",\"avgfeerate\"]'") + | "1000 '[\"minfeerate\",\"avgfeerate\"]'") + | ||||
HelpExampleRpc("getblockstats", | HelpExampleRpc("getblockstats", | ||||
"1000 '[\"minfeerate\",\"avgfeerate\"]'")}, | "1000 '[\"minfeerate\",\"avgfeerate\"]'")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"The range of HD chain indexes to explore (either " | "The range of HD chain indexes to explore (either " | ||||
"end or [begin,end])"}, | "end or [begin,end])"}, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
"[scanobjects,...]"}, | "[scanobjects,...]"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"success\": true|false, (boolean) Whether the scan was " | "", | ||||
"completed\n" | "", | ||||
" \"txouts\": n, (numeric) The number of " | { | ||||
"unspent transaction outputs scanned\n" | {RPCResult::Type::BOOL, "success", | ||||
" \"height\": n, (numeric) The current block " | "Whether the scan was completed"}, | ||||
"height (index)\n" | {RPCResult::Type::NUM, "txouts", | ||||
" \"bestblock\": \"hex\", (string) The hash of the " | "The number of unspent transaction outputs scanned"}, | ||||
"block at the tip of the chain\n" | {RPCResult::Type::NUM, "height", | ||||
" \"unspents\": [\n" | "The current block height (index)"}, | ||||
" {\n" | {RPCResult::Type::STR_HEX, "bestblock", | ||||
" \"txid\": \"hash\", (string) The transaction id\n" | "The hash of the block at the tip of the chain"}, | ||||
" \"vout\": n, (numeric) The vout value\n" | {RPCResult::Type::ARR, | ||||
" \"scriptPubKey\": \"script\", (string) The script key\n" | "unspents", | ||||
" \"desc\": \"descriptor\", (string) A specialized " | "", | ||||
"descriptor for the matched scriptPubKey\n" | { | ||||
" \"amount\": x.xxx, (numeric) The total amount " | {RPCResult::Type::OBJ, | ||||
"in " + | "", | ||||
CURRENCY_UNIT + | "", | ||||
" of the unspent output\n" | { | ||||
" \"height\": n, (numeric) Height of the " | {RPCResult::Type::STR_HEX, "txid", | ||||
"unspent transaction output\n" | "The transaction id"}, | ||||
" }\n" | {RPCResult::Type::NUM, "vout", "The vout value"}, | ||||
" ,...],\n" | {RPCResult::Type::STR_HEX, "scriptPubKey", | ||||
" \"total_amount\": x.xxx, (numeric) The total amount of " | "The script key"}, | ||||
"all found unspent outputs in " + | {RPCResult::Type::STR, "desc", | ||||
CURRENCY_UNIT + | "A specialized descriptor for the matched " | ||||
"\n" | "scriptPubKey"}, | ||||
"]\n"}, | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"The total amount in " + CURRENCY_UNIT + | |||||
" of the unspent output"}, | |||||
{RPCResult::Type::NUM, "height", | |||||
"Height of the unspent transaction output"}, | |||||
}}, | |||||
}}, | |||||
{RPCResult::Type::STR_AMOUNT, "total_amount", | |||||
"The total amount of all found unspent outputs in " + | |||||
CURRENCY_UNIT}, | |||||
}}, | |||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}); | RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
if (request.params[0].get_str() == "status") { | if (request.params[0].get_str() == "status") { | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"getblockfilter", | "getblockfilter", | ||||
"Retrieve 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{RPCResult::Type::OBJ, | ||||
" \"filter\" : (string) the hex-encoded filter data\n" | "", | ||||
" \"header\" : (string) the hex-encoded filter header\n" | "", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR_HEX, "filter", | |||||
"the hex-encoded filter data"}, | |||||
{RPCResult::Type::STR_HEX, "header", | |||||
"the hex-encoded filter header"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getblockfilter", | RPCExamples{HelpExampleCli("getblockfilter", | ||||
"\"00000000c937983704a73af28acdec37b049d214a" | "\"00000000c937983704a73af28acdec37b049d214a" | ||||
"dbda81d7e2a3dd146f6ed09\" \"basic\"")}} | "dbda81d7e2a3dd146f6ed09\" \"basic\"")}} | ||||
.Check(request); | .Check(request); | ||||
const BlockHash block_hash(ParseHashV(request.params[0], "blockhash")); | const BlockHash block_hash(ParseHashV(request.params[0], "blockhash")); | ||||
std::string filtertype_name = "basic"; | std::string filtertype_name = "basic"; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Serialize the UTXO set to a file for loading elsewhere. | * Serialize the UTXO set to a file for loading elsewhere. | ||||
* | * | ||||
* @see SnapshotMetadata | * @see SnapshotMetadata | ||||
*/ | */ | ||||
static UniValue dumptxoutset(const Config &config, | static UniValue dumptxoutset(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{"dumptxoutset", | RPCHelpMan{ | ||||
"dumptxoutset", | |||||
"\nWrite the serialized UTXO set to disk.\n" | "\nWrite the serialized UTXO set to disk.\n" | ||||
"Incidentally flushes the latest coinsdb (leveldb) to disk.\n", | "Incidentally flushes the latest coinsdb (leveldb) to disk.\n", | ||||
{ | { | ||||
{"path", RPCArg::Type::STR, RPCArg::Optional::NO, | {"path", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"path to the output file. If relative, will be prefixed by " | "path to the output file. If relative, will be prefixed by " | ||||
"datadir."}, | "datadir."}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"coins_written\": n, (numeric) the number of " | "", | ||||
"coins written in the snapshot\n" | "", | ||||
" \"base_hash\": \"...\", (string) the hash of the " | { | ||||
"base of the snapshot\n" | {RPCResult::Type::NUM, "coins_written", | ||||
" \"base_height\": n, (string) the height of the " | "the number of coins written in the snapshot"}, | ||||
"base of the snapshot\n" | {RPCResult::Type::STR_HEX, "base_hash", | ||||
" \"path\": \"...\" (string) the absolute " | "the hash of the base of the snapshot"}, | ||||
"path that the snapshot was written to\n" | {RPCResult::Type::NUM, "base_height", | ||||
"]\n"}, | "the height of the base of the snapshot"}, | ||||
{RPCResult::Type::STR, "path", | |||||
"the absolute path that the snapshot was written to"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("dumptxoutset", "utxo.dat")}} | RPCExamples{HelpExampleCli("dumptxoutset", "utxo.dat")}} | ||||
.Check(request); | .Check(request); | ||||
fs::path path = fs::absolute(request.params[0].get_str(), GetDataDir()); | fs::path path = fs::absolute(request.params[0].get_str(), GetDataDir()); | ||||
// Write to a temporary path and then move into `path` on completion | // Write to a temporary path and then move into `path` on completion | ||||
// to avoid confusion due to an interruption. | // to avoid confusion due to an interruption. | ||||
fs::path temppath = | fs::path temppath = | ||||
fs::absolute(request.params[0].get_str() + ".incomplete", GetDataDir()); | fs::absolute(request.params[0].get_str() + ".incomplete", GetDataDir()); | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |