I'm really new to the whole concept of blockchain.
I do understand how consensus protects from changing past blocks and allows to keep a clear and valid blockchain, but I am having a hard time trying to wrap my head around fake transactions.
Let me explain. As I understand it :
- Nodes in the network produce transactions.
- They are repeated all across the network
- At the same time, some nodes try to mine a block.
- When someone resolves the hash, they can create their block.
- The block is accepted by everybody on the network as they can immediately check Proof of Work (via the hash + the data)
Ok so this basically means that everybody follows the consensus (otherwise, everything said by anybody else would be garbage to a Node, and the other way round : we would have an isolated node). But how do they know that the transactions themselves written in the new block are correct ?
For instance, let A and B be two accounts. What prevents a node from randomly saying "B gave n bitcoins to A", and that information being completely false ? B would obviously benefit from doing that.
Maybe I don't understand how consensus is enforced in nodes themselves as well... is everybody running the same "program" ? Is it something in the protocol itself ? Does the consensus "know" when a transaction cannot be made for some reason ?
Thanks for your help