please note I have made this question previously (link) and I was indicated to visit here.
I am writing a program using GoLang to mine bitcoins. It's part of my college conclusion project and likely won't be used to mine bitcoins since it's not gonna be efficient enough running on regular PC's (facing a race against those huge chinese mining pools). Though it's not originally intended for real usage, my college expects nothing less than a flawless piece of software to mine real bitcoins (in parallel).
So far, I have implemented quite an extensive code, therefore, you guys may assume I already have means to achieve:
- Get pending transactions to fill my block (from https://blockchain.info)
- Build the merkle tree over the transactions data retrieved
- Calculate a sha256 of a given data input (I also understand the concepts behind such hash functions)
I have organized my questions regarding this subject below:
Question 1) I can't precisely tell how to build a block header which would be appended to the block chain. I know it has fields like the root of our merkle tree (which I already know how to calculate) or a version field, but if I was to produce a block header as an array of bytes, how would I do it ? I'd like to see how to calculate each field we need to build the header and how our byte array (representing the header) would look like.
Any dummy data may be used for this example, my focus stays on understanding the process and the data structure.
Please, note I have already read this: https://bitcoin.org/en/developer-reference#block-headers
I have studied quite a lot regarding how the bitcoin protocol works to achieve the code I currently have, but I feel extremely limited on the information I can find online regarding the internal details of the bitcoin protocol:
Question 2) Is there any online technical information you guys would consider useful for me to read regarding the headers subject and/or anything else in bitcoin? Keep in mid that I still have quite some code to write, therefore, I'm taking all the information I can get : )