coinbase transaction – reverse stratum mining.notify

I have a mining notification from a shift pool. I want to write a generic script to extract the value of the block reward the pool accepts. This is, Reconstruct the block template using the JSON statement stratum mining.notify or at least the sum of the Coinbase Transaction / Block Reward issues, For example, we have the file mining.notify JSON for a Digibyte sha256d block template:

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

Here is the "coinb2" string:


and this is the important part for the issuing transactions.

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

How can we find the sum of all expenses of the Coinbase transaction given the "Coinb2" string in the most general case?