bitcoin/bitcoin — pull request #2340 by petertodd (2013-03-01 11:09:14+00:00)
Title: Discourage fee sniping with nLockTime

Set nLockTime on wallet transactions (only, no RPC changes) such that they can only be mined by the next block, rather than a block orphaning the current best block. There are two reasons to do this, the first is the minor benefit that using nLockTime ensures related bugs get caught immediately, so protocols that need that feature don't become "unusual" transactions with flaky behavior.

The more important reason is to discourage "fee sniping" by deliberately
mining blocks that orphan the current best block. Basically 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 best block. However with nLockTime you'll soon run out of
transactions you can put in the first block, which means they now need
to go in the second. With limited block sizes you're run out of room,
and additionally another miner now only needs to orphan one block to
in-turn snipe the high-fee transactions you had to place in the second
block, wrecking all your hard work.

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. Transaction propagation is not
impacted; even with non-final is non-standard the best block height
implies we have at least one peer, and very soon more peers, that will
accept and rebroadcast the transaction immediately.

# Testing

## Unit tests

Pass

## Propagation

No issues. Used -blocknotify='bitcoind sendtoaddress' to send transactions as soon as a few block is found with worst-case of a node connected to only two 0.8 peers. Enabled -logtimestamps w/ ntp on that node and another node, and every transaction got to the second node within 5 seconds.

## Services

No problems:

Easywallet, Instawallet, Coinbase Wallet, Blockchain.info, BitPay, bitfetch, localbitcoins

Won't accept until 1 confirmation:

Satoshidice, Coinbase Merchant Payments

Most likely these two services implemented nLockTime == 0 rather than IsFinal() as their never-confirm nLockTime fix; I'll contact them.