Author

Topic: Patch to add a "rescan" option to importprivkey (Read 2205 times)

full member
Activity: 146
Merit: 103
December 06, 2012, 09:30:42 PM
#11
Looks like we are moving forward on this: https://github.com/bitcoin/bitcoin/pull/2080
full member
Activity: 146
Merit: 103
This would benefit me too.

There is an open issue on github.com/bitcoin on this also.

https://github.com/bitcoin/bitcoin/issues/1085
legendary
Activity: 1199
Merit: 1012
I applied your patch and successfully imported 33402 keys to my new wallet.dat. Thanks a lot!
hero member
Activity: 742
Merit: 500
Its as easy as 0, 1, 1, 2, 3
Thanks for all the cmd line ideas, going to test them out too when I get home. And good point on the genesis block, mayhap there should be a python patch for bitcoinqt that gives a full separate window with auto import and copy/paste function from a spreadsheet to make multiple payments at once without having to copy/paste each. There it is my full wishlist. So when I do my faucet payouts it wont take as long if I am not on bitcoind at the time.
kjj
legendary
Activity: 1302
Merit: 1026
What would be really handy would be a block hash or height number to tell it to rescan starting from there instead of from the genesis block.  Is there an easy way to turn either of the human-visible block identifiers into a CBlockIndex pointer?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
Hmm... well using the -o option to output to a file you could then pull out just the "privkey" lines with findstr.

So from a cmd shell:

Code:
C:\Program Files\Bitcoin>vanitygen -q -o x 1AB
C:\Program Files\Bitcoin>findstr "Privkey: " x > xx

The tricky bit is not now do a "search/replace" to turn the following:
Code:
C:\Program Files\Bitcoin>type xx
Privkey: 5J9eh7Fwwbji4L45xsLT4FskJWb7spJx1YekagS1vAdTAiHMwWX
Privkey: 5J2kSNfhhPzMdceaBbBxGdKaGmEDosFEYNVTpHcCKjTGo4UutZM
Privkey: 5KXbbBZjmv4TqnJttrhGy7tSWp8thDkesayyCCm1Ss3ZM9N8v3F

into something that looks like this:
Code:
C:\Program Files\Bitcoin>type xx
bitcoind -rpcpassword=password importprivkey 5J9eh7Fwwbji4L45xsLT4FskJWb7spJx1YekagS1vAdTAiHMwWX
bitcoind -rpcpassword=password importprivkey 5J2kSNfhhPzMdceaBbBxGdKaGmEDosFEYNVTpHcCKjTGo4UutZM
bitcoind -rpcpassword=password importprivkey 5KXbbBZjmv4TqnJttrhGy7tSWp8thDkesayyCCm1Ss3ZM9N8v3F

I'm not sure if newer versions of Windows have some sort of sed equivalent but from previous work I have the following .vbs script:
Code:
C:\Program Files\Bitcoin>type findrep.vbs

Const ForReading = 1
Const ForWriting = 2

If Wscript.Arguments.Count > 2 Then

strFileName = Wscript.Arguments(0)
strOldText = Wscript.Arguments(1)
strNewText = Wscript.Arguments(2)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close

Else
 Wscript.Echo "Usage: findrep "
 Wscript.Quit
End If


So you can use that to convert xx with the following:
Code:
findrep xx "Privkey:" "bitcoind -rpcpassword=password importprivkey"

Unfortunately it still doesn't give the empty quotes and "false" at the end of each line (to use the patched command) although for testing purposes you could always change the command to not do the scan by default.
hero member
Activity: 742
Merit: 500
Its as easy as 0, 1, 1, 2, 3
I was having oclvanity spit them into the .key file then using multibit to import them all. Been looking for a way to automate the process but havent found one yet, the vanitygen and oclvanity both spit out the address and the priv key when all I want in the file is the priv key. Any idea of a command to limit the output? (trying to do this all in windows binaries with current tools to make an easier process)
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
I see the potential, will try and give it a whirl when I get back form vacation.

Thanks for that and hope you have a great vacation. Smiley
hero member
Activity: 742
Merit: 500
Its as easy as 0, 1, 1, 2, 3
I see the potential, will try and give it a whirl when I get back form vacation.
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
No-one thinks this option would be useful?

I guess I must be the only person here who has imported lots of vanitygen keys on a slow machine. Sad
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
I've created a patch here: https://github.com/ciyam/bitcoin/tree/importprivkey_rescan_opt

This would be mostly useful when importing a lot of private keys (such as you might wish to do if using vanitygen to create a set of vanity addresses) especially when you know the public addresses for the keys you are importing have not been used.

I had posted about this in another thread but I guess it wasn't noticed so just thought I'd post it here.

Unfortunately I don't have the setup or time to actually compile and test it (too busy on my own project) so if someone else could do that it would be great (and I don't need any credit so if someone does take the time to compile and test it then they are welcome to push the patch as their own).
Jump to: