I'm trying to understand how bitcoin works technically. I understand the blockchain, digital signatures etc ... I'm more interested in what happens to a transaction once it's "created".
Suppose Bitcoin only contains one transaction per block (to simplify). Basically:
- someone create a transaction using its wallet
- this transaction must be validated (check inputs, digital signature etc ...
- a proof of work must be computed on the block hash
- the the block is added to the blockchain
So I know miners are responsible to come with the proof of work. My questions are:
- how does one node broadcast a transaction to miners ? Is it part of the P2P protocol ?
- does miner check the transaction (digital signature, available inputs etc ...) ?
- does miner directly submit blocks to the blockchain ?
This part is still confusing to me any help pointers to article would be great :)
In a P2P network, nodes are not connected to every other nodes. So let's say the network looks like this:
node1 <-> node2 <-> node3 (1 and 2 are directly connected and 2 and 3 are directly connected. 1 and 3 are connected through 2)
node1 wants to broadcast a transaction for validation, it will only broadcast it to
node2 can eventually broadcast it to
node3 to give him the chance to validate
But, because we are in an untrusted network, nothing prevent
node2 to validate the transaction without never transmitting it to
node3 and thus, keeping mining fees for himself.
We could also imagine that
node1 never broadcast it's unconfirmed transaction, do the mining work himself and only broadcast the validated block so it get "merged" into the blockchain.
How does Bitcoin deal with this situation ?