7

I have a standard client (QT client on OSX) with an encrypted wallet. I've tried to import keys with pywallet, but while it claimed to be importing them, when I ran again the bitcoin client, it said wallet.dat was corrupted (yes the client wasn't running when I did the import).

I guess pywallet doesn't know about encryption and didn't care enough to check everything was ok before importing them.

So, how do I do this import?


Trying to run the command line client gets me the following error a few seconds after starting it (with -daemon option of course):

EXCEPTION: NSt8ios_base7failureE       
CDataStream::read() : end of data       
bitcoin in AppInit()       

Running the QT client with the -server option crashes too after a while (apparently it works correctly without that).

5

Since 0.6.0, key import/export are available in the client itself, though only through RPC. The commands are called dumpprivkey and importprivkey. For example (on testnet):

$ ./bitcoind getnewaddress

n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv

$ ./bitcoind dumpprivkey n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv

cR4RtpaeAZY8MwrNvTQGX9PZ9pdCgFoLxuo4Pkwqx61broC4Gb4y

And on another wallet:

$ ./bitcoind importprivkey R4RtpaeAZY8MwrNvTQGX9PZ9pdCgFoLxuo4Pkwqx61broC4Gb4y

$ ./bitcoind validateaddress n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv

{ "isvalid" : true, "address" : "n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv", "ismine" : true, "pubkey" : "029e3a934cfc9f89d7a1c15f99b98479cabc81964f4972e7b8fa3989a788261695", "iscompressed" : true, "account" : "" }

  • Oh, apparently bitcoin-qt doesn't provide a server for the command line client to connect to; also looks like bitcoind isn't starting anymore, crashing with an exception a few seconds after it started... (does it support encrypted wallets? in the options I noticed nothing about that...) – o0'. Apr 30 '12 at 16:35
  • You need to run "bitcoin-qt -server" to get it to provide a server. And you'll need to have 'rpcuser=x' and 'rpcpassword=y' in your bitcoin.conf file, but I think bitcoin-qt will tell you that if you don't have it. bitcoind supports encrypted wallets, but make sure you're using the same version as the version of bitcoin-qt you have. – Chris Moore Apr 30 '12 at 16:37
  • 1
    @ChrisMoore mmmh, doing so I only get errors -4"Error adding key to wallet" if I try to add priv_sipa or -5"Invalid private key" if I try to add priv – o0'. Apr 30 '12 at 16:45
  • 2
    Oh, you need to unencrypt your wallet temporarily so it can add the new key. I do the following, so my passphrase doesn't end up in my shell history. It unlocks the wallet for 60 seconds: read x; ./bitcoind walletpassphrase "$x" 60; unset x – Chris Moore Apr 30 '12 at 17:29
  • I can't do that: if I run the server from command line, it crashes after a while, and the same happens if I run the QT client with the -server option. – o0'. May 2 '12 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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