Support for RBF (Replace-By-Fee) and CPFP (Child Pays for Parent) Functionality
Issue Description
Pending transactions often remain unconfirmed due to insufficient fees or network congestion, leading to delays and frustration for users. To address this, mechanisms are required to allow replacing or incentivizing transactions to ensure timely confirmation.
EVM-Based Chains
Nonce-Based Transaction Replacement
Implement support for a nonce-based Transaction Replacement mechanism in EVM-based chains to allow replacing pending transactions with higher gas fees.
UTXO-Based Chains
Replace-By-Fee (RBF) Introduce support for Replace-By-Fee (RBF) in UTXO-based chains. RBF allows replacing transactions in the mempool with a new transaction offering a higher fee, ensuring faster inclusion during network congestion. This feature can improve user experience when transactions are delayed due to insufficient fees.
Child Pays for Parent (CPFP)
Implement Child Pays for Parent (CPFP) functionality for UTXO-based chains. CPFP enables the creation of linked transactions where a high-fee child transaction motivates miners to include a related low-fee parent transaction in the same block. This ensures both transactions are confirmed together, addressing scenarios where the parent transaction would otherwise remain unconfirmed due to insufficient fees.
These features should be supported by both the wallet and DEX functionalities to enhance user experience across various transaction scenarios.
There also could be a recovery mechanism which retries to send new tx during swap if previous failed due to insufficient gas limit and cannot be replaced using the nonce-based mechanism.
btw RBF is also supported for some UTXO coins, for e.g. BTC.
First obvious option for use of RBF is withdrawal of coins.
Another option is to retry of maker or taker payment if it has low txfee (mentioned in the issue description). The implementation of this requires workflow changes: we need to detect this low fee condition while swap is in progress (by setting some special timeout for payment confirmation). Then we would need a new workflow state and require the user interaction to retry with higher fee.
I think what we could w/o big changes in workflow is use of RBF or CPFP in refund. if a swap has entered the failed state and we have the payment tx stuck due to low fee we may use this:
- for utxo use CPFP to recover funds payment tx
- for eth we may use the 'cancel' RBF option: create a new replacement tx (with the same nonce) and with small amount and bumped fee.
btw RBF is also supported for some UTXO coins, for e.g. BTC.
Yes, UTXO support both RBF and CPFP. As I understand, these approaches were originally created to address challenges in Bitcoin's transaction fee management and confirmation process.
On EVM-based chains, there is a mechanism similar to Bitcoin's RBF called (unofficially) "Transaction Replacement." It works by using nonces to identify and replace unconfirmed transactions.
ps: I will update issue description a bit to differentiate evm and utxo more explicitly