Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Monopoly on April 04, 2015, 01:33:18 PM



Title: Import Multi privkey in bitcoin core ?
Post by: Monopoly on April 04, 2015, 01:33:18 PM
How to Import Multi privkey into bitcoin core at same time ( once ) , not separately ?


Title: Re: Import Multi privkey in bitcoin core ?
Post by: Amph on April 04, 2015, 03:14:33 PM
it's better to use those private keys to sign raw transactions, than importing them, it's faster

https://en.bitcoin.it/wiki/Raw_Transactions


or you can do a script to do it for you, because i don't think it is possible via command-line


Title: Re: Import Multi privkey in bitcoin core ?
Post by: grue on April 05, 2015, 04:36:19 AM
by using a script that calls importprivkey repeately?


Title: Re: Import Multi privkey in bitcoin core ?
Post by: coinableS on April 05, 2015, 05:33:36 AM
Is the reason you want to do multiple at once instead of one at a time due to the rescan?

You can add a false parameter at the end to skip the rescanning process, just rescan on the last private key you import. Should help make the process a bit quicker.

Code:
importprivkey 5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "label" false


Title: Re: Import Multi privkey in bitcoin core ?
Post by: InceptionCoin on April 05, 2015, 07:12:31 AM
Is the reason you want to do multiple at once instead of one at a time due to the rescan?

You can add a false parameter at the end to skip the rescanning process, just rescan on the last private key you import. Should help make the process a bit quicker.

Code:
importprivkey 5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "label" false
How should it work? What is 5xxxxxxxxxx? Is it privkey of one addr or somehow compressed set of privkeys?


Title: Re: Import Multi privkey in bitcoin core ?
Post by: shorena on April 05, 2015, 07:35:50 AM
Is the reason you want to do multiple at once instead of one at a time due to the rescan?

You can add a false parameter at the end to skip the rescanning process, just rescan on the last private key you import. Should help make the process a bit quicker.

Code:
importprivkey 5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "label" false
How should it work? What is 5xxxxxxxxxx? Is it privkey of one addr or somehow compressed set of privkeys?

5xx... is a placeholder for a single private key. You would have to write some sort of loop that iterates over a list of private keys and calls the above function on bitcoin.


Title: Re: Import Multi privkey in bitcoin core ?
Post by: S4VV4S on April 05, 2015, 08:25:43 AM
This will answer your question: https://bitcointalk.org/index.php?topic=342872.0 (https://bitcointalk.org/index.php?topic=342872.0)


Title: Re: Import Multi privkey in bitcoin core ?
Post by: emrebey on April 05, 2015, 10:35:00 AM
if you have a text file including private keys, you can easily write a script to import them. rescan should be at the last importprivkey command.


Title: Re: Import Multi privkey in bitcoin core ?
Post by: btchris on April 05, 2015, 05:00:39 PM
How to Import Multi privkey into bitcoin core at same time , not separately ?

I don't think this has been answered yet; apologies if I missed it.

See here for details on the importwallet RPC command, which imports a bunch of privkeys from a single file at once, and does a single rescan for them at the end: https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822 (https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822)


Title: Re: Import Multi privkey in bitcoin core ?
Post by: Monopoly on August 10, 2015, 10:29:27 PM
How to Import Multi privkey into bitcoin core at same time , not separately ?

I don't think this has been answered yet; apologies if I missed it.

See here for details on the importwallet RPC command, which imports a bunch of privkeys from a single file at once, and does a single rescan for them at the end: https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822 (https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822)

Yes . My question has been answered yet even with your guiding .

I couldn't understand what is importwallet and where is the location of "fie name" and what's the format of "file name" and what is the content of "file name" .


Title: Re: Import Multi privkey in bitcoin core ?
Post by: Monopoly on August 10, 2015, 10:32:45 PM
if you have a text file including private keys, you can easily write a script to import them. rescan should be at the last importprivkey command.

No one write this script yet ? i am the first one that have this problem ?


Title: Re: Import Multi privkey in bitcoin core ?
Post by: tspacepilot on August 11, 2015, 06:16:23 AM
How to Import Multi privkey into bitcoin core at same time , not separately ?

I don't think this has been answered yet; apologies if I missed it.

See here for details on the importwallet RPC command, which imports a bunch of privkeys from a single file at once, and does a single rescan for them at the end: https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822 (https://bitcointalk.org/index.php?topic=712047.msg8051822#msg8051822)

Yes . My question has been answered yet even with your guiding .

I couldn't understand what is importwallet and where is the location of "fie name" and what's the format of "file name" and what is the content of "file name" .

For those following this thread, Monopoly seems to be following up about the post btchris linked him to:

For that number of addresses you really need a full-node client. (Armory or Core)

If you don't, then querying the lite-wallet servers will probably get you soft-banned from querying them (they'll view you as DOSing them)

I would use Core and write a script that will run the following RPC call for each private key
Code:
importprivkey <privatekey> "" False
(The private keys should be in WIF format and without the <> or any "" around them...)

The [ "" False ] part is a must. only remove that false (or change it to True) on the LAST private key you import...

If you don't, it will rescan the blockchain after every import and take a REAAAAALLLY long time, if it doesn't crash.




Maybe Armory has a better solution, but afaik bitcoind would be the best way to go.

I'd tend to agree with using Bitcoin Core, even though it looks like that's what you were using when the problem occurred. Bitcoin Core uses Berkeley DB as its wallet.dat format. Berkeley DB is a bit bloated, but it's mature, very scalable, and has some reasonably decent recovery tools. I'm not aware of any other client that would be equally scalable (not that I'm an expert on alternative clients though...).

As much as I like Armory, I don't think it would scale as well (although it's wallet format is nice and simple and more error-resistant than any other wallet format I'm aware of).

For importing, as an alternative you could use the RPC command:
Code:
importwallet "filename"

The wallet import format is a bunch of lines like so:

Code:
Kx2GEDGhepMhkUnymSFtrU2Q59KMPY75oYjBVofYV9032p5L4a2b 2014-06-19T00:58:01Z change=1 reserve=1 label=label%20with%20spaces

The first two fields are required. If you don't have the address creation time, you can replace that field with something meaningless (e.g. "DATE-UNKNOWN") but something needs to be there. The last three fields are each optional. Only a single rescan is done at the end of the file import, and if you do have all of the creation times, the rescan will intelligently start at the right time instead of starting at the genesis block.

So, Monopoly, "filename" is the name and path to the file which contains a list of private keys  in WIF format.  The contents of the file are what's shown in the second code block.  Each line should have at least two fields:

PRIVKEY DATESTAMP

I hope this helps.


Title: Re: Import Multi privkey in bitcoin core ?
Post by: shorena on August 11, 2015, 05:56:06 PM
if you have a text file including private keys, you can easily write a script to import them. rescan should be at the last importprivkey command.

No one write this script yet ? i am the first one that have this problem ?

I have a batch file from the spam keys, but I would not exactly call it a script since its just a modified textfile. I had a list of private keys so adding path\to\bitcoin\bitcoin-cli.exe importprivkey was easily done with search and replace. Just make sure the last file ends with true instead of false to trigger the rescan.

Code:
"C:\Program Files\Bitcoin\daemon\bitcoin-cli.exe" importprivkey Kx77AtZ3TZaLRHaRTVBtjdwSN9qn8phRqy3osFxShN6Qm7fH287T 000 false
"C:\Program Files\Bitcoin\daemon\bitcoin-cli.exe" importprivkey KwciCH5RRePGDzH85xU5iZb3oGPtRuanqHqJbgnRvF3DnWH6F17n 001 false
"C:\Program Files\Bitcoin\daemon\bitcoin-cli.exe" importprivkey Kz9EYSbrDVZACjUmgYNtP7sNT1DZDs3sB1xNXroj3vGz55xyPFfg 002 false
...