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?