Let's say parties A and B both submit a transaction to the blockchain with a different version of what happened. Party A submits a transaction saying Party B gave him 3 BTC and Party B submits a transaction saying he gave Party A only 1 BTC. How does the network decide which one to put in the next block?

Don't you have to trust a third party? A wallet or some kind of transaction application? How does that work?


4 Answers 4


Each node in the Bitcoin network tracks every single piece of bitcoin. This body is called the "Unspent Transaction Output Set" or UTXO Set for short. Every UTXO is uniquely identifiable and can only be spent once. If two transactions try to spend the same UTXO, only one of the two transactions can become part of the best chain. Including both transactions into one block would make the block invalid as the second transaction spends funds that no longer exist. So, as pinhead already said, if someone attempts a so called , the two unconfirmed transactions are only competing in the network until one of the two gets confirmed. The other is evicted from the queue, because the funds it is attempting to spend are no longer spendable. Even before, most full nodes will only relay the first of two competing transactions they've seen.

"Party A submits a transaction saying Party B gave him 3 BTC and Party B submits a transaction saying he gave Party A only 1 BTC."

There is another practical issue with your scenario here: most UTXO require the spender to authenticate themselves as the owner by providing a cryptographic signature corresponding to the locking script the funds were originally received to. As Party B is sending to A, in most cases only Party B would be privy to the necessary private key to provide such a signature. Unless Party A somehow got access to Party B's key material, they would simply be unable to create a valid transaction spending Party B's funds. Without a valid signature, Party A's transaction would simply be discarded by any other network participant as invalid.


If two transactions spend the same coin (utxo) only one is allowed in each node's mempool. That may not be the tx that gets actually confirmed by a miner though and inserted into a block. In that case, the confirmed transaction "evicts" the double-spend from the mempool.

It is possible that two competing miners each mine different blocks at the same height with conflicting transactions. This is a split blockchain and a split network, but it's not a problem. Eventually one of these blockchain branches will be extended by an additional block. The chain with the most accumulated proof of work is the only one that matters, and the other branch (with the conflicting TX) will again be wiped out.

If you are running your own full node you don't need to trust any other source of truth. If you are a vendor accepting bitcoin, this is why "waiting six confirmations" is generally accepted as best practice.


Let’s say you’re making purchases from Amazon.

Instead of using your actual name, your purchase is recorded without any identifying information using a unique “digital signature”, sort of like a username.

Blocks store information that distinguishes them from other blocks. Much like you and I have names to distinguish us from one another, each block stores a unique code called a “hash” that allows us to tell it apart from every other block. Hashes are cryptographic codes created by special algorithms. Let’s say you splurge purchased on Amazon, but while it’s in transit, you decide you just can’t resist and need a second one. Even though the details of your new transaction would look nearly identical to your earlier purchase, we can still tell the blocks apart because of their unique codes.

Then again Double-spending is a potential flaw in a digital cash scam in which the same single digital token can unfortunately be spent more than once. Unlike physical cash, a digital token consists of a digital file that can be duplicated and/or falsified.


The network doesn't have to. (In reality it does, but it doesn't have to)

The miner who finds the next block does have to choose one, if it receives both. We don't really care which one the miner chooses. If it's the one Party B doesn't want, well, that's Party B's fault for creating two transactions in the first place.

The miner has to choose one, though, because otherwise its block is invalid and it doesn't get paid. It will probably choose the one with the highest transaction fee or the one it received first.

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.