bitcoin/bitcoin — pull request #4298 by petertodd (2014-06-06 10:13:39+00:00)
Title: Add replace-by-fee logic to the mempool

Replaces transactions if a new transaction is seen with a higher fee, specifically both a higher fee per KB and a higher absolute fee. Children are evaluated for replacement as well, using a fixed depth/breadth limit to prevent DoS attacks. Child-pays-for-parent is however not yet supported.

This patch doesn't include any wallet changes to actually take advantage of replace-by-fee, e.g. fee bumping functionality. I have however written some Python utilities for experimentation: https://github.com/petertodd/replace-by-fee-tools Now that the wallet code handles double-spends correctly fee bumping and other replace-by-fee applications won't mess up your wallet with never-confirming transactions. That said Bitcoin-QT does need some UI improvements re: conflicts.

Note that this is the version suitable for a pull-req; if you want to actually try out replace-by-fee functionality use https://github.com/petertodd/bitcoin/tree/replace-by-fee-v0.9.1 instead. It has preferential peering code that seeks out other replace-by-fee supporting peers and connects to them, ensuring your replacements get propagated and you see others' replacements.

As discussed elsewhere ad nauseam, unconfirmed transactions are easily double-spent via a variety of methods with high success rates, even without miners implementing replace-by-fee. For instance the above replace-by-fee-tools has about a 95% success rate against most wallet software by taking advantage of the minimum v0.9 fee drop. Better to be clear to users about what security guarantees Bitcoin actually provides, and replace-by-fee functionality is highly useful otherwise to lower fees through more aggressive fee estimation, fix stuck transactions, lower fees by combining successive transactions, etc.