Author

Topic: How to efficiently parse the blockchain for ANY random address or txid? (Read 1238 times)

legendary
Activity: 1442
Merit: 1186
A lot of these services need to use a block parser/broswer like ABE. Have you looked into bitcoin abe? https://github.com/bitcoin-abe/bitcoin-abe

sr. member
Activity: 362
Merit: 262
You need to add the info to bitcoin.conf i.e. add txindex=1
Then you need to reindex (once only) by running bitcoin with the -reindex option from the command line.  This needs to be done once (and will take some time).

newbie
Activity: 13
Merit: 2
I see, thanks. Is this a default feature of Bitcoin Core? And should I have done this right from the start, when initially downloading/parsing the blockchain, or is this something I can also enable on an existing default (i.e. non full tx indexed) Bitcoin Core instance?
sr. member
Activity: 362
Merit: 262
What is a "full transaction index"? I've read that term before and sort of can imagine how to interpret that, but is there something "official" in Bitcoin jargon that defines full transaction index?
It allows you to pull the details of ANY tx by the tx hash.  Default as stated before only allows this for tx in your wallet.
copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
What is a "full transaction index"? I've read that term before and sort of can imagine how to interpret that, but is there something "official" in Bitcoin jargon that defines full transaction index?

Full transaction index as in: an index of all transactions (recorded in the blockchain). The default behaviour is to only keep an index of transactions that are related to your wallet.
newbie
Activity: 13
Merit: 2
What is a "full transaction index"? I've read that term before and sort of can imagine how to interpret that, but is there something "official" in Bitcoin jargon that defines full transaction index?

copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
How do API services or block explorers like blockr.io, bchain.info, blockchain.info, blocktrail.com and so on, efficiently parse the blockchain for *any* address or transaction?

They start with the first block and keep track via an external database.

I've got some full nodes running. And especially since Bitcoin Core 0.10 where you can import watch only addresses, it's relatively easy to import a random address and watch its balance and history. It's not clear to me how people did this before 0.10 - I understand the data is in the blockchain obviously, but I wouldn't know how to parse it.

getbalance was added in 0.10.0 but it does not return correct values for arbitrary addresses on none of my nodes. I suspect this is because the node running 24/7 has no wallet and the other one does not maintain a full transaction index. I suspect that getbalance is only working on address you imported (whether watch only or via private key) and that 0.10.0 isnt keeping track of all balances in the background.

But in order to come up with any address' balance or tx history in a matter of seconds, how is that done?

You have to trade calculation time for storage. If you expect to make these requests on a regular basis it makes sense to create a database that does the work once for all addresses, stores the results and gets updated with every new block found.

Is there a script or library of sorts to efficiently traverse the raw blockchain data for any particular address or txid?

AFAIK the best you can get from bitcoin core is to enable txindex which allows you to get information on any TX.

Does it require a special version of Bitcoin Core with extra tracking information or something? Do they actually keep a dedicated database for this, explicitly listing ALL addresses and txids?

Note that this is not related to any 'wallet', or specific addresses I already own or know. I'm trying to understand how this is done for random addresses or txs. That includes non-existent addresses or txids (where the result is 'does not exist' or 'never used' or balance zero).

Due to the amount of possible addresses I suspect that addresses that have never appeared on the blockchain have no database entry.
newbie
Activity: 13
Merit: 2
How do API services or block explorers like blockr.io, bchain.info, blockchain.info, blocktrail.com and so on, efficiently parse the blockchain for *any* address or transaction?

I've got some full nodes running. And especially since Bitcoin Core 0.10 where you can import watch only addresses, it's relatively easy to import a random address and watch its balance and history. It's not clear to me how people did this before 0.10 - I understand the data is in the blockchain obviously, but I wouldn't know how to parse it.

But in order to come up with any address' balance or tx history in a matter of seconds, how is that done? Is there a script or library of sorts to efficiently traverse the raw blockchain data for any particular address or txid? Does it require a special version of Bitcoin Core with extra tracking information or something? Do they actually keep a dedicated database for this, explicitly listing ALL addresses and txids?

Note that this is not related to any 'wallet', or specific addresses I already own or know. I'm trying to understand how this is done for random addresses or txs. That includes non-existent addresses or txids (where the result is 'does not exist' or 'never used' or balance zero).
Jump to: