4
We are working on a small project and imported all block information to mongoDB. Right now we're aiming to calculate the coin supply regarding to the block number.
My plan is to loop through all transactions per block and parse vout and vin. However, I'm not sure how to distinguish mined coins and previously existing coins transferred users. Plus, how to account for transaction fees?
Can I track only "valueOut" and that's all?
{
"txid":"0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"version":1,
"locktime":0,
"vin":[
{
"coinbase":"04ffff001d0104",
"sequence":4294967295,
"n":0
}
],
"vout":[
{
"value":"50.00000000",
"n":0,
"scriptPubKey":{
"hex":"410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
"asm":"0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
"addresses":[
"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"
],
"type":"pubkeyhash"
},
"spentTxId":null,
"spentIndex":null,
"spentHeight":null
}
],
"blockhash":"00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"blockheight":1,
"confirmations":601155,
"time":1231469665,
"blocktime":1231469665,
"isCoinBase":true,
"valueOut":50,
"size":134
}
Any help would be appreciated!
Hey Prologas, interesting question. I've touched up the body of your question a bit to make it easier to understand. Could you please proofread my changes to verify that I didn't change the essence of your question? – Murch – 2019-10-27T00:23:00.327
1We have really good answers below, and I would like to add a nice hack to them. On Bitcoin-Core, run the command
bitcoin-cli gettxoutsetinfo. It will give you all the information of the coins outstanding. It calculates that amount by summing all the block subsidies less the amount not claimed by miners, bitcoins sent toOP_RETURNoutputs, 50 BTC genesis block output that cannot be spent and the two coinbase transactions Raghav Sood mentioned in his answers. It doesn't exclude the Bitcoins sent to1BitcoinEater...type addresses as thr is no verifiable way to know if one own the priv key. – Ugam Kamat – 2019-10-27T08:25:33.537This works indeed:
root@b9f3dd35c755:/# bitcoin-cli gettxoutsetinfo { "height": 601237, "bestblock": "0000000000000000000f18a401591a0f440668ed1e3d975a64cb3687b796b8c6", "transactions": 37206777, "txouts": 63615267, "bogosize": 4784113473, "hash_serialized_2": "88e6d6b2585e83204760db1f383b942dbade97569c7556bdd30b1ad8fcfcdfa9", "disk_size": 3833721332, "total_amount": 18015292.32182326 }But minus here if you don't have RPC access and using only public explorer to import data. – Prologas – 2019-10-27T10:49:51.753