From 3127a4808b05092900e47e2ce9dd1f4d74762e2c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 20 Oct 2016 16:08:02 -0300 Subject: [PATCH] test --- src/coins.cpp | 3 +++ src/komodo.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/coins.cpp b/src/coins.cpp index 5f23528f5..147c68872 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -383,6 +383,8 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const return coins->vout[input.prevout.n].scriptPubKey; } +uint32_t komodo_txtime(uint256 hash); + CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const { if (tx.IsCoinBase()) @@ -391,6 +393,7 @@ CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const CAmount nResult = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { + fprintf(stderr,"i.%d time.%u\n",i,komodo_txtime(tx.vin[i].prevout.hash)); nResult += GetOutputFor(tx.vin[i]).nValue; } nResult += tx.GetJoinSplitValueIn(); diff --git a/src/komodo.h b/src/komodo.h index 7d8059695..37d8a558f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -605,4 +605,21 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) } } +uint32_t komodo_txtime(uint256 hash) +{ + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(hash, tx, hashBlock, true)) + return(0); + if (!hashBlock.IsNull()) { + BlockMap::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) + return(pindex->GetBlockTime()); + } + } + return(0); +} #endif