Bitcoin Forum
May 05, 2024, 09:26:56 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Patch to add a "rescan" option to importprivkey  (Read 2183 times)
CIYAM (OP)
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
September 05, 2012, 12:18:57 PM
Last edit: September 06, 2012, 08:50:11 AM by CIYAM Pty. Ltd.
 #1

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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
1714901216
Hero Member
*
Offline Offline

Posts: 1714901216

View Profile Personal Message (Offline)

Ignore
1714901216
Reply with quote  #2

1714901216
Report to moderator
1714901216
Hero Member
*
Offline Offline

Posts: 1714901216

View Profile Personal Message (Offline)

Ignore
1714901216
Reply with quote  #2

1714901216
Report to moderator
"Bitcoin: mining our own business since 2009" -- Pieter Wuille
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714901216
Hero Member
*
Offline Offline

Posts: 1714901216

View Profile Personal Message (Offline)

Ignore
1714901216
Reply with quote  #2

1714901216
Report to moderator
1714901216
Hero Member
*
Offline Offline

Posts: 1714901216

View Profile Personal Message (Offline)

Ignore
1714901216
Reply with quote  #2

1714901216
Report to moderator
1714901216
Hero Member
*
Offline Offline

Posts: 1714901216

View Profile Personal Message (Offline)

Ignore
1714901216
Reply with quote  #2

1714901216
Report to moderator
CIYAM (OP)
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
September 07, 2012, 02:58:31 AM
 #2

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

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
jasinlee
Hero Member
*****
Offline Offline

Activity: 742
Merit: 500


Its as easy as 0, 1, 1, 2, 3


View Profile
September 07, 2012, 03:01:25 AM
 #3

I see the potential, will try and give it a whirl when I get back form vacation.

BTC 1JASiNZxmAN1WBS4dmGEDoPpzN3GV7dnjX DVC 1CxxZzqcy7YEVXfCn5KvgRxjeWvPpniK3                     Earn Devcoins Devtome.com
CIYAM (OP)
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
September 07, 2012, 03:27:32 AM
 #4

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

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
jasinlee
Hero Member
*****
Offline Offline

Activity: 742
Merit: 500


Its as easy as 0, 1, 1, 2, 3


View Profile
September 07, 2012, 04:13:54 AM
 #5

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)

BTC 1JASiNZxmAN1WBS4dmGEDoPpzN3GV7dnjX DVC 1CxxZzqcy7YEVXfCn5KvgRxjeWvPpniK3                     Earn Devcoins Devtome.com
CIYAM (OP)
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
September 07, 2012, 04:50:20 AM
 #6

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 <file> <findstr> <replace>"
 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.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
September 07, 2012, 04:58:28 AM
 #7

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?

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
jasinlee
Hero Member
*****
Offline Offline

Activity: 742
Merit: 500


Its as easy as 0, 1, 1, 2, 3


View Profile
September 07, 2012, 05:07:30 AM
 #8

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.

BTC 1JASiNZxmAN1WBS4dmGEDoPpzN3GV7dnjX DVC 1CxxZzqcy7YEVXfCn5KvgRxjeWvPpniK3                     Earn Devcoins Devtome.com
arsenische
Legendary
*
Offline Offline

Activity: 1199
Merit: 1012


View Profile
November 05, 2012, 05:34:04 PM
 #9

I applied your patch and successfully imported 33402 keys to my new wallet.dat. Thanks a lot!

BitcoinHoarder
Full Member
***
Offline Offline

Activity: 144
Merit: 100


View Profile
December 06, 2012, 03:05:11 AM
 #10

This would benefit me too.

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

https://github.com/bitcoin/bitcoin/issues/1085
BitcoinHoarder
Full Member
***
Offline Offline

Activity: 144
Merit: 100


View Profile
December 07, 2012, 02:30:42 AM
 #11

Looks like we are moving forward on this: https://github.com/bitcoin/bitcoin/pull/2080
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!