Is it possible for both to actually get confirmed? If the answer is yes, then what happens to the fee of CPFP if the double-spend scaled through and CPFP got droppedlater?
There seem to be a misunderstanding on how RBF/CPFP work and how the fee is paid due this question.
Let me use your example scenario to explain;
From the sender side:
- Let's label the sender's original transaction as "Txn A1".
- Then "Txn A2" is his replacement transaction that aims to be included to a block instead of A1.
Since both are spending the same input, only one of them can be accepted by each individual node.
Nodes select based on a few factors like RBF policy of the particular node, which one it seen first, was the other txn already dropped (
since you mentioned "very long time"), etc.
Pools and Solo miners have their own mempool as well so they're also subjected to that, unless their method of acquiring transactions is unique.
Then, from the receiver side:
- Aside from Txn A1, there's "Txn B" that spends Txn A1's output to bump its effective fee rate.
Since he managed to create a CPFP despite the sender already replaced A1 at his end, let's assume that his node isn't aware of A2.
And since it's trying to spend A1's output, it will only get relayed by nodes that has Txn A1.
Now it's a "
race" on which can get to a miner that will mine the next block first.
With those in mind, there're two scenarios:
- If Txn A1 got confirmed, his CPFP Txn B can also get confirmed.
- But if Txn A2 got confirmed, Txn B will be dropped by nodes that has the latest block because they'll see that its parent Txn A1 is now invalid at that point.
As for the fee, it's not paid up front to the miner,
It's just the difference between the inputs' and outputs' total amount, they can get it when they included the transaction to their block.