I understand that we can use RBF Protocol to replace a transaction with higher fees to get the transaction confirmed faster. However, is it possible to use RBF to change the value of the transaction, or to set it to zero (in case of cancellation)?
2 Answers
However, is it possible to use RBF to change the value of the transaction or zero value (in case of cancellation)?
Yes, there is no restriction on transactions only changing the fee. In fact, that's not possible in general, as increasing the fee implies at least one of:
- Adding an additional input
- Reducing or removing an output
The former may not be possible (e.g. if a wallet already has all its inputs in flight), and the latter typically involves reducing the amount sent as change back to the sender. Since the protocol has (intentionally) no way of knowing which output is change, the latter is inherently in conflict with a hypothetical "only fee changes allowed in RBF" policy.
So, RBF can be used for any transaction replacement whatsoever. Typical usage is just fee bumping (where non-change outputs remain the same), but the protocol has no way of enforcing this, and thus RBF recipients need to be aware that unconfirmed transactions may be replaced with another that doesn't pay the same people at all. In fact, this is true in general, as unconfirmed funds in Bitcoin are generally not secure - RBF or not.
Bitcoin Optech defines RBF as:
Replace-By-Fee (RBF) is a node policy that allows an unconfirmed transaction in a mempool to be replaced with a different transaction that spends at least one of the same inputs and which pays a higher transaction fee.
It is generally assumed that the destination (address) and the funds being sent are the same for both the original transaction and the replacement transaction. The problem with changing the destination and/or the funds being sent is that there is no guarantee that this replacement transaction will make it into the blockchain first before the original transaction. You can try to get the replacement transaction into the blockchain first and the quicker you broadcast it and the higher the fee the better. But if the original transaction is being propagated across the network there is no way to stop it from getting into the blockchain if it is paying a sufficient fee rate. Hence RBF focuses on merely bumping the fee. With this use case if the original transaction gets into the blockchain before the replacement this is actually beneficial to the sender as they end up paying less fee than the fee in the replacement transaction.
If you think you might want to change the destination or the funds sent at a later time it is better to delay broadcasting the transaction until you are sure what you want to send.