While trying to understand the mining process and checking in python..... i am puzzled with which info from/to pool are in Little Endian, which one needs reversing in building the block header + hashing and which one not. ??
For example ... Let's start with connecting to solo.ckpool.org response to mining.authorize gives me ..... job_id,prevhash,coinb1,coinb2,merkle_branch,version,nbits,ntime,clean_jobs =
{'id': None, 'method': 'mining.notify', 'params': ['59bc8dfc0000029f',
'0eba48f47bc0ab4bb35b230849868bf1d79aeb19006eed460000000000000000',
'01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff35039a6807000404d5bc5904fc873d140c',
'0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff03c4626c4e000000001976a914fc6123f4bfd3a840b4387ab90e9801e98fb17cf888acb1caca00000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edab3b87f3963e55a23f3cea5e4435bf6637328fd5e329bb8fdac7d31c3a01d26200000000',
['c251d18568d2cdb07c376d5f3304a2161e3d09d289d1a7e53737199171d73ae6',
'4f9bcac3ec00fc8238db04b7758a1b673bdf38b93e48159678b60b51517dd563',
'2aadad2c9c8e6df5c71264524b090cdf89830f12949527f7872c243bc1dc552c',
'8c5edf39c0d85c9853308eef3ce6f9b71c8d6584ca4120d411bc75987bb2f254',
'48751c2ae0ddc05f5d504a3d6039e7d5afb3d5f2a6aaac93bd5822e5f8efc328',
'3e9b5c6b986c2ddc09bf8604eb2bd2a3b49b46f11042c282331a206dadb4296e',
'c65f502b11b325abc0fac847e8fc5cd300169160e7244b29dd5acc3d0e4b8605',
'afe7d2287020c4291f609a772adbeafc952a8de0ced38a7346acb6c7103bec6d',
'0caa545ae63de39d47baea100ea15a18061235d7e1a372fbca88edf9ca5ac797',
'c5bfff15b4dd64e7faac98f1bba118fb11990e4ff146cb45c7f4af6b93e2ea03',
'a8805201e8152c1f5835c9aa024752fb34aeb7fa55dd3af0ae6109918f328dbb'],
'20000000',
'1801310b',
'59bcd504',
True]}
Based on the pool response....I can build the coinbase just by
coinbase = coinb1 + extranonce1 + extranonce2 + coinb2
coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest()
and same to include in merkle tree with hashing to get merkle_root. I am not sure if i need to reverse the bits here ?
But to build a block header ... should i do this..
header = version + prevhash + merkle_root + ntime + nbits + nonce
or this..
header = binascii.hexlify(binascii.unhexlify(version)[::-1]).decode('utf-8') + \
prevhash + \
merkle_root + \
binascii.hexlify(binascii.unhexlify(ntime)[::-1]).decode('utf-8') + \
binascii.hexlify(binascii.unhexlify(nbits)[::-1]).decode('utf-8') + \
binascii.hexlify(binascii.unhexlify(nonce)[::-1]).decode('utf-8')
blockheader:000000200eba48f47bc0ab4bb35b230849868bf1d79aeb19006eed460000000000000000fb68998fe1dd4cc22fa1225c2592c27df5331d40d9b33ffce99b26c0aead8ef404d5bc590b3101181e3eef8c
Can someone please post an example of a recent BLOCK HEADER ... i think i m doing something wrong !
I am comparing this hash
hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(header)).digest()).digest()[::-1]
with the target "000000000001310b000000000000000000000000000000000000000000000000"