diff --git a/src/coins.cpp b/src/coins.cpp index 147c68872..3385ebd6b 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -383,7 +383,28 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const return coins->vout[input.prevout.n].scriptPubKey; } -uint32_t komodo_txtime(uint256 hash); +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); +} CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const { @@ -393,7 +414,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)); + fprintf(stderr,"GetValueIn 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 90e2527c8..41703845a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -246,29 +246,6 @@ 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/main.cpp b/src/main.cpp index 29afc109e..f781a8d6d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2133,7 +2133,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (nSigOps > MAX_BLOCK_SIGOPS) return state.DoS(100, error("ConnectBlock(): too many sigops"), REJECT_INVALID, "bad-blk-sigops"); - +fprintf(stderr,"ht.%d vout0 t%u\n",pindex->nHeight,tx.nLockTime); if (!tx.IsCoinBase()) { if (!view.HaveInputs(tx)) diff --git a/src/miner.cpp b/src/miner.cpp index 56a6aa515..c65dcff41 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -329,6 +329,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Create coinbase tx CMutableTransaction txNew; + txNew.nLockTime = (uint32_t)time(NULL) - 60; txNew.vin.resize(1); txNew.vin[0].prevout.SetNull(); txNew.vout.resize(1); @@ -499,7 +500,6 @@ void static BitcoinMiner(CWallet *pwallet) } CBlock *pblock = &pblocktemplate->block; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); - LogPrintf("Running ZcashMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b33888a29..194299472 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2437,7 +2437,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, } else { - txNew.nLockTime = (uint32_t)time(NULL) - 1800; // set to a time close to now + txNew.nLockTime = (uint32_t)time(NULL) - 60; // set to a time close to now } {