diff --git a/src/chain.h b/src/chain.h index 03fc75660..77d17114e 100644 --- a/src/chain.h +++ b/src/chain.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -276,9 +276,12 @@ public: //! inputs and outputs. int64_t nShieldedTx; - //! (memory only) Number of shielded outputs in the block up to and including this block. + //! (memory only) Number of shielded outputs int64_t nShieldedOutputs; + //! (memory only) Number of shielded spends + int64_t nShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -332,6 +335,9 @@ public: //! (memory only) Number of shielded outputs in the chain up to and including this block. int64_t nChainShieldedOutputs; + //! (memory only) Number of shielded spends in the chain up to and including this block. + int64_t nChainShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -429,18 +435,20 @@ public: nChainNotarizations = 0; nChainFullyShieldedTx = 0; nChainShieldedOutputs = 0; + nChainShieldedSpends = 0; nChainShieldedPayments = 0; nChainShieldingPayments = 0; nChainDeshieldingPayments = 0; nChainFullyShieldedPayments = 0; - // Shieldex Index stats + // Shielded Index stats nPayments = 0; nShieldedTx = 0; nShieldingTx = 0; nNotarizations = 0; nDeshieldingTx = 0; nShieldedOutputs = 0; + nShieldedSpends = 0; nFullyShieldedTx = 0; nShieldedPayments = 0; nShieldingPayments = 0; @@ -679,6 +687,7 @@ public: READWRITE(nDeshieldingPayments); READWRITE(nFullyShieldedPayments); READWRITE(nShieldedOutputs); + READWRITE(nShieldedSpends); } } diff --git a/src/consensus/params.h b/src/consensus/params.h index 67d84af0b..e4242ad33 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 7e0477eb7..0f0b59421 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/main.cpp b/src/main.cpp index d4426e181..0dc0cf87e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4734,7 +4734,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl CAmount sproutValue = 0; CAmount saplingValue = 0; bool isShieldedTx = false; - unsigned int nShieldedSpends=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; + unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; unsigned int nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0; unsigned int nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0; unsigned int nNotarizations=0; @@ -4822,8 +4822,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // No shielded payments, add transparent payments minus a change address nPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size(); } - // To calculate the anonset we must track the sum of zouts in every tx, in every block. -- Duke + // To calculate the anonset we must track the sum of spends and zouts in every tx, in every block. -- Duke nShieldedOutputsInBlock += nShieldedOutputs; + nShieldedSpendsInBlock += nShieldedSpends; } pindexNew->nSproutValue = sproutValue; @@ -4840,6 +4841,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nPayments = nPayments; pindexNew->nShieldedTx = nShieldedTx; pindexNew->nShieldedOutputs = nShieldedOutputsInBlock; + pindexNew->nShieldedSpends = nShieldedSpendsInBlock; pindexNew->nFullyShieldedTx = nFullyShieldedTx; pindexNew->nDeshieldingTx = nDeshieldingTx; pindexNew->nShieldingTx = nShieldingTx; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index faed5b957..3bdce7eb2 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2003,8 +2003,9 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); int64_t nullifierCount = pwalletMain->NullifierCount(); + //TODO: this is unreliable, is only a cache or subset of total nullifiers ret.pushKV("nullifiers", (int64_t)nullifierCount); - ret.pushKV("shielded_pool_size", (int64_t)pindex->nChainShieldedOutputs - nullifierCount); + ret.pushKV("shielded_pool_size", (int64_t)(pindex->nChainShieldedOutputs - pindex->nChainShieldedSpends)); ret.pushKV("shielded_outputs", (int64_t)pindex->nChainShieldedOutputs); } diff --git a/src/txdb.cpp b/src/txdb.cpp index 6fe8bd575..78769c07c 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -723,6 +723,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nPayments = diskindex.nPayments; pindexNew->nShieldedTx = diskindex.nShieldedTx; pindexNew->nShieldedOutputs = diskindex.nShieldedOutputs; + pindexNew->nShieldedSpends = diskindex.nShieldedSpends; pindexNew->nShieldedPayments = diskindex.nShieldedPayments; pindexNew->nShieldingTx = diskindex.nShieldingTx; pindexNew->nShieldingPayments = diskindex.nShieldingPayments;