@ -781,11 +781,10 @@ struct CCoinsStats
uint256 hashBlock ;
uint256 hashBlock ;
uint64_t nTransactions ;
uint64_t nTransactions ;
uint64_t nTransactionOutputs ;
uint64_t nTransactionOutputs ;
uint64_t nSerializedSize ;
uint256 hashSerialized ;
uint256 hashSerialized ;
CAmount nTotalAmount ;
CAmount nTotalAmount ;
CCoinsStats ( ) : nHeight ( 0 ) , nTransactions ( 0 ) , nTransactionOutputs ( 0 ) , nSerializedSize ( 0 ) , n TotalAmount ( 0 ) { }
CCoinsStats ( ) : nHeight ( 0 ) , nTransactions ( 0 ) , nTransactionOutputs ( 0 ) , nTotalAmount ( 0 ) { }
} ;
} ;
//! Calculate statistics about the unspent transaction output set
//! Calculate statistics about the unspent transaction output set
@ -808,16 +807,17 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
if ( pcursor - > GetKey ( key ) & & pcursor - > GetValue ( coins ) ) {
if ( pcursor - > GetKey ( key ) & & pcursor - > GetValue ( coins ) ) {
stats . nTransactions + + ;
stats . nTransactions + + ;
ss < < key ;
ss < < key ;
ss < < VARINT ( coins . nHeight * 2 + coins . fCoinBase ) ;
for ( unsigned int i = 0 ; i < coins . vout . size ( ) ; i + + ) {
for ( unsigned int i = 0 ; i < coins . vout . size ( ) ; i + + ) {
const CTxOut & out = coins . vout [ i ] ;
const CTxOut & out = coins . vout [ i ] ;
if ( ! out . IsNull ( ) ) {
if ( ! out . IsNull ( ) ) {
stats . nTransactionOutputs + + ;
stats . nTransactionOutputs + + ;
ss < < VARINT ( i + 1 ) ;
ss < < VARINT ( i + 1 ) ;
ss < < out ;
ss < < * ( const CScriptBase * ) ( & out . scriptPubKey ) ;
ss < < VARINT ( out . nValue ) ;
nTotalAmount + = out . nValue ;
nTotalAmount + = out . nValue ;
}
}
}
}
stats . nSerializedSize + = 32 + pcursor - > GetValueSize ( ) ;
ss < < VARINT ( 0 ) ;
ss < < VARINT ( 0 ) ;
} else {
} else {
return error ( " %s: unable to read value " , __func__ ) ;
return error ( " %s: unable to read value " , __func__ ) ;
@ -891,7 +891,6 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
" \" bestblock \" : \" hex \" , (string) the best block hash hex \n "
" \" bestblock \" : \" hex \" , (string) the best block hash hex \n "
" \" transactions \" : n, (numeric) The number of transactions \n "
" \" transactions \" : n, (numeric) The number of transactions \n "
" \" txouts \" : n, (numeric) The number of output transactions \n "
" \" txouts \" : n, (numeric) The number of output transactions \n "
" \" bytes_serialized \" : n, (numeric) The serialized size \n "
" \" hash_serialized \" : \" hash \" , (string) The serialized hash \n "
" \" hash_serialized \" : \" hash \" , (string) The serialized hash \n "
" \" total_amount \" : x.xxx (numeric) The total amount \n "
" \" total_amount \" : x.xxx (numeric) The total amount \n "
" } \n "
" } \n "
@ -909,8 +908,7 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
ret . push_back ( Pair ( " bestblock " , stats . hashBlock . GetHex ( ) ) ) ;
ret . push_back ( Pair ( " bestblock " , stats . hashBlock . GetHex ( ) ) ) ;
ret . push_back ( Pair ( " transactions " , ( int64_t ) stats . nTransactions ) ) ;
ret . push_back ( Pair ( " transactions " , ( int64_t ) stats . nTransactions ) ) ;
ret . push_back ( Pair ( " txouts " , ( int64_t ) stats . nTransactionOutputs ) ) ;
ret . push_back ( Pair ( " txouts " , ( int64_t ) stats . nTransactionOutputs ) ) ;
ret . push_back ( Pair ( " bytes_serialized " , ( int64_t ) stats . nSerializedSize ) ) ;
ret . push_back ( Pair ( " hash_serialized_2 " , stats . hashSerialized . GetHex ( ) ) ) ;
ret . push_back ( Pair ( " hash_serialized " , stats . hashSerialized . GetHex ( ) ) ) ;
ret . push_back ( Pair ( " total_amount " , ValueFromAmount ( stats . nTotalAmount ) ) ) ;
ret . push_back ( Pair ( " total_amount " , ValueFromAmount ( stats . nTotalAmount ) ) ) ;
} else {
} else {
throw JSONRPCError ( RPC_INTERNAL_ERROR , " Unable to read UTXO set " ) ;
throw JSONRPCError ( RPC_INTERNAL_ERROR , " Unable to read UTXO set " ) ;
@ -992,7 +990,6 @@ UniValue gettxout(const JSONRPCRequest& request)
UniValue o ( UniValue : : VOBJ ) ;
UniValue o ( UniValue : : VOBJ ) ;
ScriptPubKeyToUniv ( coins . vout [ n ] . scriptPubKey , o , true ) ;
ScriptPubKeyToUniv ( coins . vout [ n ] . scriptPubKey , o , true ) ;
ret . push_back ( Pair ( " scriptPubKey " , o ) ) ;
ret . push_back ( Pair ( " scriptPubKey " , o ) ) ;
ret . push_back ( Pair ( " version " , coins . nVersion ) ) ;
ret . push_back ( Pair ( " coinbase " , coins . fCoinBase ) ) ;
ret . push_back ( Pair ( " coinbase " , coins . fCoinBase ) ) ;
return ret ;
return ret ;