Skip to content

Commit

Permalink
peercoin needs no fee sniping protection
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed Aug 6, 2019
1 parent ce19110 commit 3d3800b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -7,7 +7,7 @@ define(_CLIENT_VERSION_BUILD, 0)
define(_PEERCOIN_VERSION_MAJOR, 0)
define(_PEERCOIN_VERSION_MINOR, 8)
define(_PEERCOIN_VERSION_REVISION, 2)
define(_PEERCOIN_VERSION_BUILD, 0)
define(_PEERCOIN_VERSION_BUILD, 1)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2019)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
35 changes: 1 addition & 34 deletions src/wallet/wallet.cpp
Expand Up @@ -2734,37 +2734,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
CMutableTransaction txNew;
txNew.nTime = wtxNew.tx->nTime; // peercoin: set time

// Discourage fee sniping.
//
// For a large miner the value of the transactions in the best block and
// the mempool can exceed the cost of deliberately attempting to mine two
// blocks to orphan the current best block. By setting nLockTime such that
// only the next block can include the transaction, we discourage this
// practice as the height restricted and limited blocksize gives miners
// considering fee sniping fewer options for pulling off this attack.
//
// A simple way to think about this is from the wallet's point of view we
// always want the blockchain to move forward. By setting nLockTime this
// way we're basically making the statement that we only want this
// transaction to appear in the next block; we don't want to potentially
// encourage reorgs by allowing transactions to appear at lower heights
// than the next block in forks of the best chain.
//
// Of course, the subsidy is high enough, and transaction volume low
// enough, that fee sniping isn't a problem yet, but by implementing a fix
// now we ensure code won't be written that makes assumptions about
// nLockTime that preclude a fix later.
txNew.nLockTime = chainActive.Height();

// 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);
CAmount nFeeNeeded;
unsigned int nBytes;
{
Expand Down Expand Up @@ -2900,9 +2869,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT

// Fill vin
//
// Note how the sequence number is set to non-maxint so that
// the nLockTime set above actually works.
const uint32_t nSequence = CTxIn::SEQUENCE_FINAL - 1;
const uint32_t nSequence = CTxIn::SEQUENCE_FINAL;
for (const auto& coin : setCoins)
txNew.vin.push_back(CTxIn(coin.outpoint,CScript(),
nSequence));
Expand Down

0 comments on commit 3d3800b

Please sign in to comment.