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?
An answer to How can I export the private key for an address from the satoshi client? 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:
- copy/paste the list into a temporary file,
/tmp/bitaddress.txtmaking sure there's a newline on the end of the last line
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.
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.
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.