2
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 :)
Update:
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)
When node1 wants to broadcast a transaction for validation, it will only broadcast it to node2. Then node2 can eventually broadcast it to node3 to give him the chance to validate node1's transaction.
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 ?
Great thank you for your explanation that's great and make things clear for me :) – rmonjo – 2017-08-26T16:21:36.590
Regarding your final sentence, won't it be possible for the miner to fill up the blockchain with their own nonsense transactions? Sure they miss fees but they don't have to share their made-up transactions and risk wasting computing time. – jiggunjer – 2017-09-23T04:52:58.640
@jiggunjer: A miner can put any valid transactions they want into their own blocks, and sure, they could fill their blocks with their own transactions. I can't see how this would benefit them. I don't understand what you mean about wasting computing time; can you explain what you have in mind? – Nate Eldredge – 2017-09-23T13:23:37.267
The way I see it completing a block doesn't mean it gets into the blockchain if another block includes a transaction it used. By just mining your own you can 1) avoid long waiting times for a low fee transaction. 2) Your blocks won't ever be rejected by the blockchain. – jiggunjer – 2017-09-23T13:37:50.287
Oh, I see what you're saying. But that's not a real concern. Blocks are strictly ordered in the blockchain since each contains the hash of the previous block. So when you go to mine a block, you know exactly what blocks, and hence what transactions, are in the chain up to that point, and you can avoid with certainty including any transactions that are already there. If another block, later in the chain, tries to include a transaction already in your block, they get rejected, not you. – Nate Eldredge – 2017-09-23T13:42:17.790
It could be that two blocks mined simultaneously (both with the same block as their previous) contain the same transaction. But in such a case, only one block can become part of the chain, simply because of the strict ordering requirement, and this would be true even if they didn't contain any of the same transactions. So avoiding other people's transactions doesn't give any benefit here. – Nate Eldredge – 2017-09-23T13:44:28.740