I was wondering how a block encodes its set of transactions. I know a Merkle Tree is generated, and that it encodes a Hashed version of the transactions. But is the Merkle Tree included in the Block that gets sent to the other nodes for validation? Is there a list of transactions that it also sent?
In my understanding, when a Node wishes to 'Mine', they will:
- Generate a new block
- Create a coinbase transaction
- Gather a subset of the other incomplete transactions (those that have not yet been put into a block) from its copy of the blockchain.
- Generate a Merkle Tree using the transactions from steps 2 & 3
- Increment a Nonce repeatedly until the Hash of the
<Previous Hash, Nonce, Transactions from 4>begin with a certain number of 0s.
It seems that to validate each individual transaction (to ensure money is not double-spent), it would be good to include a list of transactions. But to check that the proof-of-work has actually been completed, the other nodes need the merkle tree to quickly hash.
It is very possible that there is also a way to obtain the list of transactions from a merkle tree, but I just don't understand what that process looks like.
P.S. I am building my own Python demo implementation of a blockchain currency, hence the more-theoretical/less-practical questions.