feat(evm): implement transaction replacement (speed up/cancel) #2535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a crucial feature for EVM-based coins: the ability to replace pending transactions. When a transaction is stuck due to low gas fees on a congested network, users can now use the new
replace_transaction RPCto either speed it up (by re-broadcasting with a higher fee) or cancel it (by sending a zero-value transaction to themselves with the same nonce).Note:
This is not yet integrated with the legacy swaps or TPU. Attempting to replace an HTLC locking transaction will currently fail on purpose, as the counterparty would not be aware of the changed transaction hex or hash. To properly support transaction replacement for swaps, the following must be addressed in future work:
When a transaction is replaced (sped up), the change must be communicated to the swap counterparty via p2p. The counterparty must be able to listen for and process this message while waiting for the on-chain events due to the first message.
A specific timeout should be defined during which a transaction can be replaced. This window should align with the different timeouts in the swap code.
GUIs should only present the "Speed Up" option during this defined timeout window if a transaction is not confirmed.
Todo in next PR: