3

Everything is in the title... For instance, Blockchain can do this if you import a public address and you set up their notification mechanism.

Is there a way to do this in an intelligent (=efficient) way with bitcoind even with some patches? Or is the only solution is to get all transactions and filter for the public address?

gregoiregentil
  • 155
  • 1
  • 6

1 Answers1

2

If you want to do it via bitcoind, since the transaction in question isn't an in-wallet transaction, this is as close as you can get with bitcoind: GetPublicTransaction()

If your daemon has its transactions indexed (is -txindex enabled), you can iterate through all blocks using getblockash and getblock, then iterate through all the transactions for each block using getrawtransaction and look for outputs and inputs referring the address(es) you want, when it's an input reference then balance decreases, when it's an output reference the addresses balance goes up.

Obviously this approach will take ages in you need to scan the whole blockchain that is getting bigger every day so you need to limit your iterations to the new blocks only, and for newly added addresses to watch you should allow a few minutes for the blockchain to be rescanned if you wish to provide historical data for them.

Apart from that, there is some talk going on about adding support for watch-only wallets (which is what you're actually asking here) in the core client itself, however this enhancement is not yet available today.

You can also sign-up for http://www.blocknotify.com/ and get a notification every time something changes in that address.

Finally, you can parse the local blockchain files manually but that's a little bit more hard-core, this is a nice post giving some guidance on that: http://codesuppository.blogspot.gr/2014/01/how-to-parse-bitcoin-blockchain.html and an open source project that could also help: https://github.com/jeffchan/blockchain-parser

  • Thanks but I don't want to be dependent from another service. – gregoiregentil Apr 13 '14 at 07:55
  • I'm not sure what GetPublicTransaction brings as it requires txid. – gregoiregentil Apr 13 '14 at 07:56
  • I'm not sure to understand your third suggestion. Here I want an instant notification of transactions that are not yet in any block. – gregoiregentil Apr 13 '14 at 08:00
  • @gregoiregentil I've added more details to my answer, it should make more sense now. –  Apr 13 '14 at 13:30
  • There is a thread about watch-only wallet here: https://bitcointalk.org/index.php?topic=296904.0 Also, this blog explains well how to implement the wished feature: http://www.wildbunny.co.uk/blog/2014/03/18/watch_only_wallet/ – gregoiregentil Apr 13 '14 at 16:29
  • I would avoid using 3rd party service when handling money (and the site is gone, 4 years later, proving my point). Too bad this is not there in bitcoind. Is it added now? 4 year later... – Jus12 Jun 24 '17 at 19:03