Is there any tool to check sum of all BTC based on transactions? We can easily get this amonut by sum up mining rewards, but what about sum up all non zero wallet balances?
gettxoutsetinfo RPC command iterates through the entire UTXO set (the set of outputs that haven't been spent yet by another transaction).
Currently, it reports:
"height": 539935 "total_amount": 17249017.33071828
This is the approach you're looking for as it is computed from the actual outputs and inputs, though with a few caveats:
- It is not computed on-the-fly from the blockchain; instead, it uses a database with unspent outputs that is always maintained by the validation code.
- It excludes provably unspendable outputs (OP_RETURN outputs or outputs with a script longer than 10000 characters).
Note the discrepancy with the expected amount in circulation at that height (17249200.00000000). There are various reasons for this. My answer https://bitcoin.stackexchange.com/a/38998/208 goes into the details.