Browse Source

test

pull/4/head
jl777 8 years ago
parent
commit
e19d8b3dee
  1. 2
      src/coins.cpp
  2. 10
      src/komodo.h
  3. 2
      src/main.cpp
  4. 49
      src/wallet/wallet.cpp

2
src/coins.cpp

@ -393,7 +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));
fprintf(stderr,"i.%d time.%u\n",i,komodo_txtime(tx.vin[i].prevout.hash));
nResult += GetOutputFor(tx.vin[i]).nValue;
}
nResult += tx.GetJoinSplitValueIn();

10
src/komodo.h

@ -252,8 +252,8 @@ uint32_t komodo_txtime(uint256 hash)
uint256 hashBlock;
if (!GetTransaction(hash, tx, hashBlock, true))
{
printf("null GetTransaction\n");
return(0);
//printf("null GetTransaction\n");
return(tx.nLockTime);
}
if (!hashBlock.IsNull()) {
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
@ -263,10 +263,10 @@ uint32_t komodo_txtime(uint256 hash)
if (chainActive.Contains(pindex))
return(pindex->GetBlockTime());
}
printf("cant find in iterator\n");
//printf("cant find in iterator\n");
}
printf("null hashBlock\n");
return(0);
//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)

2
src/main.cpp

@ -699,6 +699,8 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
return true;
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
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)
if (!txin.IsFinal())
return false;

49
src/wallet/wallet.cpp

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

Loading…
Cancel
Save