<p>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. </p>

<p>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.</p>

<p>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. </p>

CC BY-SA 3.0
2014-10-06T15:33:15.737Z
Thanks! But this means for each key, the whole blockchain would be scanned right? I would actually like to 'sweep' and not import
happyvirus
CC BY-SA 3.0
2014-10-06T15:34:41.713Z
I'm not sure if what I'm asking is practical, I think I better drop the question
happyvirus
CC BY-SA 3.0
2014-10-06T16:15:00.180Z
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
CC BY-SA 3.0
2014-10-07T01:13:40.070Z
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
CC BY-SA 3.0
2014-10-07T01:21:41.060Z
Do those alternative clients allow batch import? Is that why you switched?
morsecoder
CC BY-SA 3.0
2014-10-07T02:20:10.003Z
They do actually allow batch import( tested upto 50K private keys in Multibit) but of course you'll agree that a CLI would be fast and much more reliable?
happyvirus
CC BY-SA 3.0
2014-10-06T14:35:29.367Z
2014-10-06T14:35:29.367Z
morsecoder
<p>How do I import private keys en mass from a text file? They are in Wallet Import Format, e.g. 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ.</p>

<p>Would there be any limitations to the number of keys I can import?</p>

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

CC BY-SA 3.0
2014-10-06T03:59:37.777Z
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
CC BY-SA 3.0
2014-10-06T04:42:09.400Z
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
CC BY-SA 3.0
2014-10-06T05:06:33.923Z
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
CC BY-SA 3.0
2014-10-06T06:09:15.857Z
@Nick actually I meant sweeping and not importing! They're both different right?
happyvirus
CC BY-SA 3.0
2014-10-06T06:12:10.657Z
@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
CC BY-SA 3.0
2014-10-06T06:17:26.747Z
Thanks! Is there any way to load up a text file( or maybe a .bat file) with private keys and run them in a client with a gui or cli?
happyvirus
<private-key>
How do I import private keys en mass from a text file?
happyvirus
# How do I import private keys en mass from a text file?

(Asked by: username_0 on 2014-10-06)

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.

**Tags:** private-key

> **Comments:**
> **username_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.  
> **username_2**: I've tried to edit this to clarify the question. Asker, please let me know if I understood what you're asking correctly. Thanks!  
> **username_0**: 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 :)  
> **username_0**: @Nick actually I meant sweeping and not importing! They're both different right?  
> **username_2**: @user3079309 They are. Sweeping usually means moving bitcoins from many addresses to a single address, whereas importing doesn't make any transactions at all.  
> **username_0**: Thanks! Is there any way to load up a text file( or maybe a .bat file) with private keys and run them in a client with a gui or cli?  

---

## 1 answers

### Answer by username_3 on 2014-10-06. Score: 0 | Accepted answer

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.

> **Comments:**
> **username_0**: Thanks! But this means for each key, the whole blockchain would be scanned right? I would actually like to 'sweep' and not import  
> **username_0**: I'm not sure if what I'm asking is practical, I think I better drop the question  
> **username_3**: 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.  
> **username_0**: 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.  
> **username_3**: Do those alternative clients allow batch import? Is that why you switched?  
> **username_0**: They do actually allow batch import( tested upto 50K private keys in Multibit) but of course you'll agree that a CLI would be fast and much more reliable?  

---

