From 8a9bc02778f67ac6b709cfdb2ebfec9023f6265b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 21 Oct 2016 16:44:49 -0300 Subject: [PATCH] test --- src/bitcoin-tx.cpp | 5 +++++ src/coins.cpp | 23 +---------------------- src/komodo.h | 24 +++++++++++++++++++++++- src/primitives/transaction.h | 3 +-- src/rest.cpp | 1 + 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 319be2991..89a54d846 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -322,6 +322,11 @@ vector ParseHexUO(map& o, string strKey) return ParseHexUV(o[strKey], strKey); } +uint32_t komodo_txtime(uint256 hash) +{ + return(0); +} + static void MutateTxSign(CMutableTransaction& tx, const string& flagStr) { int nHashType = SIGHASH_ALL; diff --git a/src/coins.cpp b/src/coins.cpp index 0fb9d4611..e5a744674 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -383,28 +383,7 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const return coins->vout[input.prevout.n].scriptPubKey; } -uint32_t komodo_txtime(uint256 hash) -{ - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction(hash, tx, hashBlock, true)) - { - //printf("null GetTransaction\n"); - return(tx.nLockTime); - } - 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()); - } - //printf("cant find in iterator\n"); - } - //printf("null hashBlock\n"); - return(tx.nLockTime); -} +uint32_t komodo_txtime(uint256 hash); CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx,uint32_t blocktime) const { diff --git a/src/komodo.h b/src/komodo.h index 9b5a9dca4..90e2527c8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,6 @@ struct knotaries_entry { int32_t height,numnotaries; struct knotary_entry *Notar struct notarized_checkpoint { uint256 notarized_hash,notarized_btctxid; int32_t nHeight,notarized_height; } *NPOINTS; int32_t NUM_NPOINTS; int32_t komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts); -uint32_t komodo_txtime(uint256 hash); // add opreturn funcid // pricefeeds @@ -247,6 +246,29 @@ int32_t komodo_threshold(int32_t height,uint64_t signedmask) else return(0); } +uint32_t komodo_txtime(uint256 hash) +{ + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(hash, tx, hashBlock, true)) + { + //printf("null GetTransaction\n"); + return(tx.nLockTime); + } + 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()); + } + //printf("cant find in iterator\n"); + } + //printf("null hashBlock\n"); + return(tx.nLockTime); +} + void komodo_nutxoadd(int32_t addflag,int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) { struct nutxo_entry *np; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 2e83773c4..61e756b2f 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -267,8 +267,7 @@ public: friend bool operator==(const CTxOut& a, const CTxOut& b) { - return (a.nValue == b.nValue && - a.scriptPubKey == b.scriptPubKey); + return (a.nValue == b.nValue && a.scriptPubKey == b.scriptPubKey); } friend bool operator!=(const CTxOut& a, const CTxOut& b) diff --git a/src/rest.cpp b/src/rest.cpp index 7c238d506..d278198b4 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -506,6 +506,7 @@ static bool rest_getutxos(AcceptedConnection* conn, utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer)); utxo.push_back(Pair("height", (int32_t)coin.nHeight)); utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); + //utxo.push_back(Pair("interest", ValueFromAmount(komodo_interest(coin.out.nValue,coin.nLockTime,chainActive.Tip()->nTime)))); // include the script in a json output Object o;