Bitcoin-Qt Command line - adding private key - Mac OSX

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??

deweydb

Posted 2013-05-05T20:17:44.820

Reputation: 247

1I 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 2013-05-05T22:55:25.253

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.deweydb 2013-05-05T23:25:18.467

1ah! 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!deweydb 2013-05-05T23:28:40.700

I too found out that importprivkey takes forever on OSX, around 5 minutes on my MBP.RotHorseKid 2013-05-06T13:28:43.003

Answers

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.

lurf jurv

Posted 2013-05-05T20:17:44.820

Reputation: 2 516