Bitzuma

Bitcoin from Scratch: Double Spending

By Rich Apodaca | Updated

Transactions, digital signatures, and chains of ownership all protect users from counterfeiting. However, these features alone can’t protect users from receiving a coin that has already been spent. This form of fraud is known as double spending.

This post is part of the extended series Bitcoin from Scratch.

Double spending occurs when a payer gives the same coin to two or more recipients. At the transaction level, a double spend happens when two or more inputs reference the same output. If left unchecked, double spending enables the uncontrolled creation of new money.

SVG Image
Double Spending. Chuck’s payment to Alice (TXID‑942) cheats her by paying with a previously spent coin (201‑A). Even with a valid chain of ownership, Alice is unaware of Chuck’s previous payment to Bob with the same coin (TXID‑242). Double spending occurs whenever two transaction inputs point to the same output.

Simply trusting a payee does not solve the double spending problem. For example, a coin may have been double spent early in its chain of ownership. Each new recipient passes the bogus coin to a new owner, unaware of its shady history. The fraud would only be detected by a recipient who happens to run across an intersecting chain of ownership.

SVG Image
Double Spending by Association. Alice and Bob separately spend a double spent coin received from Chuck (201-A, left). Each recipient remains unaware of the other’s payment, passing the double-spent coin to the next user.

A related situation arises in physical cash systems when the owner of a metal coin or bank note copies it, then uses the copies to make payments. However, the double spending problem faced by electronic cash systems is unique in that physical tokens can never be exactly replicated. A reference to a transaction output, in contrast, can be copied with 100% fidelity. Double spending allows digital tokens to be spent many times without ever calling the chain of ownership into question.

If left unchecked, double spending erodes buying power for the entire user community. As double spenders conjure value into existence without restriction, the money supply soars. Unconstrained money growth reduces the value of all coins, even those that aren’t double spent. Eventually users flee for more secure stores of value. Building an electronic cash system that can be used in the real world requires a practical solution to the double spending problem.