Author

Topic: I feel a bit confused on how Bitcoin solves the double-spending problem (Read 1433 times)

newbie
Activity: 2
Merit: 0
1. When the miner checks the transaction from Alice to Dan, will the miner actually reject this transaction (because the miner has checked the transaction from Alice to Bob before and recorded the bitcoin deduction in Alice's address) ?
Yes. When checking the validity of a particular transaction, all transactions in the block the miner is working on are taken into account. Conflicting transactions are invalid and rejected. Conversely, a chain of dependent transactions (Alice pays Bob, Bob pays Dan) within the same block is perfectly valid.

2. If, somehow, a bad block is included in the block chain, will other miners be able to pull it out later ? By saying a bad block, I meant, for example, the block contains some invalid transactions.
It will never be included in the blockchain in the first place. All other nodes will reject it immediately.

That answered my questions. Thanks.
legendary
Activity: 3528
Merit: 4945
- snip -
I think there is a couple of places I don't quite understand:
- snip -

Have you read this yet?

https://bitcoin.org/bitcoin.pdf

If not, then you are making assumptions about how you think bitcoin works, and your assumptions are almost certain to be wrong.  This will just lead you to more confusion.
legendary
Activity: 4551
Merit: 3445
Vile Vixen and Miss Bitcointalk 2021-2023
1. When the miner checks the transaction from Alice to Dan, will the miner actually reject this transaction (because the miner has checked the transaction from Alice to Bob before and recorded the bitcoin deduction in Alice's address) ?
Yes. When checking the validity of a particular transaction, all transactions in the block the miner is working on are taken into account. Conflicting transactions are invalid and rejected. Conversely, a chain of dependent transactions (Alice pays Bob, Bob pays Dan) within the same block is perfectly valid.

2. If, somehow, a bad block is included in the block chain, will other miners be able to pull it out later ? By saying a bad block, I meant, for example, the block contains some invalid transactions.
It will never be included in the blockchain in the first place. All other nodes will reject it immediately.
legendary
Activity: 1890
Merit: 1089
Ian Knowles - CIYAM Lead Developer
To understand things a little better you need to understand that transactions involve UTXOs (unspent transaction outputs) from previous transactions (including "coinbase" transactions when a miner gets rewarded) and that these cannot be "split" (thus the need for "change addresses").

So when you receive a tx you need to check that *all* the UTXOs it is using "have not been used before". Now as this is done one tx at a time the 2nd tx the node sees will be rejected (note that it can *never* receive "two at once" as they are effectively serialised).

Of course this is just the low-level mechanism to prevent an *actual* double spend - the "double-spending problem" is usually referring to *double spend attempts* (which can successfully get you goods or services if vendors don't wait for confirmations). The solution to this is the "blockchain concept" itself (and the "proof of work" algorithm at its core in Bitcoin).
newbie
Activity: 2
Merit: 0
Say Alice has 5BTC in one of her bitcoin address.

She creates two transactions to Bob and Dan at the same time, each of 5BTC from the same address, i.e. she tries to double-spend.

Because these two transactions are created at the same time, they are very likely to be collected in the same block that some miners are working on. Suppose one miner collects these two transactions. He checks the validity of the transactions. Assume he checks the transaction from Alice to Bob first. He finds that it is a valid transaction. But at this time, the block hasn't been put into the block chain. Therefore Alice's address's information hasn't been updated (there should still be 5BTC in the address). Then the miner goes on to check the transaction from Alice to Dan. He should find that it is also valid. Assume this miner is the first one to find the proof of work for this block. He will then put the block into the block chain. And in that way Alice has spent the same 5BTC twice.

I must got something wrong somewhere.

I think there is a couple of places I don't quite understand:

1. When the miner checks the transaction from Alice to Dan, will the miner actually reject this transaction (because the miner has checked the transaction from Alice to Bob before and recorded the bitcoin deduction in Alice's address) ?

2. If, somehow, a bad block is included in the block chain, will other miners be able to pull it out later ? By saying a bad block, I meant, for example, the block contains some invalid transactions.

Thanks for help.
Jump to: