Skip to content

Conversation

@shamardy
Copy link
Collaborator

@shamardy shamardy commented Jul 16, 2025

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 RPC to 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:

  • Replacing NFT transactions.
  • Task managed RPCs
  • Swap transactions replacements

@shamardy shamardy marked this pull request as draft July 16, 2025 13:36
@shamardy shamardy changed the title feat(evm): Implement transaction replacement (speed up/cancel) feat(evm): implement transaction replacement (speed up/cancel) Jul 16, 2025
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.
@shamardy shamardy force-pushed the feat/replace-by-nonce branch from 4d118bc to 08c403e Compare July 17, 2025 11:42
@onur-ozkan onur-ozkan self-requested a review July 22, 2025 05:00
@shamardy shamardy removed the request for review from onur-ozkan January 3, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants