0
I'm going to screw up a lot of the terminology here. I'm trying to understand the Bitcoin algortihm and wanted to use this JS miner -- https://github.com/howardchung/jsminer . Specifically, I'm trying to understand how to build the data that someone attempts to hash. They attempt to do this in the JS miner by the following
var header = version + prevhash + merkle_root + ntime + nbits + '00000000' + '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000';
curr_block.data = header;
I'm following most of this, using the Bitcoin wiki as a reference, but what I can't figure out at all is what are these last two numerical constants -- '00000000' and the bigger one beginning with "0000008". I have seen these come up in other examples but I can't figure out why these are needed or if these are hard-coded values in the JS miner that shouldn't be there in real life. Any help is appreciated.
Yeah I pulled this fragment out of the section of the code where they're doing that pre-processing. Since the string beginning with "0000008" is padding, can it be anything? Does it have to be that specific sequence? – Dave – 2018-03-13T00:45:07.613
Yes. The padding is fixed and must be the same for all blocks. It should really be calculated dynamically by the SHA-256 function instead of something that you are hard coding. – Andrew Chow – 2018-03-13T01:47:24.693
To clarify your "Yes", do you mean "Yes it can be anything" or "yes it must be that specific sequence"? – Dave – 2018-03-13T13:51:14.003
Yes, it must be that specific sequence. – Andrew Chow – 2018-03-13T14:38:15.033