<p>I've a full node running in a AWS vm. I want to develop an app which would be able to provide balance for a given btc address. I know blockchain.info and blockexplorer.com exists but I want to do my own but a simple one, just to do the balance query. I want to support a high request bandwidth and each request to work in O(1) complexity.
Towards that goal, I'm thinking if</p>
<ol>
<li>I can extract out all the unique btc addresses from blockchain</li>
<li>run a script which takes btc address and runs &quot;bitcoin-cli getbalance&quot; from my node to obtain balance for that address</li>
<li>Build a in-memory cache of address-&gt;balance or in mongodb,
then I can do it.
Does this plan look good? Is there a better alternative? Are there existing open-source solutions that I can use to do this all, saving me lot of development work? How do I go about each step?
Once the infra is set, it should be easy to keep it uptodate since blocks are added every 10mins. I think a event based system can be setup to trigger when blocks added. But setting up the infra is the problem here.</li>
</ol>
<p>Please help. Much appreciated.</p>

CC BY-SA 4.0
2021-11-17T10:14:45.420Z
You only need to `getbalance` for addresses in the UTXO. All other addresses found on the blockchain will have balance 0.
bordalix
CC BY-SA 4.0
2021-11-17T10:49:23.010Z
this required years of calculation :)
vincenzopalazzo
CC BY-SA 4.0
2021-11-17T10:51:53.697Z
there are parser of the bitcoin block data that can do somethings like that, or maybe could be do something like that faster. A worked on a draft and it is available https://github.com/vincenzopalazzo/SpyCblock and an analysis of the bitcoin scrip with the result it did with https://github.com/vincenzopalazzo/AnalyticsPyBlock
vincenzopalazzo
CC BY-SA 4.0
2021-11-17T19:34:08.900Z
Hi @bordalix How can I obtain all the addresses in UTXO? Is there a script that I can run on the bitcoin data I've in my node?
kdas
CC BY-SA 4.0
2021-11-18T05:58:33.903Z
@kdas, check this answer: https://bitcoin.stackexchange.com/questions/51387/how-does-bitcoin-read-from-write-to-leveldb/52167#52167
bordalix
<bitcoin-core><address><balance>
existing solution to build a bitcoin address-balance index
kdas
# existing solution to build a bitcoin address-balance index

(Asked by: username_0 on 2021-11-17)

I've a full node running in a AWS vm. I want to develop an app which would be able to provide balance for a given btc address. I know blockchain.info and blockexplorer.com exists but I want to do my own but a simple one, just to do the balance query. I want to support a high request bandwidth and each request to work in O(1) complexity.
Towards that goal, I'm thinking if

1. I can extract out all the unique btc addresses from blockchain
2. run a script which takes btc address and runs "bitcoin-cli getbalance" from my node to obtain balance for that address
3. Build a in-memory cache of address->balance or in mongodb,
   then I can do it.
   Does this plan look good? Is there a better alternative? Are there existing open-source solutions that I can use to do this all, saving me lot of development work? How do I go about each step?
   Once the infra is set, it should be easy to keep it uptodate since blocks are added every 10mins. I think a event based system can be setup to trigger when blocks added. But setting up the infra is the problem here.

Please help. Much appreciated.

**Tags:** bitcoin-core, address, balance

> **Comments:**
> **username_1**: You only need to `getbalance` for addresses in the UTXO. All other addresses found on the blockchain will have balance 0.  
> **username_2**: this required years of calculation :)  
> **username_2**: there are parser of the bitcoin block data that can do somethings like that, or maybe could be do something like that faster. A worked on a draft and it is available https://github.com/username_2/SpyCblock and an analysis of the bitcoin scrip with the result it did with https://github.com/username_2/AnalyticsPyBlock  
> **username_0**: Hi @username_1 How can I obtain all the addresses in UTXO? Is there a script that I can run on the bitcoin data I've in my node?  
> **username_1**: @username_0, check this answer: https://bitcoin.stackexchange.com/questions/51387/how-does-bitcoin-read-from-write-to-leveldb/52167#52167  

---

## 0 answers

