How do I import a private key into Bitcoin-Qt? bitcoind is nowhere to be found, and pywallet says it requires "bsddb" when I run it, which is also nowhere to be found. I generated some vanity addresses and I want to use them.
2 Answers
- Run Bitcoin-Core
- Select Help (to the right of Settings)
- Select Debug Window
- Select Console
- If you encrypted your wallet, unlock it by entering
walletpassphrase "YourLongPassphrase" 600
next to the > input box - Next to the > input box type
importprivkey <bitcoinprivkey>
(Note that the private key must not have spaces, remove them if they are included in your backup)
Example: importprivkey 5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS
-
Thanks! I had to do it twice, though. The first time it didn't show up and the second time it said error code -4 and it worked. Whatever works! Commented Dec 31, 2012 at 5:23
-
This might also be of help: bitcoin.stackexchange.com/a/13303/6375– ScottCommented Feb 21, 2014 at 0:32
-
5While adding multiple keys you may want to avoid a time consuming rescan after each key. To do so use the command
importprivkey <bitcoinprivkey> '' false
for each key andimportprivkey <bitcoinprivkey> '' true
for the last one. The blank label is needed to pass the true/false flag. Commented Jan 24, 2017 at 7:24 -
5This only works for non-pruned mode. If pruned, you can't import private keys. Also, Console is under 'Window' now, not Help. Latest version here: en.bitcoin.it/wiki/… Commented Jan 9, 2020 at 23:01
-
1If you get "Only legacy wallets are supported by this command (code -4)" it means that you try to import a private key into a descriptor wallet. Either use a legacy wallet or create descriptors for your private keys prior import. The latter is recommend. Commented Dec 19, 2022 at 21:58
For those of you looking to import your Vanity address into your BitCoin QT client, here are the instructions (source):
Backup Your Wallet Although this process is well tested and used you should always take another backup of your wallet.dat file before starting.
Open Debug Window Then go to menu: /Help/Debug Window and click on the tab - Console.
Unlock your wallet If your wallet is encrypted (I hope it is!) you must unlock it. If not just skip this step.
To do this just type into the box at the bottom:
walletpassphrase "YourLongPassphrase" 600
You need the quotes if there is a space in your phrase else there is no need for them. The 600 means your wallet is unlocked for 10 minutes (600 seconds).
Run Import Command in Debug Window In the console at the very bottom is a text entry box. In here enter:
importprivkey yourPrivateKeyInWalletImportFormat "TheLabelThatIWant"
The private key must not have any spaces, remove them if they existt in your backup. The label may have spaces, the quotes are only needed if you want a space in the label.
You now have to be patient. On a fast PC it takes 2 minutes to import, and during this time it looks like you application has hung. You are now done. But always best to check it worked.
Check Key Imported OK Once Imported you can check that you have the address by closing the Debug window and going back to your address book. You should see the address here.
- Restart your BitCoin QT Client to see the new address in your Receive "Tab"
Backup Wallet Your backup of your wallet will not have this key in obviously. So before you do anything else backup the wallet.dat file as normal.
-
re: "yourPrivateKeyInWalletImportFormat" is that WIF Compressed or WIF Uncompressed? Commented Jan 20, 2021 at 18:41