@@ -1871,15 +1871,25 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
18711871
18721872 // Discourage fee sniping.
18731873 //
1874- // However because of a off-by-one-error in previous versions we need to
1875- // neuter it by setting nLockTime to at least one less than nBestHeight.
1876- // Secondly currently propagation of transactions created for block heights
1877- // corresponding to blocks that were just mined may be iffy - transactions
1878- // aren't re-accepted into the mempool - we additionally neuter the code by
1879- // going ten blocks back. Doesn't yet do anything for sniping, but does act
1880- // to shake out wallet bugs like not showing nLockTime'd transactions at
1881- // all.
1882- txNew.nLockTime = std::max (0 , chainActive.Height () - 10 );
1874+ // For a large miner the value of the transactions in the best block and
1875+ // the mempool can exceed the cost of delibrately attempting to mine two
1876+ // blocks to orphan the current best block. By setting nLockTime such that
1877+ // only the next block can include the transaction, we discourage this
1878+ // practice as the height restricted and limited blocksize gives miners
1879+ // considering fee sniping fewer options for pulling off this attack.
1880+ //
1881+ // A simple way to think about this is from the wallet's point of view we
1882+ // always want the blockchain to move forward. By setting nLockTime this
1883+ // way we're basically making the statement that we only want this
1884+ // transaction to appear in the next block; we don't want to potentially
1885+ // encourage reorgs by allowing transactions to appear at lower heights
1886+ // than the next block in forks of the best chain.
1887+ //
1888+ // Of course, the subsidy is high enough, and transaction volume low
1889+ // enough, that fee sniping isn't a problem yet, but by implementing a fix
1890+ // now we ensure code won't be written that makes assumptions about
1891+ // nLockTime that preclude a fix later.
1892+ txNew.nLockTime = chainActive.Height ();
18831893
18841894 // Secondly occasionally randomly pick a nLockTime even further back, so
18851895 // that transactions that are delayed after signing for whatever reason,
0 commit comments