user196: 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).

user208: 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" : ""
  }


196: <p>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).</p>

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

<p>So, how do I do this import?</p>

<hr>

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

<pre><code>EXCEPTION: NSt8ios_base7failureE       
CDataStream::read() : end of data       
bitcoin in AppInit()       
</code></pre>

<hr>

<p>Running the QT client with the <code>-server</code> option crashes too after a while (apparently it works correctly without that).</p>
 208: <p>Since 0.6.0, key import/export are available in the client itself, though only through RPC. The commands are called <code>dumpprivkey</code> and <code>importprivkey</code>. For example (on testnet):</p>

<blockquote>
  <p>$ ./bitcoind getnewaddress</p>
  
  <p>n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv</p>
  
  <p>$ ./bitcoind dumpprivkey n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv</p>
  
  <p>cR4RtpaeAZY8MwrNvTQGX9PZ9pdCgFoLxuo4Pkwqx61broC4Gb4y</p>
</blockquote>

<p>And on another wallet:</p>

<blockquote>
  <p>$ ./bitcoind importprivkey R4RtpaeAZY8MwrNvTQGX9PZ9pdCgFoLxuo4Pkwqx61broC4Gb4y</p>
  
  <p>$ ./bitcoind validateaddress n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv</p>
  
  <p>{
      "isvalid" : true,
      "address" : "n2JjZgLeCUgfubswxDm9zAaBGSLLHSLdNv",
      "ismine" : true,
      "pubkey" : "029e3a934cfc9f89d7a1c15f99b98479cabc81964f4972e7b8fa3989a788261695",
      "iscompressed" : true,
      "account" : ""
  }</p>
</blockquote>
