aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2021-02-28 19:27:00 +0100
committerFabian Jahr <fjahr@protonmail.com>2021-04-19 21:11:33 +0200
commitb9362392aef2689bc106c20925859ede555d082b (patch)
treeb8437b8db02cfe99a5d0626bdf16b6699b477eaf /src/rpc
parentbb7788b121a30489bc81a1f46dde6a9b19ae4ec1 (diff)
downloadbitcoin-b9362392aef2689bc106c20925859ede555d082b.tar.xz
index, rpc: Add use_index option for gettxoutsetinfo
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/rpc/client.cpp1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 1067a7c4bb..4a4c432a01 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1102,6 +1102,7 @@ static RPCHelpMan gettxoutsetinfo()
{
{"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'."},
{"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The block hash or height of the target height (only available with coinstatsindex)", "", {"", "string or numeric"}},
+ {"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
@@ -1148,6 +1149,7 @@ static RPCHelpMan gettxoutsetinfo()
CBlockIndex* pindex{nullptr};
const CoinStatsHashType hash_type{request.params[0].isNull() ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType(request.params[0].get_str())};
CCoinsStats stats{hash_type};
+ stats.index_requested = request.params[2].isNull() || request.params[2].get_bool();
NodeContext& node = EnsureAnyNodeContext(request.context);
ChainstateManager& chainman = EnsureChainman(node);
@@ -1183,7 +1185,7 @@ static RPCHelpMan gettxoutsetinfo()
ret.pushKV("muhash", stats.hashSerialized.GetHex());
}
ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount));
- if (!stats.from_index) {
+ if (!stats.index_used) {
ret.pushKV("transactions", static_cast<int64_t>(stats.nTransactions));
ret.pushKV("disk_size", stats.nDiskSize);
} else {
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp
index 9ccfa36450..9c8582c7a3 100644
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -128,6 +128,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "gettxout", 2, "include_mempool" },
{ "gettxoutproof", 0, "txids" },
{ "gettxoutsetinfo", 1, "hash_or_height" },
+ { "gettxoutsetinfo", 2, "use_index"},
{ "lockunspent", 0, "unlock" },
{ "lockunspent", 1, "transactions" },
{ "send", 0, "outputs" },