1

I have a mining notification from a stratum pool. I wish to write a general script to extract the value of the block reward that the pool is taking. That is, reconstruct the block template, or at least the sum of the coinbase transaction outputs / block reward, given the stratum mining.notify JSON. For example, we have the mining.notify JSON for a Digibyte sha256d block template:

{"id":null,"method":"mining.notify","params":["8c6e","4aab33fcf4579faee35bde813ad6f66f8e1c3fed97fb5763ac6de4d02b301277","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff210472329000048b2c825d08","0d2f6e6f64655374726174756d2f00000000020000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9cd1576270f0000001976a914f54c85705d38622a202c6f97caf7248cc4be001c88ac00000000",[],"20000202","1908ef40","5d822c8b",true]}

Here, the "coinb2" string is:

0d2f6e6f64655374726174756d2f00000000020000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9**cd1576270f000000**1976a914f54c85705d38622a202c6f97caf7248cc4be001c88ac00000000

and this is the important part for the output transactions.

It turns out that in this case the reward is cd1576270f000000, written with bytes reversed, which corresponds to a base 10 integer value of 65086559693. If there is only one output address, we can guess here that the reward is the 8 bytes before the 1976, but what if there are many output addresses?

How can we find the sum of all outputs of the coinbase transaction given the "coinb2" string in the most general case?

1 Answer 1

2

If there is only one output address, we can guess here that the reward is the 8 bytes before the 1976,

No, you cannot. the 1976 is the start of the output script and can/will be different depending on the output script (i.e. address) that the pool wants to use.


The stratum protocol says that the hex for the coinbase transaction is coinb1 + hex(extranonce2) + coinb2. extranonce2 is produced by the miner and is of a size specified by the mining pool as the Extranonce2_size from the response to mining.subscribe.

So you can just create bogus extranonce2 of the correct size and concatenate the strings together as described earlier. Then put the result into a raw transaction decoder. Without the full transaction with everything (or placeholder data) in place, you cannot really properly decode the transaction reliably.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.