I'm currently reading "Mastering Bitcoin" (i haven't finished it tho, but i don't see my answer and it bother me so I prefer asking it here) and there's something i don't understand. So from what I understand the "valid" blockchain is the one which has the most blocks in it. But what happens if :
- a "hacker" is lucky with the hash function and manage to add a "wrong" block to the blockchain, in which, let's say that someone gives him 1BTC (even if there is no way to make a false transaction to receive 1BTC, he will at least have the bitcoins from mining a block)
- Then the blochain of the "hacker" will have 1 block more than the others, thus it should be, at least for a few minutes, the "valid" blockchain
But what happens if he buy something with this 1BTC during those few minutes ? If for example, he buys a coffee, or some real items ? What prevents him from doing that ?
Is there a rule that makes that you can spend bitcoins from a transaction output only if the transaction is "old enough" (which mean that 3 or 4 blocks has been added after the block that contains the transaction) ?
If so, doesn't it make bitcoin transactions slow to process ? I already know that a transaction can be validated by a full node client and that you don't need to wait 10 minutes for the block to be in the blockchain, but if you need 30 minutes to be able to spend the money, doesn't it make transactions slow ?
Thank you in advance
PS : By the way i'm sorry if the term "short fork" is not the right expression but i didn't know how to call it