| 1012 | } |
| 1013 | |
| 1014 | static UniValue gettxoutsetinfo(const JSONRPCRequest& request) |
| 1015 | { |
| 1016 | if (request.fHelp || request.params.size() != 0) |
| 1017 | throw std::runtime_error( |
| 1018 | "gettxoutsetinfo\n" |
| 1019 | "\nReturns statistics about the unspent transaction output set.\n" |
| 1020 | "Note this call may take some time.\n" |
| 1021 | "\nResult:\n" |
| 1022 | "{\n" |
| 1023 | " \"height\":n, (numeric) The current block height (index)\n" |
| 1024 | " \"bestblock\": \"hex\", (string) The hash of the block at the tip of the chain\n" |
| 1025 | " \"transactions\": n, (numeric) The number of transactions with unspent outputs\n" |
| 1026 | " \"txouts\": n, (numeric) The number of unspent transaction outputs\n" |
| 1027 | " \"bogosize\": n, (numeric) A meaningless metric for UTXO set size\n" |
| 1028 | " \"hash_serialized_2\": \"hash\", (string) The serialized hash\n" |
| 1029 | " \"disk_size\": n, (numeric) The estimated size of the chainstate on disk\n" |
| 1030 | " \"total_amount\": x.xxx (numeric) The total amount\n" |
| 1031 | "}\n" |
| 1032 | "\nExamples:\n" |
| 1033 | + HelpExampleCli("gettxoutsetinfo", "") |
| 1034 | + HelpExampleRpc("gettxoutsetinfo", "") |
| 1035 | ); |
| 1036 | |
| 1037 | UniValue ret(UniValue::VOBJ); |
| 1038 | |
| 1039 | CCoinsStats stats; |
| 1040 | FlushStateToDisk(); |
| 1041 | if (GetUTXOStats(pcoinsdbview.get(), stats)) { |
| 1042 | ret.pushKV("height", (int64_t)stats.nHeight); |
| 1043 | ret.pushKV("bestblock", stats.hashBlock.GetHex()); |
| 1044 | ret.pushKV("transactions", (int64_t)stats.nTransactions); |
| 1045 | ret.pushKV("txouts", (int64_t)stats.nTransactionOutputs); |
| 1046 | ret.pushKV("bogosize", (int64_t)stats.nBogoSize); |
| 1047 | ret.pushKV("hash_serialized_2", stats.hashSerialized.GetHex()); |
| 1048 | ret.pushKV("disk_size", stats.nDiskSize); |
| 1049 | ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount)); |
| 1050 | } else { |
| 1051 | throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); |
| 1052 | } |
| 1053 | return ret; |
| 1054 | } |
| 1055 | |
| 1056 | UniValue gettxout(const JSONRPCRequest& request) |
| 1057 | { |
nothing calls this directly
no test coverage detected