From 5365d15e693f1a3e1e5543ca48ce19d6490157f7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 18 Aug 2019 18:06:12 -0700 Subject: [PATCH] Correct various stats and add block height to response --- src/main.cpp | 15 +++++++++------ src/rpc/blockchain.cpp | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bcfb83f77..fda64ce02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4796,11 +4796,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl nShieldedTx++; if(tx.vin.size()==0 && tx.vout.size()==0) { nFullyShieldedTx++; - } - if(tx.vin.size()>0) { + } else if(tx.vin.size()>0) { nShieldingTx++; - } - if(tx.vout.size()>0) { + } else if(tx.vout.size()>0) { nDeshieldingTx++; } //NOTE: These are at best heuristics. Improve them as much as possible @@ -4819,8 +4817,13 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // z->(z,z,z) = 2 shielded payments + shielded change // Assume that there is always 1 change output when there are more than one nShieldedPayments += nShieldedOutputs > 1 ? (nShieldedOutputs-1) : 1; - // TODO: fully shielded should not count toward shielding/deshielding - nShieldingPayments += nShieldedOutputs > 1 ? (nShieldedOutputs-1) : 1; + + // Fully shielded do not count toward shielding/deshielding + if(tx.vin.size()==0 && tx.vout.size()==0) { + nFullyShieldedPayments += nShieldedOutputs > 1 ? (nShieldedOutputs-1) : 1; + } else { + nShieldingPayments += nShieldedOutputs > 1 ? (nShieldedOutputs-1) : 1; + } } else if (nShieldedSpends >=1) { // Shielded inputs with no shielded outputs. We know none are change output because // change would flow back to the zaddr diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f963052d4..d18f4e5c1 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2017,6 +2017,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); + ret.pushKV("window_final_block_height", pindex->GetHeight()); ret.pushKV("window_block_count", blockcount); if (blockcount > 0) {