Title: Issue with Blockheader from Stratum Data Post by: dwarf_racoon on January 25, 2023, 07:24:02 PM Hey hey
I'm writing a python script to take stratum tcp messages recorded through a mining proxy to reconstruct blockheaders and verify the miners' work. Documentation seems fairly sparse and at times conflicting. From an initial 'mining.subscribe' response, we can gather the ExtraNonce1 (or from a later 'mining.set_extranonce') From a 'mining.notify' job specification, we can gather the version, previous hash, time, and nBits towards the blockheader, additionally we can gather both the coinbase bits and the merkle branches. From a 'mining.submission', we can gather the extraNonce2 and the nonce. We can build the merkle root applying the following by first constructing the coinbase_hash: Code: coinbase=trans1+extraNonce1+extraNonce2+trans2 and then the following: Code: def build_merkle_root(merkle_branch, coinbase_hash_bin): From here is where things seem to get fuzzy, as https://github.com/ricmoo/nightminer/ gives a different order for the blockheader than say https://braiins.com/stratum-v1/docs where ricmoo has the nbits before the ntime, whilst the latter (and most other documentation) has nbits after ntime. I can build a simple byte reversal and swap for the merkel_root via: Code: def swap_order(s): and get towards the following: Code: padding='000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000' but this does not seem to result in hashes that are below the target difficulty. I've struggled to find a straightforward version of this kind of a script and would appreciate any tips, insights, or links to related projects ??? Title: Re: Issue with Blockheader from Stratum Data Post by: NotFuzzyWarm on January 25, 2023, 08:33:11 PM A better place to ask this in in the Bitcoin Technical Support area of the Forum (https://bitcointalk.org/index.php?board=4.0). This area is mainly for hardware support, not coding.
|