When running bitcoind under OSX/Linux, how can we add a watch-only wallet using the JSON RPC? Do we need the public key or is the bitcoin address sufficient?
2 Answers
As of bitcoind v10, there is support for watch-only addresses. A bitcoin address is sufficient. The bitcoin-cli command is:
bitcoin-cli importaddress "address" ( "label" rescan )
Where "address"
is the address you wish to watch, "label"
is an optional label for the the address, and "rescan"
is a boolean of whether bitcoind should rescan all previous transactions for activity relating to "address"
.
The example in bitcoin-cli's documentation of the JSON-RPC command is:
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "importaddress", "params": ["myaddress", "testing", false] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
-
thank goodness for this new functionality. this should have been one of the first things that was implemented in bitcoin. how else can anybody run a trustless e-commerce site with air-gapped private keys? i was writing my own re-implementation until this feature came out purely for this purpose :p Commented Jun 20, 2015 at 2:03
Today this is not possible. There's been an active discussion on this topic on GitHub, but it's currently not implemented.
There was a pull request submitted a while back that some people may have started using in production, but my understanding is that the code is old and currently not buildable against the current source.
It would be a great feature, so I hope it comes out at some point.