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?

1
  • have you solve this issue using JSON-RPC?
    – Jus12
    Jun 24, 2017 at 19:02

1 Answer 1

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

6
  • Thanks but I don't want to be dependent from another service. Apr 13, 2014 at 7:55
  • I'm not sure what GetPublicTransaction brings as it requires txid. Apr 13, 2014 at 7: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. Apr 13, 2014 at 8:00
  • @gregoiregentil I've added more details to my answer, it should make more sense now.
    – user11221
    Apr 13, 2014 at 13:30
  • There is a thread about watch-only wallet here: bitcointalk.org/index.php?topic=296904.0 Also, this blog explains well how to implement the wished feature: wildbunny.co.uk/blog/2014/03/18/watch_only_wallet Apr 13, 2014 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.