This PR’ aim is to improve user experience around stuck transactions without affecting users of zero conf transactions.
tldr: Allow transaction replacement for transactions sitting in mempool for longer than timeout (default 6h configurable) regardless of opt-in replacement flag.
This PR affects policy/relay only.
Stuck transactions have been a problem for users recently. While wallets are improving (opt in replacement, Child Pays For Parent, etc) there are some cases which find users with transactions stuck for days that can’t be solved easily/reliably by wallet developers, especially when the user creates the stuck transaction with old software or for some reason disabled available features countering stuck transactions.
For the purpose of the below I will ignore transactions created by the core wallet when talking about transaction expiration/eviction and focus on policy.
Bitcoin 0.12 introduced (or in a way re-introduced) opt-in transaction replacement (BIP125), allowing people to more explicitly flag that their transaction can be replaced (such that users of zero conf transactions can immediately recognize them).
At the same time mempool limiting (configurable) was introduced, making the individual mempool drop transactions at the bottom (low fee) when full.
Both before and after these changes any transaction in mempool would be automatically evicted after 72 hours (configurable).
Recently 0.14.0 increased the eviction from 72 hours to 2 weeks. These changes allows users of the system to aim for lower fees but at the same time makes it frustrating for users that disable opt-in transaction replacement or that use software that doesn’t support it in first place to bump the fee at a later time or to revert the payment as they have to wait for a while or use ad-hoc software.
A number of miners will mine transactions regardless of opt-in flags (5-10% maybe) and while core nodes won’t propagate those transactions, a well connected user can generally get replacement transactions mined within a reasonable amount of time without opt-in transaction replacement flags set.
This may be convenient for attackers or ad-hoc expert use but not ideal for wallet developers, or at least until core merges full transaction replacement because using this functionality would requires wallets to use preferential peering and/or forks of bitcoin core.
Until then a compromise solution that doesn’t impact zero conf use and that improves user experience would be to allow transactions to be replaced after sitting for a timeout in mempool (thus unconfirmed).
The timeout should be high enough that allows current use of zero conf and at the same time allows same working day solution for users. I suggest a 6 hours timeout and to have it configurable for testing and ability for user to change.
The changes continue to support disabling entirely transaction replacement (-mempoolreplacement) and introduces a new command line parameter (-mempoolreplacementtimeout) which allows to pass the number of seconds after which a transaction can be unconditionally replaced and setting this parameter to two weeks will keep the original behavior.
If you want to test the changes using @petertodd Replace-by-Fee tools build core with this PR applied and wallet enabled and run with -mempoolreplacementtimeout=10 and use doublespend.py (with and without -b 1) from https://github.com/petertodd/replace-by-fee-tools