Bitcoin Forum
November 10, 2024, 12:48:36 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Importing many privkeys into bitcoin-qt?  (Read 1374 times)
SebastianJu (OP)
Legendary
*
Offline Offline

Activity: 2674
Merit: 1083


Legendary Escrow Service - Tip Jar in Profile


View Profile WWW
August 15, 2015, 06:36:37 PM
 #1

I wonder if there is a way to import many privkeys into bitcoin-qt easily without having to copy one line per address. I tried adding a couple commands at one time but doesn't work. The same goes for providing several keys in one line.

Is there a way to use the importprivkey command with several keys at a time or does the console allow to enter multiple commands in one line?

Creating such command would be no problem with calc. Only i don't want to copy so many lines one by one.

Please ALWAYS contact me through bitcointalk pm before sending someone coins.
BitcoinAddicts
Hero Member
*****
Offline Offline

Activity: 502
Merit: 500


View Profile
August 15, 2015, 07:10:41 PM
 #2

I don't think there is a way to import multiple privatekeys to bitcoin qt wallet, you have to import them one by one. to make this process fast you can disable scan of the address when importing the key so it won't take long time to import a single key as usual,
read this post, it may help you
https://bitcointalk.org/index.php?topic=886599.msg9805886#msg9805886

     ▄█
   ▄██▌
 ▄████
▀▀▀█████▀
  ▐███▀
  ██▀
  ▀
.
▄▄▄███████▄▄▄
▄▄█████████████████▄▄
▄███████████████████████▄
███████████████████████████
██████████
███████████████████
██████████
█████████████████████
█████████████████████████████
█████████████████████████████
██
███████████████████████████
██
█████████████████████████
███████████████████████
▀▀█████████████████▀▀

▀▀▀███████▀▀▀
▄▄▄███████▄▄▄
▄▄█▀▀███████████▀▀█▄▄
▄████▄▄███████████▄▄████▄
█████
███▀▀▄▄▄▄▄▄▄▀▀████████
█████
██▀▄██████▀████▄▀███████
███████▀▄█████▀ ▐█████▄▀███████
██  ███ ████▀   ▀▀█████ ███  ██
██████▄▀█████  ▄█████▀▄██████
██████▄▀███▌▄██████▀▄██████
██
██████▄▄▀▀▀▀▀▀▀▄▄████████
▀█
███▀▀███████████▀▀████▀
▀▀█▄▄███████████▄▄█▀▀
▀▀▀███████▀▀▀
▄▀▀▀▀▀▀▀▀▀▀█████████
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█████████████████████

██████████▄▀▀▀▀▀▀▀▀▀

▄▄▄████████████████████▄▄▄
████████████████████████████
██████████████████████████████
███████████████████████████████
███████████████████████████████
███████████████████████████
▀██
█████████▀   ▀███████████▀
▀▀█████▀▀       ▀▀█████▀▀
.
..SPORTS  │  CASINO  │  ESPORTS..
.
dserrano5
Legendary
*
Offline Offline

Activity: 1974
Merit: 1029



View Profile
August 15, 2015, 07:16:41 PM
 #3

Create a text file such as:

Code:
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z

And run:

Code:
importwallet /path/to/file
Nikinger
Full Member
***
Offline Offline

Activity: 141
Merit: 100



View Profile
August 15, 2015, 07:17:48 PM
 #4

Put all private keys in privkeys.txt, one private key per line.

On Linux:
Code:
touch btcimport.sh
chmod +x btcimport.sh
echo "#/bin/bash" >btcimport.sh
echo "" >>btcimport.sh
for i in `cat privkeys.txt`; do echo "bitcoin-cli importprivkey $i \"\" false" >>btcimport.sh; done
vi btcimport.sh and turn the last "false" to "true" in order to reindex after the last import
Then ./btcimport.sh

On Windows:
Code:
for /f %i in (privkeys.txt) do @(echo bitcoin-cli.exe importprivkey %i "" false >>btcimport.bat)
notepad btcimport.bat and turn the last "false" to "true" in order to reindex after the last import
on prompt, run btcimport.bat

I tested the generation script only - haven't tried to run the importprivkey bash/batch script itsself, it's possible that you have to adapt the script for your system.

1EwKrY5Bn3T47r4tYqSv6mMQkUyu7hZckV
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
August 15, 2015, 07:18:38 PM
 #5

If you have a text file with all of the private keys in them, you can use a shell script to iterate through the file and import each key.

SebastianJu (OP)
Legendary
*
Offline Offline

Activity: 2674
Merit: 1083


Legendary Escrow Service - Tip Jar in Profile


View Profile WWW
August 18, 2015, 11:47:33 AM
 #6

Thank you guys for the tips. Smiley

Create a text file such as:

Code:
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z

And run:

Code:
importwallet /path/to/file

I would have been never got the idea that a wallet.dat file can be created that way. Or is it only a simplified import that works with that command?

Anyway... i will try that first since it looks like the easiest solution.

Please ALWAYS contact me through bitcointalk pm before sending someone coins.
SebastianJu (OP)
Legendary
*
Offline Offline

Activity: 2674
Merit: 1083


Legendary Escrow Service - Tip Jar in Profile


View Profile WWW
August 18, 2015, 09:41:39 PM
 #7

Create a text file such as:

Code:
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z
5abc...privkeyhere 2015-08-15T00:00:00Z

And run:

Code:
importwallet /path/to/file

This actually worked like a charm. I would have not awaited that you can create a wallet file that way though it worked fine. Smiley

Thanks again.

Please ALWAYS contact me through bitcointalk pm before sending someone coins.
D3m0nKinGx
Hero Member
*****
Offline Offline

Activity: 1638
Merit: 507


The snake which cannot cast its skin has to die


View Profile
August 22, 2016, 09:16:46 AM
 #8

Here's a super easy script to import multiple keys into bitcoin-cli

$ touch import.sh
$ nano import.sh

paste this code:

Code:
#!/bin/bash

Filename=”privkeys.txt”

while IFS='' read -r line || [[ -n "$line" ]]; do

    echo "Text read from file: $line"

    bitcoin-cli importprivkey $line true

done < "$Filename"

$ chmod +x import.sh
$ ./import.sh


**make sure the import.sh and privkeys.txt files are in the same location!**

.
.
.
▬◇
▬◇▬◆
▬◇▬◇▬◆
.
.







███
███░░░███
███░░░░░░░░░███
███░░░░░░░░░░░░░░░███
███░░░░░░░░░░░░░░░░░░░░░███
███░░░░░░░░░░░░░░░░░░░░░░░░░░░███
███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███
███░░░░░░░░░░░░░░░░░░░░░░░░░░░███
███░░░░░░░░░░░░░░░░░░░░░███
███░░░░███░░░░░░░░░░░░░░░███░░░░███
███░░░░░░░░░███░░░░░░░░░███░░░░░░░░░███
███░░░░░░░░░███░░░███░░░░░░░░░███
███░░░░░░░░░███░░░░░░░░░███
███░░░░███░░░░░░░░░░░░░░░███░░░░███
███░░░░░░░░░███░░░░░░░░░███░░░░░░░░░███
███░░░░░░░░░███░░░███░░░░░░░░░███
███░░░░░░░░░███░░░░░░░░░███
███░░░░░░░░░░░░░░░███
███░░░░░░░░░███
███░░░███
███
.
.
.
◇▬
◆▬◇▬
◆▬◇▬◇▬
.
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!