13

Both RBF and CPFP attempt to solve the problem of transactions not confirming because of an insufficient fee. What are the pros/cons of using one vs the other?

Are both currently functional and available for use on the bitcoin network?

Murch
  • 75,206
  • 34
  • 186
  • 622
morsecoder
  • 14,168
  • 2
  • 42
  • 94

1 Answers1

14

Replace-by-fee means transactions spending the same coin to the same addresses are not considered double-spends by the network and are still relayed, as long as they pay a higher fee than the preceding transaction.

Example: Alice pays Bob with a coin worth 1 BTC, sending 0.5 BTC to Bob, 0.49995 BTC to herself as change, and 0.00005 BTC to fees. Alice sees that her transaction is quite slow to confirm, so she sends an identical transaction (spending the same coin), but with twice the fee. The network relays the updated transaction and rational miners quickly mine the higher fee transaction.

Child pays for parent means, as the name implies, that spending an unconfirmed transaction will cause miners to consider confirming the parent transaction in order to get the fees from the child transaction included in the same block.

Example: Eve spends 1 BTC at a shop owned by Alice. But Eve is greedy: she only pays the bare minimum fee, and her transaction will take hours to confirm. Alice spends Eve's transaction to her banker Bob, but this time with a higher fee. Miners will now want to confirm Eve's cheap transaction in order to be able to include Alice's more rewarding transaction in their block.

RBF is currently live since 0.12, but is opt-in for the spender: Unless the spender marks the transaction as replaceable with a non-maximal sequence number, the transaction is final.

CPFP is not a change in the protocol, but in miner strategy. Since it is rational for miners to implement it (they make more money), it is expected that most miners do implement it. At least Eligius seems to have implemented it. As mentioned by Pieter in the comments, any miner using version 0.13 or above will mine using CPFP rules.

Which one should you use?

If you're the spender and want your transaction to confirm faster, use RBF. If you received a payment and are unable to convince the sender to up the fee, or the transaction is marked as non-replaceable, use CPFP.

Better yet, send your transaction with the proper fee the first time.

maservant
  • 1,021
  • 6
  • 8
  • As a user, though, which one should I prefer to use? Probably RBF since it has the fees of only 1 transaction instead of 2? CPFP is outsourceable, though, anyone can pay to get my transaction confirmed, including the person on the receiving end of the transaction. – morsecoder Nov 18 '16 at 15:53
  • Interestingly, you could do CPFP on the predecessor of a RBF transaction, which would send mixed signals to miners as to which version of the RBF transaction they should accept. – morsecoder Nov 18 '16 at 15:54
  • 1
    CPFP mining is implemented in Bitcoin Core 0.13.0 and later versions. Any miner using that software follows it. – Pieter Wuille Nov 18 '16 at 16:14
  • 2
    RBF is done by the spender. CPFP is used by the recipient. You are correct, CPFP uses twice the blockchain space and is therefore less efficient. – maservant Nov 18 '16 at 17:42
  • Also, not everyone can pay for your transaction's fees; only the recipient who can spend the output, except if you explicitly signed the transaction with the ANYONECANPAY flag. You can't use CPFP on the predecessor of a RBF transaction, as the R stands for Replace: the original transaction isn't in the memory pool anymore, and your CPFP transaction is therefore orphaned and non-replaceable. – maservant Nov 18 '16 at 18:52
  • 1
    Note that in the typical case where a change output is used, the sender is also a recipient and thus would also have the ability to use CPFP. – Nate Eldredge Nov 18 '16 at 19:22
  • Why isn't RBF a miner strategy, too? Can't a miner just choose the higher paying transaction from the mempool? – mikezter May 24 '18 at 07:40
  • @maservant: a sequence of MAX-1 indicates that a transaction is using locktime. For replaceability the sequence has to be MAX-2 or smaller. – Murch Dec 08 '22 at 19:48