Bitcoin Forum

Other => Beginners & Help => Topic started by: mistersisco on August 09, 2013, 08:17:00 AM



Title: Importing vanitygen txt file into mysql database
Post by: mistersisco on August 09, 2013, 08:17:00 AM
I am trying to import some vanitygen created Bitcoin addresses into a sql database.
The vanitygen .txt data looks like this :

Pattern : 1
Address : 1btcwefhhiZUzjcilcdjcdijcdicd     
Privaddress : 5kihfrierhf8hfreriierhow8945h4589
Pattern : 1
Address : 1ltcwbvwerbvuhiBGUOGZo12gg23413g     
Privaddress : 5ZVGOUVZouvzuvocdzgwe8of7g487gbf73o
Pattern : 1
Address : 1ppczif868tgfouiblfuhipfh45pfh45f     
Privaddress : 5BBHJogzup98zhpf489f5h4pf45fp894f89     


This is just a example of pub. and priv. key I am trying to import this into a sqldatabase which name is bitcoin and the table is called one with the files pattern, address and privaddress.

mysql> LOAD DATA LOCAL INFILE '/path/one.txt' INTO TABLE one

COLUMNS TERMINATED BY     ????



   







Title: Re: Importing vanitygen txt file into mysql database
Post by: Snub on August 09, 2013, 09:14:39 AM
What operating system are you using?

Are you physically at the system or are you connecting through a ssh?


Title: Re: Importing vanitygen txt file into mysql database
Post by: J35st3r on August 09, 2013, 11:25:20 AM
You need to reformat your input so that each table row is on one line.

As snub said, it really depends on your OS and what tools you have available, but this is a perl script to do it

Code:
while (<>) {
chomp;
if (/^Pattern: (.*)/) { $pattern = $1; }
if (/^Address: (.*)/) { $address = $1; }
if (/^Privkey: (.*)/) {
$privkey = $1;
print "$pattern\t$address\t$privkey\n";
}
}

It runs as a filter
$ perl join.pl <input.txt >output.txt

If your vanitygen is labelling the Privkey as Privaddress, you'll need to change the code slightly ... if (/^Privaddress: (.*)/) {


Title: Re: Importing vanitygen txt file into mysql database
Post by: mistersisco on August 09, 2013, 01:43:38 PM
Thanks for the posts, sorry made an mistake I am running mysql not sql like in my first post. I am using Ubuntu the newest release an 64bit processor and I am using the command line for the mysql. I am running the server on my own system (LOCAL).




Title: Re: Importing vanitygen txt file into mysql database
Post by: J35st3r on August 09, 2013, 01:57:01 PM
Thanks for the posts, I am using Ubuntu the newest release an 64bit processor and I am using the command line for the mysql. I am running the server on my own system (LOCAL).
Then you should be fine with the perl script, you may want to add the top line
#!/usr/bin/perl
and "chmod +x join.pl" (assuming you save it as that), to make it executable stand-alone.

I assume the
Quote
Pattern : 1
Address : 1btcwefhhiZUzjcilcdjcdijcdicd     
Privaddress : 5kihfrierhf8hfreriierhow8945h4589
is a typo as my vanitygen gives
Quote
$ vanitygen 1x
Difficulty: 1353
Pattern: 1x
Address: 1x37ithpwe4pnP4pJUm13LXKEJa2bhsCE
Privkey: 5J3cvzKQN8S5GWnFUF6xbiLvkD56cV6mXjA9WPtYiLWu1SZBVzd
Note the lack of a space before the ":", and Privkey rather than Privaddress. The script will work for my output but not yours (its easy to tweak though).

Then again, looking at those outputs, your Privaddress is 33 chars, while my Privkey is the standard 51, so perhaps I'm misunderstanding what you are doing there. No matter, just tweak the perl script to match your input.