message: [RPC] Fix getblockstats to handle zerocoin spends, RingCT and PoS blocks
diff: @@ -1937,6 +1937,13 @@ static UniValue getblockstats(const JSONRPCRequest& request)
  if (tx->IsCoinBase()) {
  continue;
  }
  + if (tx->IsCoinStake()) {
  + continue;
  + }
  + if (tx->vin[0].IsAnonInput()) {
  + // Can't really do much with a ringCT transaction
  + continue;
  + }
  inputs += tx->vin.size(); // Don't count coinbase's fake input
  total_out += tx_total_out; // Don't count coinbase reward
  @@ -1972,6 +1979,7 @@ static UniValue getblockstats(const JSONRPCRequest& request)
  }
  CAmount tx_total_in = 0;
  for (const CTxIn& in : tx->vin) {
  + if (!in.IsZerocoinSpend()) {
  CTransactionRef tx_in;
  uint256 hashBlock;
  if (!GetTransaction(in.prevout.hash, tx_in, Params().GetConsensus(), hashBlock, false)) {
  @@ -1984,6 +1992,9 @@ static UniValue getblockstats(const JSONRPCRequest& request)
  CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
  ss << *prevoutput.get();
  utxo_size_inc -= ss.size() + PER_UTXO_OVERHEAD;
  + } else {
  + tx_total_in += in.GetZerocoinSpent();
  + }
  }
  CAmount txfee = tx_total_in - tx_total_out;
  