Post
Topic
Board Development & Technical Discussion
Re: How to get the information about a bitcoin address without 3rd-pard services?
by
keeshux
on 10/09/2014, 15:58:00 UTC
You'll be only able to get such information about an address if you have a full node history locally. Given that, the overall process is:

  • Parse blocks from files
  • For each block, iterate through all transactions
  • For each transaction, parse output scripts
  • If the output script is of some standard form, you can get an address out of its bytes
  • If the parsed address matches the one you're interested in, add the transaction to your "interesting" set
  • From the relevant transactions you can finally infer all the stats you need, e.g. balance, sent/received..

This is just a generic slow algorithm because I don't know the structure of Bitcoin Core files. Some existing index would surely improve search efficiency (e.g. the UTXO index is enough for the balance), in fact web providers must have some internal index on addresses. I've seen many tools around that build fast databases from raw blocks, but I've never used them.

If you don't have any local history, the only way I'm aware of is loading a Bloom filter matching your address and scan the whole blockchain. The peers will then send you relevant transactions for that address plus some unrelevant ones due to the probabilistc nature of the Bloom filter. Beware that you will be forced to do a full rescan for each new address you want to search.