How Bitcoin Solves the Double Spend Problem
Table of Contents
- Bitcoin uses a distributed ledger to publically record all transactions on the network.
- A distributed ledger allows anyone to view the entire history of each coin, and prove that no coin was spent twice.
- A Proof-of-Work based blockchain provides an objective way for members of the network to determine the validity and order of transactions.
- Bitcoin transactions that are not recorded on the blockchain are not absolutely safe from double-spending.
The Double Spend Problem
The Double Spend Problem describes the difficulty of controlling or preventing the duplication of digital content, especially with regards to digital money. Traditional financial systems solve this problem by employing trusting third parties, such as banks and payment processors, and relying on governments to keep the trusted third parties honest.
Several attempts at digital currencies preceded Bitcoin, but none were able to solve the Double Spend Problem without a trusted authority. Satoshi Nakamoto cited this trusted authority as the critical flaw in each of Bitcoin’s predecessors. Solving the Double Spend Problem in a trustless manner was one of Bitcoin’s greatest innovations.
How Bitcoin Solves the Double Spend Problem
Bitcoin uses a distributed ledger to record all transactions in the network. This ledger takes the form of a blockchain, a large database. This database is composed of time stamped batches of transactions, called blocks.
The Distributed Ledger
The blockchain is a distributed ledger, and is stored independently by tens of thousands of computers, called nodes, across the world. Each node stores the entire history of transactions, and all nodes collaboratively update each other with new transactions and blocks as they are produced.
Since each node independently stores their copy of the blockchain, there must be a way for nodes to agree on the valid state of the blockchain and the ownership of each bitcoin. The rules of the Bitcoin network specify an objective method for determining the valid instance of the blockchain.
Because each node maintains a full history of Bitcoin transactions, they can verify that no coin was double spent, and that all coins were minted in accordance with Bitcoin’s emission schedule. A user who runs a node is able to verify their ownership of bitcoin without relying on any third party.
A blockchain is composed of blocks, and each block is time stamped. Thus, blocks are strictly linear and chronological. In case two transactions attempt to double spend the same bitcoin, this design allows all nodes to objectively decide which of the two transactions is valid. On the Bitcoin network, unlike with traditional payment systems, there can be no disputes over which transactions are valid and which are not. Thus, there is no need for authorities or trusted arbitrators to resolve disputes.
If a transaction is included in a block in the blockchain, it is objectively valid. Any future transaction attempting to double spend the same bitcoin will be rejected by all nodes on the Bitcoin network.
Bitcoin transactions are considered final and immutable once settled. However, a Bitcoin transaction is not immutable immediately after it is broadcast to the network. First, it is added to the mempool, a list of pending transactions.
Once a transaction is added to a block it is considered “confirmed”. Each block that comes after the block containing a transaction is counted as a confirmation for that transaction. While a Bitcoin transaction is official once it has a single confirmation, it is generally not considered final until it has achieved six or more confirmations.
Most Bitcoin users wait for six confirmations because the most recent block can be removed from the blockchain if it is no longer part of the longest chain. In this case, all transactions included in the removed block, called an orphan block, are returned to the mempool and must await confirmation again. This is called a reorganization, and it is a rare occurrence.
Reorganizations can resurrect the Double Spend Problem. For example, imagine Alice creates a transaction sending Bob 1 BTC. While this transaction is in the mempool awaiting confirmation, Alice creates another transaction sending the same 1 BTC to Charlie. Alice’s transaction to Bob is then included in a block. However, by chance, or by Alice’s malicious intent, a different miner mines two blocks in a short timespan, one of which included Alice’s transaction to Charlie. Bob’s transaction would be unconfirmed and Charlie’s transaction would be confirmed.
In order to avoid the risks caused by reorganizations, Bitcoin users usually wait for 2-6 confirmations to consider a transaction final. The likelihood that six blocks will be reorganized out of the Bitcoin blockchain is extremely miniscule. In the example above, if Bob waited for six confirmations, he would have seen his transaction arrive, but then be quickly unconfirmed. He would safely know that Alice had not yet paid him.