Bitcoin Core RPC "importaddress" for a P2SH watch-only

0

I am trying to import a p2sh address as watch-only:

bitcoin-cli importaddress <P2SH ADDRESS> true true

for which the command seems to execute, pause, then after a few minutes give me the error message:

error: couldn't connect to server: unknown (code -1) (make sure server is running and you are connecting to the correct RPC port)

Why is this not working for me?

doffing81

Posted 2018-03-28T22:47:49.093

Reputation: 474

Answers

1

I believe the issue is that you forgot the label parameter. According to the RPC help documentation, the parameters for importaddress should be:

 importaddress "address" "label" rescan p2sh

You have used "address", rescan and p2sh but not label, so the error is likely due to an issue converting the parameters you provided into the ones it expected.

But the fact that the error message is so hard to understand / unrelated to the actual error is a bug, please open an issue on github here: https://github.com/bitcoin/bitcoin/issues

MeshCollider

Posted 2018-03-28T22:47:49.093

Reputation: 8 735

That is looking to be the problem, so far. It wants a script instead of an address after adding a label. I will report the issue.doffing81 2018-03-29T00:08:14.843

@BrettDoffing it should not require the script, that defeats half the purpose of watch-only :)MeshCollider 2018-03-29T00:14:25.830

I know, right?!doffing81 2018-03-29T00:14:54.197

-1

for some reason bitcoin-cli requires bitcoin.conf to be setup before it can work. To do this, you can go to your bitcoin data directory and add the following:

name the file bitcoin.conf then add the config file or you can just add: rpcuser=Randomusername rpcpassword=randompassword server=1 daemon=1 listen=1

zhiyan114

Posted 2018-03-28T22:47:49.093

Reputation: 528

rpc commands work for everything else.doffing81 2018-03-28T23:43:42.400

hmm try add that and see if it work cause i do have the same issue when i didnt setup the bitcoin.confzhiyan114 2018-03-28T23:44:19.207

my .conf is setup just fine, unless you can give me a specific reason why listen=1, or daemon=1 need to be set for this specific problem.doffing81 2018-03-28T23:49:14.233

I mean i added all to make sure because listen usually stands for to listen the port while daemon usually refers to a background server thing.

Try add it and see if it solves and if not u can then remove it. – zhiyan114 2018-03-28T23:50:48.247

btw that error you have usually means that bitcoin-cli cannot connect to json-rpc with bitcoin-daemon or bitcoin core.zhiyan114 2018-03-28T23:54:03.247

Like I said, any other rpc command works just fine, the daemon is running just fine, and I'm pretty sure "listen" has to do with how your node connects to other nodes, and has nothing to do with this problem.doffing81 2018-03-28T23:56:29.330

It might be the source code error. Well good luck with itzhiyan114 2018-03-28T23:58:09.077

No bitcoin.conf is necessary anymore before you can use bitcoin-cli.Pieter Wuille 2018-03-29T07:02:57.547