bitcoin/bitcoin — pull request #2577 by gavinandresen (2013-04-26 14:35:58+00:00)
Title: Treat dust outputs as non-standard, un-hardcode TX_FEE constants

This is a quick, safe fix for transaction fee handling. A riskier, more complicated fix still needs to happen, but will take more time to code/test/etc.

Two motivations for this pull:

First, to discourage people from bloating users' wallets and the UTXO set with tiny outputs.

This pull defines 'uneconomic dust' as 54 uBTC (5400 satoshis, about $0.007 at current prices), and treats any transaction with outputs less than 5400 satoshis as non-standard (won't be relayed, won't be mined). 5400 satoshis is derived from the cost (in fees) to spend a TxOut/TxIn. See https://people.xiph.org/~greg/txouts2.png for proportion of recent outputs this will (eventually) affect.

Second, we have no idea what will happen to Bitcoin prices or transaction volume / competition for space in blocks. So this patch gives users and miners specify the minimum transaction fees at startup, using the -mintxfee / -mintxrelayfee options (which I'm intentionally leaving undocumented for now). The dust/nonstandard test is based on the -mintxrelayfee.

Qt and RPC both now tell the user why CreateTransaction fails, if it fails; Qt error reporting is a little wonky (try to send one satoshi, and you get two modal dialog boxes, one after the other; I don't care enough to try to fix that).

The transaction creation code didn't have to change; it was already written to never create dust outputs.

Note: I spent several hours trying, and failing, to create unit tests for this patch; CWallet::fFileBacked is ignored by several of the wallet routines used by CWallet::CreateNewTransaction. In the end, I decided thatrefactoring CWallet to support unit testing would be much more extensive and riskier than these changes.