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:


Here, the "coinb2" string is:


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


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.


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.