This commit is contained in:
jl777
2016-10-21 15:20:30 -03:00
parent b1c247f28f
commit e19d8b3dee
4 changed files with 36 additions and 27 deletions

View File

@@ -393,7 +393,7 @@ CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const
CAmount nResult = 0; CAmount nResult = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) 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,"i.%d time.%u\n",i,komodo_txtime(tx.vin[i].prevout.hash));
nResult += GetOutputFor(tx.vin[i]).nValue; nResult += GetOutputFor(tx.vin[i]).nValue;
} }
nResult += tx.GetJoinSplitValueIn(); nResult += tx.GetJoinSplitValueIn();

View File

@@ -252,8 +252,8 @@ uint32_t komodo_txtime(uint256 hash)
uint256 hashBlock; uint256 hashBlock;
if (!GetTransaction(hash, tx, hashBlock, true)) if (!GetTransaction(hash, tx, hashBlock, true))
{ {
printf("null GetTransaction\n"); //printf("null GetTransaction\n");
return(0); return(tx.nLockTime);
} }
if (!hashBlock.IsNull()) { if (!hashBlock.IsNull()) {
BlockMap::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
@@ -263,10 +263,10 @@ uint32_t komodo_txtime(uint256 hash)
if (chainActive.Contains(pindex)) if (chainActive.Contains(pindex))
return(pindex->GetBlockTime()); return(pindex->GetBlockTime());
} }
printf("cant find in iterator\n"); //printf("cant find in iterator\n");
} }
printf("null hashBlock\n"); //printf("null hashBlock\n");
return(0); return(tx.nLockTime);
} }
void komodo_nutxoadd(int32_t addflag,int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) void komodo_nutxoadd(int32_t addflag,int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts)

View File

@@ -699,6 +699,8 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
return true; return true;
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true; return true;
if ( (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 )
return(false); // need to prevent pastdating tx
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
if (!txin.IsFinal()) if (!txin.IsFinal())
return false; return false;

View File

@@ -2411,27 +2411,34 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
wtxNew.BindWallet(this); wtxNew.BindWallet(this);
CMutableTransaction txNew; CMutableTransaction txNew;
// Discourage fee sniping. if ( 0 )
// {
// However because of a off-by-one-error in previous versions we need to // Discourage fee sniping.
// neuter it by setting nLockTime to at least one less than nBestHeight. //
// Secondly currently propagation of transactions created for block heights // However because of a off-by-one-error in previous versions we need to
// corresponding to blocks that were just mined may be iffy - transactions // neuter it by setting nLockTime to at least one less than nBestHeight.
// aren't re-accepted into the mempool - we additionally neuter the code by // Secondly currently propagation of transactions created for block heights
// going ten blocks back. Doesn't yet do anything for sniping, but does act // corresponding to blocks that were just mined may be iffy - transactions
// to shake out wallet bugs like not showing nLockTime'd transactions at // aren't re-accepted into the mempool - we additionally neuter the code by
// all. // going ten blocks back. Doesn't yet do anything for sniping, but does act
txNew.nLockTime = std::max(0, chainActive.Height() - 10); // to shake out wallet bugs like not showing nLockTime'd transactions at
// all.
// Secondly occasionally randomly pick a nLockTime even further back, so txNew.nLockTime = std::max(0, chainActive.Height() - 10);
// that transactions that are delayed after signing for whatever reason,
// e.g. high-latency mix networks and some CoinJoin implementations, have // Secondly occasionally randomly pick a nLockTime even further back, so
// better privacy. // that transactions that are delayed after signing for whatever reason,
if (GetRandInt(10) == 0) // e.g. high-latency mix networks and some CoinJoin implementations, have
txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100)); // better privacy.
if (GetRandInt(10) == 0)
assert(txNew.nLockTime <= (unsigned int)chainActive.Height()); txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100));
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);
assert(txNew.nLockTime <= (unsigned int)chainActive.Height());
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);
}
else
{
txNew.nLockTime = (uint32_t)time(NULL) - 1800; // set to a time close to now
}
{ {
LOCK2(cs_main, cs_wallet); LOCK2(cs_main, cs_wallet);