Let's say miner Moe mines a block taht is accepted by the network. Moe presumably receives some Bitcoins in his wallet for this. So let's say Moe "spends" that Bitcoin by buying some anti-poking goggles from Curly, even though his newly mined block is at the top of the chain and has no blocks on top of it. Curly sends the goggles to Moe via FedEx. Then another miner Larry mines a longer block and that replaces the original one Moe mined. So now Larry has some Bitcoins. So does the transaction between Moe and Curly disappear and Curly is left without a pair of goggles and with no Bitcoin?
1 Answer
Yes, Moe's transactions (both the coin creation one and the payment transaction) become invalid if Larry mines a conflicting blockchain that has more work (almost the same as longest, but not quite) than Moe's blockchain. So Curly would be without payment and Moe would have gotten himself a free pair of goggles.
Now if Moe and Larry were the same person this would be a Finney attack where Moe/Larry are intentionally defrauding Curly.
Of course there are built in safeguards to protect against this. Firstly, Moe cannot spend newly mined Bitcoins until 100 blocks have been mined on top of his block. But even if he did wait 100 blocks before transacting, Curly could still be defrauded.
The solution to this is for Curly to wait for the payment transaction to get a few confirmations. By waiting for confirmations, the amount of hashrate that Larry would need in order to change the blockchain to not include Moe's transaction greatly increases. After a few blocks, it is basically infeasible and thus it can be said that the transaction is permanent and cannot disappear.
-
"But even if he did wait 100 blocks before transacting, Curly could still be defrauded." -- yes, but that would just be a regular double spend attempt. A reorganization of 100 blocks is unreasonable. After that much POW you can be assured that the block that mined the coins will stay in the chain.– JestinCommented Jan 2, 2018 at 21:49
-
"Firstly, Moe cannot spend newly mined Bitcoins until 100 blocks have been mined on top of his block" -- what exactly prevents this? If Moe has hte Bitcoin adn Curly chooses to accept it (after being poorly advised not to wait for 100 blocks), what safeguard is there?– DaveCommented Jan 3, 2018 at 17:25
-
It is a consensus rule that prevents it. The transaction will be invalid. I suppose it doesn't matter if Curly accepts it even though it is unconfirmed.– Ava Chow ♦Commented Jan 3, 2018 at 18:08
-
But in my question Curly has accepted the Bitcoin before Larry has mined a longer block. Or can this siutation never happen, since you mention Moe cannot spend newly mined Bitcoins until 100 blocks have been mined (which I'm guessing is part of the Bitcoin software)?– DaveCommented Jan 3, 2018 at 20:53
-