I want to set up a service to monitor the activity of various watch-only addresses. I know Blockchain.info offers an option to do URL callback notifications when a payment is made to an address in their wallet and I know you can add a watch-only address to their wallet by hand, but I can't seem to find an API call to be able to accomplish that. Is it possible to add watch-only addresses to Blockchain.info through an API call?
1 Answer
It seems that Blockchain.info, among others, is compliant to the bitcoin JSON RPC API. That given, you can use the most common programming languages to access your wallet, last but not least the simple bitcoin-cli
command, from the original bitcoin distribution:
$ bitcoin-cli -rpcconnect=rpc.blockchain.info -rpcport=443 -rpcssl -rpcuser=YourWalletIdentifier -rpcpassword=YourPassword getinfo
-rpcconnect=rpc.blockchain.info
will instruct bitcoin-cli
to connect to blockchain.info's RPC interface; -rpcport=443
specifies the remote port; -rpcssl
needs to require a SSL connection; -rpcuser
and -rpcpassword
speak for themselves.
The last word, getinfo
, is the command itself.
In your case, it should be something like:
importaddress <bitcoinaddress> "" false
where importaddress
is the command (or method) which instructs the wallet to include the <bitcoinaddress>
in the wallet itself. Since you don't specify the private key of the address, but just the address itself, it will become a "watch address" inside your wallet: you will be able to track its status but not to broadcast transactions which involves it. The couple of double quotes ""
can be replaced with the wallet's name, if you set one. false
is a boolean value which instructs the bitcoin engine not to rescan the whole blockchain looking for transactions which involves the address you are adding. I am not a blockchain.info customer, so I don't know the effects of this particular flag. I believe that it is ok to set it true, since blockchain.info scans the blockchain in real time.