May 5, 2024

How Bitcoin Solves the Double Spending Problem

The double spending problem describes the difficulty of controlling or preventing the creation of duplicates.digital content, especially digitalof money. Traditional financial systems solve this problem by using trusted third parties, such as banks and payment processors, and relying on governments to control the activities of these third parties.

We wrote more about what the double-spending problem is here.

Bitcoin was preceded by several other attemptscreation of digital currencies, but none of them solved the problem of double spending without the use of trusted authorities. Satoshi Nakamoto called the presence of this trusted third party a critical flaw in each of Bitcoin's predecessors. One of the main innovations of Bitcoin consisted in a "trustless" solution to the problem of double spending.

Bitcoin uses to record all transactions innetwork distributed ledger. This ledger is in the form of a blockchain, a large database of time-stamped bundles of transactions called blocks.

Distributed ledger

Blockchain is a distributed ledger of records,which is stored independently by tens of thousands of computers scattered around the world called nodes. Each node stores the entire history of transactions and all nodes together update the state of the registry, adding new blocks of transactions to it as they are created.

"Nodes can leave the network and reconnect to it at any time, taking the longest version of the chain to recover the missing transaction history,"
- Satoshi Nakamoto, from the introduction to the Bitcoin Whitepaper. October 31, 2008.

Since each node independently stores its owna copy of the blockchain, they must have a way to reconcile the valid state of the blockchain and the ownership of each bitcoin. The Bitcoin network rules provide an objective method for determining the valid state of the blockchain.

Since each node contains a complete historybitcoin transactions, they can verify that no coin has been spent twice and that they have all been issued according to the Bitcoin issuance schedule. A user with their own node can independently verify their ownership of bitcoins without relying on any third party.

Time stamps

The blockchain consists of blocks, each of whichprovided with a time stamp. Thus, the blocks are organized in a strictly linear and chronological order. In the event that two transactions try to spend the same bitcoin, this design allows all nodes to objectively determine which of these transactions is valid. In the Bitcoin network, unlike traditional payment systems, there can be no disagreement about which transactions are considered valid and which are not. Accordingly, there is no need for authorities or trusted arbitrators to resolve disputes.

If a transaction is included in a block and recorded on the blockchain, it is objectively valid. Any future transaction trying to spend the same bitcoins will be rejected by all nodes on the network.

Confirmation

Bitcoin transactions are not immutable immediately after they are broadcast to the network. They are first added to the mempool, the pending transactions list.

Mempool transactions can be double-spent or overwritten, so you shouldn't rely on them.

After being added to the block, the transaction is considered"Confirmed". Each block added to the blockchain after a block containing a transaction adds another confirmation to that transaction. Although a bitcoin transaction is considered completed as soon as it receives the first confirmation, transactions with six or more confirmations are usually considered final.

Reorganizations

Most Bitcoin users preferwait for six confirmations, because the most recent block can be removed from the blockchain if it is no longer part of its longest branch. Such a block is called orphan, and all transactions from it are returned to the mempool and must wait for confirmation again. This is a rare occurrence called reorganization.

Reorganizations may to some extentactualize the problem of double spending. For example, let's imagine that Alice creates a transaction in which she sends Bob 1 BTC. While this transaction sits in the mempool waiting for confirmation, Alice creates another transaction sending the same 1 BTC to Charlie. Then transaction Alice —> Bob joins the block. However, by accident or Alice's malicious intent, another miner in a short period of time mines two blocks, one of which includes Alice's transaction —> Charlie. Bob's transaction will be unconfirmed, but Charlie's transaction will be confirmed.

To avoid the risks associated withreorganizations, Bitcoin users typically wait 2-6 confirmations before considering a transaction final. The likelihood that six blocks will undergo reorganization in the Bitcoin blockchain is extremely small. In the example above, if Bob were waiting for six confirmations, he would see that his transaction came in, but then quickly turned out to be unconfirmed again. And he would have realized that Alice had not yet received payment.

 

</p>