Some Technology: What is Double-Spending?
What happens if someone wants to spend the same bitcoins twice? What if he publishes two transactions almost simultaneously in the Bitcoin system that refer to the same bitcoins? The already described procedure of a transaction prevents the double-spending attempt of bitcoins, because only one transaction of the same bitcoins will be included in the blockchain. This is an elementary feature of the Bitcoin system.
Each intended transaction is transmitted by the system – more specifically by the sender wallet – to all computers with routing functions (nodes). The nodes verify the respective transaction and push it into the so-called mempool. A mempool is a digital place where all verified transactions are located, ready to be collected by the miners.
In the mempool, the miners use those verified transactions to integrate them into newly created blocks. Afterwards, they encrypt the latter and attach them to the blockchain. However, different miners choose different transactions. Thus, it may occur that different miners coincidentally integrate one of the two transactions that refer to the same bitcoins in their block simultaneously and find a valid hash for it. A hash is a code, consisting of a series of letters and numbers. The hash is the code that miners search for in order to create a new block.
A Junction in the Blockchain – A Rare Case
Both miners refer to the same block of the blockchain. In this rare case both new blocks are attached to that block. This creates a junction in the blockchain, a so-called fork. The Bitcoin algorithm determines that the blockchain is always continued at the longest end. However, now there are two new chains of the same short length.
Therefore, some of the miners will mine their next block for one annex of the fork and the others will mine their next block for the other annex. As a result, it is still to be revealed which of the two chains grows faster. As soon as one them has one block more than the other, all miners will concentrate on this chain again. In that case, the valid transactions in the unsupported block will go back to the mempool to be integrated into the blockchain at a later point.
Bitcoin is Tamper-Resistant
In exceptional cases, it can also happen that several blocks are attached to both annexes until one of the two chains is clearly longer. Accordingly, the valid transactions from the other blocks then move back to the mempool. If the recipient of the bitcoins waits six newly created blocks – which takes about an hour – he can be quite sure that a transaction was successful.
For a transaction to be integrated in the blockchain and considered to be processed, it must be included in a valid block. A valid block must contain a proof of execution – that is, a proof of work. The blockchain consists of blocks linked together and is therefore tamper-resistant.
Antonopoulos, A. M. (2017). Mastering Bitcoin: Programming the Open Blockchain (2nd ed.). Sebastopol: O’Reilly Media.
Antonopoulos, A. M. (2015). 51% Bitcoin Attack. Retrieved January 25, 2019, from https://www.youtube.com/watch?v=ncPyMUfNyVM
Narayanan, A., Bonneau, J., Felten, E., Miller, A., & Goldfeder, S. (2016). Bitcoin and Cryptocurrency Technologies: A Comprehensive Introduction. Princeton, New Jersey: Princeton University Press.