Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't count minted coins in block stats #1048

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <hash.h>
#include <index/blockfilterindex.h>
#include <masternodes/masternodes.h>
#include <masternodes/mn_checks.h>
#include <policy/feerate.h>
#include <policy/policy.h>
#include <policy/rbf.h>
Expand Down Expand Up @@ -1883,8 +1884,15 @@ static UniValue getblockstats(const JSONRPCRequest& request)

CAmount tx_total_out = 0;
if (loop_outputs) {
for (const CTxOut& out : tx->vout) {
tx_total_out += out.nValue;
auto mintingOutputsStart = ~0u;
if (auto accountToUtxos = GetAccountToUtxosMsg(*tx)) {
mintingOutputsStart = accountToUtxos->mintingOutputsStart;
}
for (size_t i = 0; i < tx->vout.size(); ++i) {
const auto& out = tx->vout[i];
if (i < mintingOutputsStart) {
tx_total_out += out.nValue;
}
utxo_size_inc += GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/functional/feature_accounts_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def run_test(self):
node.generate(1)
self.sync_all()

stats = node.getblockstats(blockcount + 1)
assert_equal(stats["total_out"], 18199952120)
assert_equal(stats["totalfee"], 25880)

# Check the blockchain has extended as expected
assert_equal(node1.getblockcount(), blockcount + 1)

Expand Down