I was wondering where I could see how many unique addresses currently exist in the blockchain, and especially how many of those have a positive balance. Is that data available somewhere?
2 Answers
As of 12th May 2013 there have been just over 13 million distinct Bitcoin addresses which have been recipients of funds, and of those just over 1.6 million carry a positive balance.
However, please be aware that a single person's wallet is very likely to have multiple addresses in it, so the above numbers should not be extrapolated to assume anything about the number of users of Bitcoin.
You could create an index of all addresses and their balances by going over the whole block chain, f.e. using the RPC API.
I quickly wrote this script in Python. Note that I did not verify it! I only made it to give you an idea on how you can iterate over all transactions. Also, there is probably a more time-efficient way to do it by reading the block chain files yourself.
# setup bitcoind as RPC connection to your bitcoind client using JSON-RPC
block_hash = bitcoind.getblockhash(0)
while True:
block = bitcoind.getblock(block_hash)
for txid in block["tx"]:
# you will need to run bitcoind with -txindex to be able to do this
tx = bitcoind.gettransaction(txid)
for det in tx["details"]:
address = det["address"]
amount = det["amount"]
# do something with address and amount
# f.e. put them in a dictionary (this will take a lot of RAM)
# it is more advised to setup a db on disk
if block.has_key("nextblockhash"):
block_hash = block["nextblockhash"]
else:
break