How do I import private keys en mass from a text file? They are in Wallet Import Format, e.g. 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ.

Would there be any limitations to the number of keys I can import?

Thank you and please forgive me for such a question, I'm quite new to this.

  • 1
    We need a lot more details. What OS, what format private keys (WIF, Mini, hex), which client, what format of wallet are the privkeys in now? More details would help. – Wizard Of Ozzie Oct 6 '14 at 3:59
  • I've tried to edit this to clarify the question. Asker, please let me know if I understood what you're asking correctly. Thanks! – Nick ODell Oct 6 '14 at 4:42
  • OS: Windows Private key: WIF, I checked Client: I'm not sure actually. Hope you can suggest me one Additionally, I suppose a CLI that could sweep keys from a text file would be fast enough right? If there is a such a thing yet Thank you! @Nick thanks for editing the question :) – happyvirus Oct 6 '14 at 5:06
  • @Nick actually I meant sweeping and not importing! They're both different right? – happyvirus Oct 6 '14 at 6:09
  • @user3079309 They are. Sweeping usually means moving bitcoins from many addresses to a single address, whereas importing doesn't make any transactions at all. – Nick ODell Oct 6 '14 at 6:12

Not sure on this, but you might be able to use the importprivkey RPC call. What I would try is importing one of them with rescan=false and then import another with rescan=true. The rescan=true causes it to go through the whole blockchain and look for any places that the associated address to that private key. After importing two private keys, the first without a rescan and the second with a rescan, then look to see if rescanning on the second private key got you all the transactions for the first private key that you entered.

Then if that works, you could write a command line script to execute that RPC call with each line of the file as the private key.

That's a high level description of what I would try. If you need more help on the importprivkey, open the Bitcoin-QT GUI, go to Help >> Debug Window >> Console and type "help importprivkey". If you need help writing that script, you'll probably have to do some googling around to learn about your OS-dependent scripting language.

| improve this answer | |
  • Thanks! But this means for each key, the whole blockchain would be scanned right? I would actually like to 'sweep' and not import – happyvirus Oct 6 '14 at 15:33
  • I'm not sure if what I'm asking is practical, I think I better drop the question – happyvirus Oct 6 '14 at 15:34
  • I mean, there should be a way to do what you are asking for. And no, hopefully you wouldn't have to do a rescan for every key, that would take forever. My proposed idea was to set the rescan flag to be false for all but the last private key you are importing. If you didn't need to rescan at all, then don't even set rescan=true on the last import. – morsecoder Oct 6 '14 at 16:15
  • I have started to look into this with all seriousness. Thank you for your valuable input. For now, I'll have to do with GUI clients such as Armory / Multibit because of my limited knowledge of this subject. – happyvirus Oct 7 '14 at 1:13
  • Do those alternative clients allow batch import? Is that why you switched? – morsecoder Oct 7 '14 at 1:21

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.