<p>Importing could be done with <a href="https://bitcointalk.org/index.php?topic=34028.0">Pywallet</a> or hopefully soon-to-be-official <a href="https://bitcointalk.org/index.php?topic=8091.0">wallet export/import bitcoin patch</a>, but make sure to backup your wallet first.</p>

CC BY-SA 3.0
2011-12-17T19:15:04.563Z
Pywallet doesn't work on Mac.  When the patch is official, will it be a part of the normal version of the client?
shoeless joe
CC BY-SA 3.0
2011-12-17T19:42:08.153Z
@shoeless joe, that is wrong because "Pywallet is a python script that deals with wallets and keys" and "Confirmed to work on:
 Ubuntu 32bit(me),
 Windows 32bit(me) 64bit(ctoon6),
 OSX(defxor)" , as for the patch, I think you better ask Gavin
Serith
CC BY-SA 3.0
2011-12-18T08:46:07.110Z
What I mean is that it doesn't work on Mac unless you load a thousand non-native programs: https://bitcointalk.org/index.php?topic=34028.msg437850#msg437850
shoeless joe
CC BY-SA 3.0
2012-04-30T14:23:10.830Z
Quite disappointing: seems you have to import keys one by one?
o0'.
CC BY-SA 3.0
2012-05-04T01:09:36.973Z
The answer was written a while ago, a lot has changed since then, and I remember some buzz about the functionality on forum. Maybe someone made an improvement, my first guess would be to look at Armory client: http://bitcoinarmory.com/
Serith
CC BY-SA 3.0
2011-12-17T01:06:47.770Z
2011-12-17T01:06:47.770Z
Serith
<p>An answer to <a href="https://bitcoin.stackexchange.com/a/4205/659">How can I export the private key for an address from the satoshi client?</a> gives the steps required to export a private key. The steps to import a private key are the same except that you need to change "dumpprivkey 1aaabbb..." to "importprivkey 5aaabbb...".</p>

<p>If you use bitaddress.org's "Bulk Wallet" feature you can generate a list of private keys, like this:</p>

<pre><code>1,"1AWUTMBC3XuTnPugwznNoju37ptACYRJyn","5K4dStGTDUR4r9yCwe7DqLunr5o7fjs2rH1Qb7KQg76d6KASGqv"
2,"1QKvh1wy8Vgri7BCGnY3XiXsdoX8SpzYTK","5JT6RJLjkKp5UDkkBsTNjNFgoo8o3bB3qK1qvsxKawCjh8X4pQQ"
3,"171er29jxgoUw5GNZFRF5w7FCUeXvPHbyK","5KBmhDfAEPDTd9asLCYcWaJNkc9KNvBmFoZzPTWfCdq3CaLePAB"
</code></pre>

<p>To import all the private keys into your wallet:</p>

<ol>
<li>copy/paste the list into a temporary file, <code>/tmp/bitaddress.txt</code> making sure there's a newline on the end of the last line</li>
<li><code>tr -d '"' &lt; /tmp/bitaddress.txt | tr , ' ' | while read number address privkey; do echo importing $address; bitcoind importprivkey $privkey; done</code></li>
</ol>

<p>Note: if you're running Windows you'll need to modify the command in step 2 to whatever the equivalent Windows shell command would be.</p>

<p>Note 2: <strike>the <code>importprivkey</code> command is very slow since it rescans the whole transaction history after each private key import.  It's possible to speed it up considerably by <a href="https://bitcointalk.org/index.php?topic=43496.msg1065765#msg1065765" rel="nofollow noreferrer">commenting out two lines in the bitcoind source code</a>.</strike></p>

<p>Note 3: importprivkey now has an optional rescan option which you can set to false. This will make importing much faster, and you don't have to edit the source code.</p>

CC BY-SA 3.0
2013-08-22T01:39:01.947Z
Excellent answer. I'd like to point out that importprivkey now has an optional rescan option which you can set to false. This will make importing much faster, and you don't have to edit the source code.
timetofly
CC BY-SA 3.0
2014-08-09T08:52:38.587Z
About the note 3 what the implications of avoid the rescan? The rescan should be made anyway after importing a bunch of private keys or can be always "false"?
Felipe
CC BY-SA 3.0
2012-08-06T17:07:15.463Z
Hi Chris, this is a very good answer, but it presupposes that bitcoind is running on my computer, which it is not.  So how do I get bitcoind running so I can give it the importaprivkey command?
shoeless joe
CC BY-SA 3.0
2012-08-06T22:18:06.457Z
You don't need the bitcoind server running.  The regular bitcoin-qt program will act as a server if you start it with the -server argument.  You will need the bitcoind program to act as the client though.  Do you have a copy of the bitcoind program?  I thought it came with bitcoin-qt, but maybe that's not true.
Chris Moore
CC BY-SA 3.0
2012-08-07T20:51:43.307Z
Yes, I have the bitcoin-qt program.  I could start it in a Terminal window using -server argument.  I can't find bitcoind on the bitcoin.org website and it is not in the bundle for MacOS.
shoeless joe
CC BY-SA 3.0
2012-08-08T00:38:44.833Z
See http://bitcoin.stackexchange.com/a/4251/659 - it appears that you will need to build bitcoind from source.
Chris Moore
CC BY-SA 3.0
2012-08-10T03:24:00.647Z
So the whole thing falls apart again and I am left doing really hacky things with lots of programs and libraries.
shoeless joe
CC BY-SA 3.0
2012-08-04T16:29:31.553Z
2014-08-10T08:36:28.453Z
2017-04-13T12:47:34.187Z
Chris Moore
<p>I have a private key and I want to add it to the keys in the Bitcoin client.  Is there an easy way to do this?</p>

<bitcoin-core>
How can I import a private key into the Bitcoin client?
shoeless joe
# How can I import a private key into the Bitcoin client?

(Asked by: username_0 on 2011-12-16)

I have a private key and I want to add it to the keys in the Bitcoin client. Is there an easy way to do this?

**Tags:** bitcoin-core


---

## 2 answers

### Answer by username_1 on 2011-12-17. Score: 7

Importing could be done with [Pywallet](https://bitcointalk.org/index.php?topic=34028.0) or hopefully soon-to-be-official [wallet export/import bitcoin patch](https://bitcointalk.org/index.php?topic=8091.0), but make sure to backup your wallet first.

> **Comments:**
> **username_0**: Pywallet doesn't work on Mac.  When the patch is official, will it be a part of the normal version of the client?  
> **username_1**: @username_0, that is wrong because "Pywallet is a python script that deals with wallets and keys" and "Confirmed to work on:  Ubuntu 32bit(me),  Windows 32bit(me) 64bit(ctoon6),  OSX(defxor)" , as for the patch, I think you better ask Gavin  
> **username_0**: What I mean is that it doesn't work on Mac unless you load a thousand non-native programs: https://bitcointalk.org/index.php?topic=34028.msg437850#msg437850  
> **username_2**: Quite disappointing: seems you have to import keys one by one?  
> **username_1**: The answer was written a while ago, a lot has changed since then, and I remember some buzz about the functionality on forum. Maybe someone made an improvement, my first guess would be to look at Armory client: http://bitcoinarmory.com/  

---

### Answer by username_3 on 2012-08-04. Score: 4

An answer to [How can I export the private key for an address from the satoshi client?](https://bitcoin.stackexchange.com/a/4205/659) gives the steps required to export a private key. The steps to import a private key are the same except that you need to change "dumpprivkey 1aaabbb..." to "importprivkey 5aaabbb...".

If you use bitaddress.org's "Bulk Wallet" feature you can generate a list of private keys, like this:

```
1,"1AWUTMBC3XuTnPugwznNoju37ptACYRJyn","5K4dStGTDUR4r9yCwe7DqLunr5o7fjs2rH1Qb7KQg76d6KASGqv"
2,"1QKvh1wy8Vgri7BCGnY3XiXsdoX8SpzYTK","5JT6RJLjkKp5UDkkBsTNjNFgoo8o3bB3qK1qvsxKawCjh8X4pQQ"
3,"171er29jxgoUw5GNZFRF5w7FCUeXvPHbyK","5KBmhDfAEPDTd9asLCYcWaJNkc9KNvBmFoZzPTWfCdq3CaLePAB"

```

To import all the private keys into your wallet:

1. copy/paste the list into a temporary file, `/tmp/bitaddress.txt` making sure there's a newline on the end of the last line
2. `tr -d '"' < /tmp/bitaddress.txt | tr , ' ' | while read number address privkey; do echo importing $address; bitcoind importprivkey $privkey; done`

Note: if you're running Windows you'll need to modify the command in step 2 to whatever the equivalent Windows shell command would be.

Note 2: the `importprivkey` command is very slow since it rescans the whole transaction history after each private key import. It's possible to speed it up considerably by [commenting out two lines in the bitcoind source code](https://bitcointalk.org/index.php?topic=43496.msg1065765#msg1065765).

Note 3: importprivkey now has an optional rescan option which you can set to false. This will make importing much faster, and you don't have to edit the source code.

> **Comments:**
> **username_0**: Hi username_3, this is a very good answer, but it presupposes that bitcoind is running on my computer, which it is not.  So how do I get bitcoind running so I can give it the importaprivkey command?  
> **username_3**: You don't need the bitcoind server running.  The regular bitcoin-qt program will act as a server if you start it with the -server argument.  You will need the bitcoind program to act as the client though.  Do you have a copy of the bitcoind program?  I thought it came with bitcoin-qt, but maybe that's not true.  
> **username_0**: Yes, I have the bitcoin-qt program.  I could start it in a Terminal window using -server argument.  I can't find bitcoind on the bitcoin.org website and it is not in the bundle for MacOS.  
> **username_3**: See http://bitcoin.stackexchange.com/a/4251/659 - it appears that you will need to build bitcoind from source.  
> **username_0**: So the whole thing falls apart again and I am left doing really hacky things with lots of programs and libraries.  
> **username_4**: Excellent answer. I'd like to point out that importprivkey now has an optional rescan option which you can set to false. This will make importing much faster, and you don't have to edit the source code.  
> **username_5**: About the note 3 what the implications of avoid the rescan? The rescan should be made anyway after importing a bunch of private keys or can be always "false"?  

---

