feat(evm): implement transaction replacement (speed up/cancel)#2535
Draft
feat(evm): implement transaction replacement (speed up/cancel)#2535
Conversation
This commit introduces the ability to replace pending Ethereum-based transactions. Users can now use the `replace_transaction` RPC to either "speed up" a transaction by re-broadcasting it with a higher fee, or "cancel" it by sending a zero-value transaction to themselves with the same nonce. Key changes include: - A new `replace_transaction` method on the `MmCoin` trait, with a concrete implementation for `EthCoin`. - The `EthWithdraw` logic has been updated to allow for nonce overriding, which is essential for replacing transactions. - An in-memory `local_tx_cache` has been added to `EthCoin` to enable replacement of transactions that have not yet been propagated to RPC nodes. - A new `replace_transaction` RPC endpoint is exposed through the dispatcher. refactor(coins): Centralize HD address scanning logic As part of this work, the `scan_for_new_addresses` function has been refactored from a required trait method into a default implementation on the `HDWalletBalanceOps` trait. This change simplifies the codebase by removing redundant address scanning logic from multiple UTXO-based coins (`BchCoin`, `QtumCoin`, `UtxoStandardCoin`) and `EthCoin`, making them rely on the new generic implementation. This also involved adding a `bip44_chains` method to specify which chains to scan.
4d118bc to
08c403e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: