@@ -2076,10 +2076,6 @@ static UniValue getblockstats(const JSONRPCRequest& request)
2076
2076
if (tx->IsCoinStake ()) {
2077
2077
continue ;
2078
2078
}
2079
- if (tx->vin [0 ].IsAnonInput ()) {
2080
- // Can't really do much with a ringCT transaction
2081
- continue ;
2082
- }
2083
2079
2084
2080
inputs += tx->vin .size (); // Don't count coinbase's fake input
2085
2081
total_out += tx_total_out; // Don't count coinbase reward
@@ -2110,34 +2106,46 @@ static UniValue getblockstats(const JSONRPCRequest& request)
2110
2106
2111
2107
if (loop_inputs) {
2112
2108
2113
- if (!g_txindex) {
2114
- throw JSONRPCError (RPC_INVALID_PARAMETER, " One or more of the selected stats requires -txindex enabled" );
2115
- }
2116
- CAmount tx_total_in = 0 ;
2117
- for (const CTxIn& in : tx->vin ) {
2118
- if (!in.IsZerocoinSpend ()) {
2119
- CTransactionRef tx_in;
2120
- uint256 hashBlock;
2121
- if (!GetTransaction (in.prevout .hash , tx_in, Params ().GetConsensus (), hashBlock, false )) {
2122
- throw JSONRPCError (RPC_INTERNAL_ERROR, std::string (" Unexpected internal error (tx index seems corrupt)" ));
2109
+ CAmount txfee;
2110
+ if (tx->vin [0 ].IsAnonInput ()) {
2111
+ if (!tx->GetCTFee (txfee)) {
2112
+ // Can't really do much with a ringCT transaction with no fee
2113
+ continue ;
2114
+ }
2115
+ } else {
2116
+ if (!g_txindex) {
2117
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " One or more of the selected stats requires -txindex enabled" );
2118
+ }
2119
+ // Total up the utxo_size_inc even if we have a ct_fee
2120
+ CAmount tx_total_in = 0 ;
2121
+ for (const CTxIn& in : tx->vin ) {
2122
+ if (!in.IsZerocoinSpend ()) {
2123
+ CTransactionRef tx_in;
2124
+ uint256 hashBlock;
2125
+ if (!GetTransaction (in.prevout .hash , tx_in, Params ().GetConsensus (), hashBlock, false )) {
2126
+ throw JSONRPCError (RPC_INTERNAL_ERROR, std::string (" Unexpected internal error (tx index seems corrupt)" ));
2127
+ }
2128
+
2129
+ auto prevoutput = tx_in->vpout [in.prevout .n ];
2130
+
2131
+ tx_total_in += prevoutput->GetValue ();
2132
+ CDataStream ss (SER_NETWORK, PROTOCOL_VERSION);
2133
+ ss << *prevoutput.get ();
2134
+ utxo_size_inc -= ss.size () + PER_UTXO_OVERHEAD;
2135
+ } else {
2136
+ tx_total_in += in.GetZerocoinSpent ();
2137
+ }
2138
+ }
2139
+ // Prefer the ct_fee over the difference
2140
+ if (!tx->GetCTFee (txfee)) {
2141
+ txfee = tx_total_in - tx_total_out;
2142
+ if (tx_total_in < tx_total_out) {
2143
+ // RingCT with hidden inputs, can't count it
2144
+ continue ;
2123
2145
}
2124
-
2125
- auto prevoutput = tx_in->vpout [in.prevout .n ];
2126
-
2127
- tx_total_in += prevoutput->GetValue ();
2128
- CDataStream ss (SER_NETWORK, PROTOCOL_VERSION);
2129
- ss << *prevoutput.get ();
2130
- utxo_size_inc -= ss.size () + PER_UTXO_OVERHEAD;
2131
- } else {
2132
- tx_total_in += in.GetZerocoinSpent ();
2133
2146
}
2134
2147
}
2135
2148
2136
- CAmount txfee = tx_total_in - tx_total_out;
2137
- if (tx_total_in < tx_total_out) {
2138
- // RingCT with hidden inputs, can't count it
2139
- continue ;
2140
- }
2141
2149
assert (MoneyRange (txfee));
2142
2150
if (do_medianfee) {
2143
2151
fee_array.push_back (txfee);
0 commit comments