1

I recently created a custom Public key (with vanitygen) and i would like to add the corresponding private key to my bitcoin-Qt wallet client. I have started bitcoin-Qt in server mode using:

$ open Bitcoin-Qt.app --args -server

And then issued the following commands, yet i cannot seem to successful add the private key, can anyone tell me what i am doing wrong?

$ curl --user bitcoinrpc --data-binary '{"method": "walletlock" }' http://127.0.0.1:8332/
Enter host password for user 'bitcoinrpc':
{"result":null,"error":null,"id":null}

$ curl --user bitcoinrpc --data-binary '{"method": "walletpassphrase", "params": ["************", 120] }' http://127.0.0.1:8332/
Enter host password for user 'bitcoinrpc':
{"result":null,"error":null,"id":null}

$ curl --user bitcoinrpc --data-binary '{"method": "walletpassphrase", "params": ["************", 120] }' http://127.0.0.1:8332/
Enter host password for user 'bitcoinrpc':
{"result":null,"error":{"code":-17,"message":"Error: Wallet is already unlocked."},"id":null}

$ curl --user bitcoinrpc --data-binary '{"method": "importprivkey", "params": ["************", "************"] }' http://127.0.0.1:8332/
Enter host password for user 'bitcoinrpc':
{"result":null,"error":{"code":-4,"message":"Error adding key to wallet"},"id":null}

So what happens is, when i try to decrypt my wallet it just says 'null' as a response. At first i thought it wasn't actually decrypting, but if i lock it and then try twice to decrypt it, it tells me "Error: Wallet is already unlocked".

Great! so it is unlocked and we should be able to now add the private key, but i just get error code -4 ? what is error -4 ? how do i make this work??

4
  • 1
    I don't actually know, but I think (not sure, so I won't submit an answer) Error -4 means you've already added that private key.
    – lurf jurv
    May 5, 2013 at 22:55
  • I think you might be correct. I deleted my wallet (there was nothing in it anyway, just getting started). and started fresh. I get all the way through these steps but instead of the error -4, now bitcoin-qt just crashes and uses 100% cpu when it try's to add that private key. May 5, 2013 at 23:25
  • 1
    ah! ok, it doesn't crash, it just hangs for a while, eventually it does insert that key! Sweet. I think your original answer is correct, you should make it an answer so i can mark you approved. thanks! May 5, 2013 at 23:28
  • I too found out that importprivkey takes forever on OSX, around 5 minutes on my MBP. May 6, 2013 at 13:28

1 Answer 1

2

Error -4 means that you've already added that private key. It might take a while to import because it's rescanning the whole blockchain for transactions involving that address.

Your Answer

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

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