MCPcopy Create free account
hub / github.com/ElementsProject/elements / gettxoutsetinfo

Function gettxoutsetinfo

src/rpc/blockchain.cpp:1304–1445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1302}
1303
1304static RPCHelpMan gettxoutsetinfo()
1305{
1306 return RPCHelpMan{"gettxoutsetinfo",
1307 "\nReturns statistics about the unspent transaction output set.\n"
1308 "Note this call may take some time if you are not using coinstatsindex.\n",
1309 {
1310 {"hash_type", RPCArg::Type::STR, RPCArg::Default{"hash_serialized_2"}, "Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'muhash', 'none'."},
1311 {"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::OMITTED_NAMED_ARG, "The block hash or height of the target height (only available with coinstatsindex).", "", {"", "string or numeric"}},
1312 {"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."},
1313 },
1314 RPCResult{
1315 RPCResult::Type::OBJ, "", "",
1316 {
1317 {RPCResult::Type::NUM, "height", "The block height (index) of the returned statistics"},
1318 {RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at which these statistics are calculated"},
1319 {RPCResult::Type::NUM, "txouts", "The number of unspent transaction outputs"},
1320 {RPCResult::Type::NUM, "bogosize", "Database-independent, meaningless metric indicating the UTXO set size"},
1321 {RPCResult::Type::STR_HEX, "hash_serialized_2", /*optional=*/true, "The serialized hash (only present if 'hash_serialized_2' hash_type is chosen)"},
1322 {RPCResult::Type::STR_HEX, "muhash", /*optional=*/true, "The serialized hash (only present if 'muhash' hash_type is chosen)"},
1323 {RPCResult::Type::NUM, "transactions", /*optional=*/true, "The number of transactions with unspent outputs (not available when coinstatsindex is used)"},
1324 {RPCResult::Type::NUM, "disk_size", /*optional=*/true, "The estimated size of the chainstate on disk (not available when coinstatsindex is used)"},
1325 {RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of coins in the UTXO set"},
1326 {RPCResult::Type::STR_AMOUNT, "total_unspendable_amount", /*optional=*/true, "The total amount of coins permanently excluded from the UTXO set (only available if coinstatsindex is used)"},
1327 {RPCResult::Type::OBJ, "block_info", /*optional=*/true, "Info on amounts in the block at this block height (only available if coinstatsindex is used)",
1328 {
1329 {RPCResult::Type::STR_AMOUNT, "prevout_spent", "Total amount of all prevouts spent in this block"},
1330 {RPCResult::Type::STR_AMOUNT, "coinbase", "Coinbase subsidy amount of this block"},
1331 {RPCResult::Type::STR_AMOUNT, "new_outputs_ex_coinbase", "Total amount of new outputs created by this block"},
1332 {RPCResult::Type::STR_AMOUNT, "unspendable", "Total amount of unspendable outputs created in this block"},
1333 {RPCResult::Type::OBJ, "unspendables", "Detailed view of the unspendable categories",
1334 {
1335 {RPCResult::Type::STR_AMOUNT, "genesis_block", "The unspendable amount of the Genesis block subsidy"},
1336 {RPCResult::Type::STR_AMOUNT, "bip30", "Transactions overridden by duplicates (no longer possible with BIP30)"},
1337 {RPCResult::Type::STR_AMOUNT, "scripts", "Amounts sent to scripts that are unspendable (for example OP_RETURN outputs)"},
1338 {RPCResult::Type::STR_AMOUNT, "unclaimed_rewards", "Fee rewards that miners did not claim in their coinbase transaction"},
1339 }}
1340 }},
1341 }},
1342 RPCExamples{
1343 HelpExampleCli("gettxoutsetinfo", "") +
1344 HelpExampleCli("gettxoutsetinfo", R"("none")") +
1345 HelpExampleCli("gettxoutsetinfo", R"("none" 1000)") +
1346 HelpExampleCli("gettxoutsetinfo", R"("none" '"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"')") +
1347 HelpExampleRpc("gettxoutsetinfo", "") +
1348 HelpExampleRpc("gettxoutsetinfo", R"("none")") +
1349 HelpExampleRpc("gettxoutsetinfo", R"("none", 1000)") +
1350 HelpExampleRpc("gettxoutsetinfo", R"("none", "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09")")
1351 },
1352 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1353{
1354 UniValue ret(UniValue::VOBJ);
1355
1356 CBlockIndex* pindex{nullptr};
1357 const CoinStatsHashType hash_type{request.params[0].isNull() ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType(request.params[0].get_str())};
1358 CCoinsStats stats{hash_type};
1359 stats.index_requested = request.params[2].isNull() || request.params[2].get_bool();
1360
1361 NodeContext& node = EnsureAnyNodeContext(request.context);

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ParseHashTypeFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseHashOrHeightFunction · 0.85
GetUTXOStatsFunction · 0.85
ValueFromAmountFunction · 0.85
get_boolMethod · 0.80
ForceFlushStateToDiskMethod · 0.80
LookupBlockIndexMethod · 0.80
GetSummaryMethod · 0.80
isNullMethod · 0.45

Tested by

no test coverage detected