6

I haven't been able to find information on how to efficiently index UTXOs. Can you explain or point me to some resources?

Update: Btw, I understand completely that the notion of address balance is awkward at best, and that it can never really be known with 100% confidence, especially as P2SH transactions gain popularity.

5
  • 1
    Index for what type of querying? Commented Oct 9, 2014 at 8:24
  • 1
    haven't tried anything as I'm not an expert on indices, but have browsed a ton of bitcointalk and couldn't find anything. @PieterWuille to query balances for addresses.
    – stanm87
    Commented Oct 9, 2014 at 11:38
  • So after doing more digging, here's is what I'm thinking: read the chainstate db from bitcoin core, either directly or via rpc, and then flip the index. I was thinking of putting it in a redis hash, with addresses as keys and transactions as values. This way I can use HSCAN to iterate over the transactions that point to an address and get its balance. The reason I want to use Redis is because this datastructure will be updated quite often, and having everything in RAM is good for that use case. What do you think?
    – stanm87
    Commented Oct 13, 2014 at 15:12
  • 1
    Does this answer your question? bitcoin.stackexchange.com/questions/5518/…
    – Nick ODell
    Commented Oct 22, 2014 at 17:57
  • @NickODell not at all
    – stanm87
    Commented Oct 22, 2014 at 21:09

1 Answer 1

2

I believe what you are looking for is and address based index for txout. Have a look here https://bitcointalk.org/index.php?topic=1395749.msg14194272#msg14194272

Your basic idea of keeping a map of address -> txout is ok. You might want to rethink about storing in memory. Current bitcoind chainstate is around 1.2G (compressed state).

2
  • how can I know the size of the chain state today?
    – Giszmo
    Commented Jan 16, 2018 at 3:21
  • Currently its around 3.2 GB . You need to run a bitcoin node and see size of .bitcoin/chainstate directory Commented Jan 16, 2018 at 11:15

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.