Let's assume people got the same private key of 1 BTC amount(Unspent state) for somehow lucky. Let's call that wallet address is WALLET_A.

So people trying to send all the balance to their each own wallet address, like:

tx1:WALLET_A(input) -> Person_A_WALLET(output)
tx2:WALLET_A(input) -> Person_B_WALLET(output)
tx3:WALLET_A(input) -> Person_C_WALLET(output)

But we all knows only one transaction can be mined which is unspent state of WALLET_A for all 1 BTC balance.

  1. How's gonna the mempool handle when people generates transactions simultaneously?
  2. Will miners mine the first registered transaction in mempool? If any person pay a much higher fee, can it be mined instead of the old one?
  3. What happens if people compete by repeating infinitely resending their transaction through the -zapwallettxes option in Bitcoin Core?

2 Answers 2


There is no "the mempool". Each node has its own mempool. So in your example, each node would receive each of the transactions, possibly in a different order, and at different times. It is physically impossible for all three transactions to reach every single node at the exact same time.

If we assume that none of the transactions signal for RBF and all of them pay the same fee and it is sufficient (i.e. above the minimum relay fee), then every node will accept into its mempool the first transaction it sees. Due to network latency and physics, each node will probably accept a different transaction because they will arrive at slightly different times. So some nodes will accept tx1, some tx2, and some tx3.

Miners will then choose the transaction that they have in their mempool. If their node's mempool accepted tx1, then tx1 will be in their block. If tx2, then tx2, and if tx3, then tx3. It is purely whichever one arrived at their node first.

Now let's suppose the only thing different is the fees. Still no RBF, but everyone has paid a different and still sufficient fee. Then the same thing pretty much happens. The vast majority of full nodes use Bitcoin Core which does not implement full RBF. So a conflicting transaction that pays a higher fee will not be accepted. This is for anti-DoS and anti-spam reasons. In order for a transaction to be accepted as a replacement, the original must signal that it is replaceable.

If one of the transactions signals for RBF and one of the other two transactions pays a higher fee, then we have a more interesting scenario. For the sake of example, lets say that tx1 signals for RBF, and both tx2 and tx3 pay higher fees than tx1. Then nodes that accept tx1 will replace it with the first one that they see of tx2 or tx3.

So in this case, in the end, most nodes will end up with either tx2 or tx3. And the miners select from either tx2 or tx3, depending on what their node sees, which depends on which arrived first.

If tx1 again signals RBF but this time only tx2 has a higher fee (tx3 has a lower one, but still sufficient), then nodes that receive tx1 that then receive tx2 will accept tx2. Nodes that first received tx3 will reject tx1 and tx2 as double spends. The rest plays out as before with tx2 and tx3.

If tx1 and tx2 signal RBF, and tx3 has a higher fee than both, then ultimately most nodes will end up with tx3. Nodes that received either tx1 or tx2, and then received tx3, will replace with tx3. If tx2 has a higher fee than tx1, then nodes that received tx1 then tx2 will first replace with tx2. Once they see tx3, they will replace with tx3. Ultimately, most nodes will have tx3 so tx3 is most likely to be mined by miners.

If tx1 and tx2 signal RBF, but this time tx3 has a lower fee, then we could have a repeat of the first scenario, or a race between two of the transactions. If tx1 and tx2 have the same fee, then it will be a race between all 3 transactions as no transaction outbids the other so none of them can be replaced. If tx1 has a higher fee, then nodes that received tx2 will likely replace with tx1. And vice versa. In this case, it becomes a race between tx1 or tx2 and tx3. Nodes that received tx3 first will not replace it because it does not signal RBF.

Lastly, if all 3 transaction signal RBF, the transaction that is most likely to be mined becomes the one with the highest fee. Again, if all 3 have the same fee, then all 3 are eligible as in the first scenario. But if one pays a higher fee and can replace the others, then that transaction will become the one that is in most node's mempools will be the one that pays the higher fee.

If any transaction does not pay enough fee, then it doesn't get relayed and it becomes a race of the other transactions. If two transactions don't pay enough fee, then the one that does becomes the one that is mined.

So the transaction that gets mined depends on whether any signal RBF, which signal RBF, the transaction fees, and which transaction miners have.

What happens if people compete by repeating infinitely resending their transaction through the -zapwallettxes option in Bitcoin Core?

-zapwallettxes doesn't make a difference if the transactions pay enough fee. If the transactions don't signal RBF, it doesn't matter. -zapwallettxes only affects your local Bitcoin Core wallet (not even the node, it does not remove the transactions from your node's mempool). So doing this has no effect.

  • Super thanks for the explanation! Commented Mar 3, 2020 at 18:29
  • 1
    That's the kind of elaborate answer I keep coming back here for. Thank you.
    – thalisk
    Commented Mar 3, 2020 at 22:38

In addition to @AndrewChow's excellent and detailed answer, you should be aware that to the bitcoin network, there are no persons, just signed transactions. Whether conflicting transactions are signed by several people as in your example or by one person attempting to double spend doesn't matter. The protection mechanisms against double spending will keep all but one of these conflicting transactions from becoming permanent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.