1

I'm currently running a Bitcoin Core full node on my raspberry pi. I have set the config file to txindex=1 and I want to query the bitcoin network to find out how many addresses hold more than 1 bitcoin. I have gotten the getrawtransaction and decoderawtransaction to work. Does anyone know where to start? I'm struggling a bit.

2 Answers 2

0

Bitcoin Core does not have an address index. It is not trying to be a backend for a block explorer, so looking up this sort of statistic from Bitcoin Core directly will be difficult.

Given that you seem to be interested in current balances, the UTXO set is a good starting point (as RedGrittyBrick already suggested). Bitcoin Core has a hidden RPC called dumptxoutset which will write the complete UTXO set to a .dat file. There appears to be a tool to convert that dump into an SQLite database by theStack which could help you work with that data dump (I have not tested this myself).

Given that database it should be easy to generate the statistics you want.

If you are just interested in getting the exact count rather than the path of extracting it yourself, it would be much easier to use Blockchair with an appropriate query: using their address endpoint filtered by balances of at least 1 ₿, the result table has 978 715 entries.

enter image description here

1
  • Thanks Murch, that looks really promising. Jan 19, 2023 at 9:48
1

I want to query the bitcoin network to find out how many addresses hold more than 1 bitcoin

Bitcoin core is mainly focussed around being a wallet for one person. Your objective is not one that Bitcoin core supports very well (if at all)

Of course, Bitcoin core does accumulate a complete set of transaction data and some useful derived data that you can analyse by other means. One of the derived sets of data maintained by Bitcoin core is the chainstate - which I believe is mostly the UTXO set.

I would aim to extract the UTXO set then iterate through that to sum by address (e.g. in a map of addresses to total amount).


Related

3
  • Thank you for the answer. What you're saying makes a lot of sense. I think I'll go that route. Jan 17, 2023 at 12:55
  • I'd say Bitcoin Core mainly focuses on being a full node, and its wallet is a tool to showcase new protocol advances and some good wallet practices. While it is usable as a wallet for power users, there are most definitely better wallets out there. :)
    – Murch
    Jan 18, 2023 at 15:32
  • Can I ask you what wallets are recommended for on-chain analysis? Jan 21, 2023 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.