9

I'm trying my best to understand how bitcoin works and while I've grasped the basics, there's a lingering question:

What's to stop me from spending my bitcoin multiple times during a confirmation period?

Let's say I have a single address that owns 1 BTC. I go to a cafe and use the coin (assume the whole coin for simplicity) to buy a cup of coffee. The transaction is broadcast across the network. The miners then compete with one another to include my transaction in a verified multi-transaction block that will be submitted to the block chain. That process takes around ten minutes. During that ten minute period, I walk to the gas station and reuse my 1 BTC to buy some gas. How could the gas station know that I had already used my 1 BTC to buy coffee a few minutes earlier and my actual balance is zero, since the coffee transaction isn't yet part of the official block chain?

In the end, one of these two transactions will most certainly get rejected by the Bitcoin network but either the cafe or the gas station will get stiffed, correct? It seems the only solution would be for the cafe to wait ten minutes for the confirmation prior to giving me my coffee -- but that's obviously not a practical approach.

What am I missing?

1
  • 2
    Its called double spending. I dont know the details myself, but maybe the wikipedia page can shed some light on it for you
    – Mathias711
    Apr 26, 2014 at 16:08

1 Answer 1

10

This is definitely a concern, and is the reason why Bitcoin users are encouraged to wait for several confirmations before accepting a transaction and delivering goods.

It's not quite as easy as you suggest, though. When you made your transaction at the cafe, it was, as you say, broadcast across the network. Barring connectivity problems, every node on the network gets a copy almost immediately. (They don't need to wait for it to be included in a block.) In particular, the gas station gets a copy. So when you try to spend the same coin with them, they know it has already been spent and will reject your transaction.

To make this work, you have to ensure that the victim is not aware of the other transaction. One approach is that the first transaction, rather than buying some other goods, simply sends the coin back to another address you control. You don't broadcast it on the network; rather, you give it directly to a miner, with the understanding that they should include it in their next block, rather than the conflicting transaction that sends the coin to the gas station. In a variant called a Finney attack, the miner (possibly yourself) has already mined a block with the transaction that sends the coin to you, but they wait to submit it to the network until you have bought your gas.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.