# Double spending problem in Bitcoin

Suppose Alice sent 2 bitcoins to Bob, Bob ships the product to Alice, then Alice sends 2 bitcoins to herself. Why is this a problem ? If both the transactions are approved then also Bob gets his 2 bitcoins (irrespective of the order of both the transactions). If Alice has no bitcoins left after sending them to Bob, then also no harm is done.

Suppose Alice sent 2 bitcoins to Bob, Bob ships the product to Alice, then Alice sends 2 bitcoins to herself. Why is this a problem?

If Alice only had 2 bitcoins to start, then she will not be able to spend them twice. After the first spend (paying Bob) is confirmed, the network will not accept a second payment that spends those same coins again. From the network's point of view, those 2 coins are now locked to an address that Bob controls, not Alice.

Just imagine you had a \$10 bill in your pocket, and you went to a food court and used it to buy \$10 worth of pizza. After eating the pizza, you decide you need a drink, but you don't have any more money. Would you be able to buy the drink by somehow 'doublespending' the \$10 bill you had earlier? Of course not, it is obvious you don't own that \$10 bill anymore! The same reasoning applies to bitcoin double spends: you simply don't have any more coins left to spend.

If both the transactions are approved then also Bob gets his 2 bitcoins (irrespective of the order of both the transactions). If Alice has no bitcoins left after sending them to Bob, then also no harm is done.

You say 'no harm is done' by allowing Alice to invent bitcoins out of thin air, but that is far from true! If Alice could create endless coins, then all other coins would slowly (or maybe not so slowly) become worthless. Why would anyone pay for something, that any person (Alice) can just create without cost?

• Why both the transactions contain the same 2 bitcoins? I mean, when is it decided which unspent outputs will be used in a transaction? Jan 28, 2020 at 17:43
• You said ‘Alice has no btc left after sending to Bob, and the question is titled ‘double spending...’, so I assumed that was the case. If the two transactions spend different coins, then it’d be no problem. Coin selection is usually done automatically by the wallet, but sometimes can be specified by the user, it depends on the software. Jan 28, 2020 at 19:29

If Alice has no bitcoins left after sending them to Bob, then also no harm is done.

You're essentially saying here that if the double-spend problem is solved, then no harm is done. Obviously.

The point is that without a solution to the double-spend problem, Alice could send her 2 BTC to Bob AND also have 2 BTC left herself. This would obviously make Bitcoin useless, as it'd allow people to print money out of nowhere, devaluing everyone else's coins.

• Why both the transactions contain the same 2 bitcoins? I mean, when is it decided which unspent outputs will be used in a transaction? Jan 28, 2020 at 17:43
• The sender software determines which coins to use, and it of course will never pick the same ones twice. But with modified software you can construct conflicting transactions that spend the same coins - and the network needs a way to prevent that. Jan 28, 2020 at 17:44