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.

stanm87
  • 237
  • 1
  • 5
  • 1
    Index for what type of querying? – Pieter Wuille Oct 09 '14 at 08: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 Oct 09 '14 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 Oct 13 '14 at 15:12
  • 1
    Does this answer your question? http://bitcoin.stackexchange.com/questions/5518/how-do-i-access-information-on-blockexplorer-com-or-blockchain-info-without-issu – Nick ODell Oct 22 '14 at 17:57
  • @NickODell not at all – stanm87 Oct 22 '14 at 21:09

1 Answers1

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).

dark knight
  • 2,017
  • 9
  • 25