Pages:
Author

Topic: Vanity bitcoin addresses: a new way to keep your CPU busy (Read 29764 times)

hero member
Activity: 544
Merit: 506
I'm unable to find the option to attach files to posts, so I'm forced to copy paste this here:

Code:
diff -urpN orig/bitcoin-0.3.23/src/main.h bitcoin-0.3.23/src/main.h
--- orig/bitcoin-0.3.23/src/main.h 2011-06-12 01:17:13.000000000 +0200
+++ bitcoin-0.3.23/src/main.h 2011-06-26 00:16:53.531905670 +0200
@@ -84,6 +84,7 @@ FILE* OpenBlockFile(unsigned int nFile,
 FILE* AppendBlockFile(unsigned int& nFileRet);
 bool AddKey(const CKey& key);
 std::vector GenerateNewKey();
+std::vector GenerateNewKey(std::string vanity);
 bool AddToWallet(const CWalletTx& wtxIn);
 void WalletUpdateSpent(const COutPoint& prevout);
 int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
diff -urpN orig/bitcoin-0.3.23/src/rpc.cpp bitcoin-0.3.23/src/rpc.cpp
--- orig/bitcoin-0.3.23/src/rpc.cpp 2011-06-12 01:17:13.000000000 +0200
+++ bitcoin-0.3.23/src/rpc.cpp 2011-06-26 00:14:12.042318453 +0200
@@ -6,6 +6,7 @@
 #include "cryptopp/sha.h"
 #undef printf
 #include
+#include
 #include
 #include
 #ifdef USE_SSL
@@ -309,19 +310,61 @@ Value getinfo(const Array& params, bool
 }
 
 
+vector GenerateNewKey(string vanity)
+{
+    using namespace boost::xpressive;
+    sregex re = sregex::compile(vanity);
+
+    RandAddSeedPerfmon();
+    unsigned int tried = 0;
+    for (;;)
+    {
+        CKey key;
+        key.MakeNewKey();
+        string strAddress = PubKeyToAddress(key.GetPubKey());
+        ++tried;
+        if (tried%100000 == 0) printf("Vanity key tried %u\n", tried);
+        if (!regex_search(strAddress, re)) continue;
+
+        if (!AddKey(key))
+            throw runtime_error("GenerateNewKey() : AddKey failed");
+        return key.GetPubKey();
+    }
+}
+
+void VanitySearchThread(void* parg)
+{
+    Array* a = (Array*)parg;
+    string vanity = (*a)[1].get_str();
+    string strAddress = PubKeyToAddress(GenerateNewKey(vanity));
+    string strLabel = (*a)[0].get_str();
+
+    SetAddressBookName(strAddress, strLabel);
+
+    delete a;
+}
+
 Value getnewaddress(const Array& params, bool fHelp)
 {
-    if (fHelp || params.size() > 1)
+    if (fHelp || params.size() > 2)
         throw runtime_error(
-            "getnewaddress [account]\n"
+            "getnewaddress [account] [vanity]\n"
             "Returns a new bitcoin address for receiving payments.  "
             "If [account] is specified (recommended), it is added to the address book "
-            "so payments received with the address will be credited to [account].");
+            "so payments received with the address will be credited to [account]."
+            "If [vanity] is specified, is less than 10 characters, and is all valid"
+            "base58 characters, then an address containing that string is generated.");
 
     // Parse the account first so we don't generate a key if there's an error
     string strAccount;
     if (params.size() > 0)
         strAccount = AccountFromValue(params[0]);
+    if (params.size() > 1)
+    {
+        Array* a = new Array(params);
+        CreateThread(VanitySearchThread, (void*)a);
+        return "...searching...";
+    }
 
     // Generate a new key that is added to wallet
     string strAddress = PubKeyToAddress(GetKeyFromKeyPool());

Should apply cleanly to bitcoin-0.3.23.

wow this is like looking into a really old history book. Glad we have other vanity software to create wallets
legendary
Activity: 1974
Merit: 1029
I've successfully compiled the bitcoin client with the patch that implements the 'importprivkey' command. Would anyone trust me enough to try running it? It's for linux 64 bits (but I can compile it for 32 bits if requested).
member
Activity: 67
Merit: 130
If someone can make and PM me a link to a windows binary that'll help me create vanity addresses, I'd be extremely greatful and might even have a bit bitdecimals I can share in gratitude.. And I'm sure there's others that would be greatful too if you'd link it here... Cheesy
You probably need vanitygen.

"There are plenty of quality tools to do this right now already.  So why use vanitygen?  The main reason is that it is fast, about two orders of magnitude faster than the official bitcoin client with the vanity address patch applied."

source https://github.com/samr7/vanitygen
win32 binary http://www.sendspace.com/file/fu84yv
gpg signature http://insight.gotdns.org/~samr7/vanitygen-0.12-win32.zip.asc
forum thread http://forum.bitcoin.org/index.php?topic=25804.0

I also wrote a python script (pywallet.py, currently 1.1) specially for importing private keys generated by vanitygen.
It works directly with the database, so you have to shut down the bitcoin client to import a key.
Installing it is super-easy, a way easier than building the entire client with a showwallet patch.
Both python and bsddb module are available as binary distributions.
After installing run the script as "python.exe pywallet.py --importprivkey=".

python: http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi
bsddb: http://pybsddb-win.googlecode.com/files/bsddb3-5.1.2.win32-py2.7.exe (run as administrator)
pywallet: https://raw.github.com/joric/pywallet/master/pywallet.py

newbie
Activity: 34
Merit: 0
If someone can make and PM me a link to a windows binary that'll help me create vanity addresses, I'd be extremely greatful and might even have a bit bitdecimals I can share in gratitude.. And I'm sure there's others that would be greatful too if you'd link it here... Cheesy
newbie
Activity: 26
Merit: 0
I think vanity addresses are cool, e.g. for nonprofits that accept bitcoin donations, among a variety of similar scenarios.

So ByteCoin, I'd encourage you to go ahead with your service, if you really can convince folks that you wouldn't find out their private address.
legendary
Activity: 882
Merit: 1001
I'm unable to find the option to attach files to posts, so I'm forced to copy paste this here:

Code:
diff -urpN orig/bitcoin-0.3.23/src/main.h bitcoin-0.3.23/src/main.h
--- orig/bitcoin-0.3.23/src/main.h 2011-06-12 01:17:13.000000000 +0200
+++ bitcoin-0.3.23/src/main.h 2011-06-26 00:16:53.531905670 +0200
@@ -84,6 +84,7 @@ FILE* OpenBlockFile(unsigned int nFile,
 FILE* AppendBlockFile(unsigned int& nFileRet);
 bool AddKey(const CKey& key);
 std::vector GenerateNewKey();
+std::vector GenerateNewKey(std::string vanity);
 bool AddToWallet(const CWalletTx& wtxIn);
 void WalletUpdateSpent(const COutPoint& prevout);
 int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
diff -urpN orig/bitcoin-0.3.23/src/rpc.cpp bitcoin-0.3.23/src/rpc.cpp
--- orig/bitcoin-0.3.23/src/rpc.cpp 2011-06-12 01:17:13.000000000 +0200
+++ bitcoin-0.3.23/src/rpc.cpp 2011-06-26 00:14:12.042318453 +0200
@@ -6,6 +6,7 @@
 #include "cryptopp/sha.h"
 #undef printf
 #include
+#include
 #include
 #include
 #ifdef USE_SSL
@@ -309,19 +310,61 @@ Value getinfo(const Array& params, bool
 }
 
 
+vector GenerateNewKey(string vanity)
+{
+    using namespace boost::xpressive;
+    sregex re = sregex::compile(vanity);
+
+    RandAddSeedPerfmon();
+    unsigned int tried = 0;
+    for (;;)
+    {
+        CKey key;
+        key.MakeNewKey();
+        string strAddress = PubKeyToAddress(key.GetPubKey());
+        ++tried;
+        if (tried%100000 == 0) printf("Vanity key tried %u\n", tried);
+        if (!regex_search(strAddress, re)) continue;
+
+        if (!AddKey(key))
+            throw runtime_error("GenerateNewKey() : AddKey failed");
+        return key.GetPubKey();
+    }
+}
+
+void VanitySearchThread(void* parg)
+{
+    Array* a = (Array*)parg;
+    string vanity = (*a)[1].get_str();
+    string strAddress = PubKeyToAddress(GenerateNewKey(vanity));
+    string strLabel = (*a)[0].get_str();
+
+    SetAddressBookName(strAddress, strLabel);
+
+    delete a;
+}
+
 Value getnewaddress(const Array& params, bool fHelp)
 {
-    if (fHelp || params.size() > 1)
+    if (fHelp || params.size() > 2)
         throw runtime_error(
-            "getnewaddress [account]\n"
+            "getnewaddress [account] [vanity]\n"
             "Returns a new bitcoin address for receiving payments.  "
             "If [account] is specified (recommended), it is added to the address book "
-            "so payments received with the address will be credited to [account].");
+            "so payments received with the address will be credited to [account]."
+            "If [vanity] is specified, is less than 10 characters, and is all valid"
+            "base58 characters, then an address containing that string is generated.");
 
     // Parse the account first so we don't generate a key if there's an error
     string strAccount;
     if (params.size() > 0)
         strAccount = AccountFromValue(params[0]);
+    if (params.size() > 1)
+    {
+        Array* a = new Array(params);
+        CreateThread(VanitySearchThread, (void*)a);
+        return "...searching...";
+    }
 
     // Generate a new key that is added to wallet
     string strAddress = PubKeyToAddress(GetKeyFromKeyPool());

Should apply cleanly to bitcoin-0.3.23.
Can a trusted user here provide a windows binary of the bitcoin client with this patch? I've been trying to help my friend make vanity addresses for a while, but my windows compiling skills are very limited.
full member
Activity: 140
Merit: 100
BitVapes.com
Anyway to generate a vanity address in windows with the current bitcoin client? My friend wants one.

someone posted a working patch for the latest bitcoin source, it compiled fine for me in linux.  I verified it worked by having it "search" for a 1-byte vanity address 'a' and it gave me one.

I let it run for a few minutes trying to find one with 'BitVapes' but I'm sure it would take over 9,000 years.   I did notice it only tied to one cpu core so I kicked off multiple instances to max out my cpus before shutting it down for fear of melting my box on this basically futile but fun effort.
Is that the one in the first post of this thread?

no that one didn't work in the latest bitcoin sources, but here is the updated one
legendary
Activity: 882
Merit: 1001
Anyway to generate a vanity address in windows with the current bitcoin client? My friend wants one.

someone posted a working patch for the latest bitcoin source, it compiled fine for me in linux.  I verified it worked by having it "search" for a 1-byte vanity address 'a' and it gave me one.

I let it run for a few minutes trying to find one with 'BitVapes' but I'm sure it would take over 9,000 years.   I did notice it only tied to one cpu core so I kicked off multiple instances to max out my cpus before shutting it down for fear of melting my box on this basically futile but fun effort.
Is that the one in the first post of this thread?
member
Activity: 112
Merit: 10
Firstbits: 1yetiax
Aw, man! Looks like somebody generated a lot of words to be used at firstbits.com. I wanted a nice firstbits vanity address that would be essentially my nick, but 1yeti is gone. Sad I wasn't fast enough, now I'm 1yetiax. Angry

In case you want one of these, you are probably gonna have to pay him a premium.

They're not interested in case-sensitivity (unlike me) which gives them the edge.

This is why we can't have nice things!
newbie
Activity: 12
Merit: 2
It seems someone already played with cool-looking addresses/hashes back in 2010:
http://blockexplorer.com/address/11126yHiXjavR3oNVwV2GRNso2ah4MnZtm  (there was >1k BTC at this address!)

Code:
HASH160                                   BTC_IN
0000000000000000000000000000000000000000 00000000.07110007
0000000000000000000000000000000000000001 00000000.01000000
000001aa6aa32fb6138c08d5e91f9a502656abdb 00000000.00000001
0000094d87949ffa143d5f3c049a5f071a16a941 00000000.00000001
00000d645142c1b4c07e6a14a854acf4412d8713 00000000.00000001
00000f3b345053879dc45e2ffa23deb781af36e3 00000000.00000001
000013bd967f59213494a10a3fdf49e0b79371cd 00000000.00000001
000018fc5a9d6eae103f0e572ff02c6e8412d42c 00000000.00000001
00001a969f9529cedba0cb353553667874e5c263 00000000.00000001
000020b4868dbb9f9ea4ae2cb23a05b6c7a50737 00000000.00000001
00002ccc7e36c6e7077dc186d33e5f60c76edf58 00000000.00000001
00002e5019ebe4c717080cae027fdb7b1c5045c4 00000000.01000000
000032a07a118a18f4ca16ad4255fbf91a12f0a3 00000000.00000001
00003629f51465a2d757e25dcf189cc260fc392d 00000000.00000001
00003710b5473b680675ba9c0d52ef954103481c 00000000.00000001
00003ddb3d79d74da3ccd4593419f4f2a55a68f8 00000000.79000000
00004020b6275ee5743080928fefe7fe90ef838c 00000000.00000001
0000435e719970dc7aa64245dc7e984f191c1c56 00000000.02000000
000046035080a1bdce64d087aca6d9017a0557a4 00000000.04000000
000048f2b372c547a768bf61f436f2394cc21787 00000000.00000001
00004ed54c20dd73ccba1e102992084b39b556f8 00000000.00000001
000051da44a22641488b8718034be843b795aa82 00000000.00000001
00005831c8aba83829c9aea53b885e752aed62f0 00000000.00000001
00005859982da7cc90ffccb6a11138293d6a7ed7 00000000.00000001
00005af355dd005383792ab27b03b2cd3663a49d 00000000.00000001
00005e2615c19b97a819558e8e8380d5eea3e098 00000000.01000000
00005fea533cbb8cd290f43e0aeea80891837ba2 00000000.00000001
000060df7b6b95c47f0b311f581ad8a471c027b8 00000000.00000001
000062c4f36e984e1c38d64ed3e83fac0b8875d2 00000000.00000001
00006a5f1c919936181de6397671dfdee5eb3f8e 00000001.00000000
00006b7527baa323ae799ae76fbc7755f5c8cb68 00000000.00000001
0000782ec52331217996d5ed7e8fac6d3db7e2c7 00000005.68000000
00007eea3c271357c4254b2f6dd58d6184828f0f 00000000.00000001
0000830a9b1f296aa3f1c468f63be4933422f249 00000008.55000000
00009b759340b8d90771ebf2da76312900d9663d 00000000.00000001
0000a281962dc5123c9d83c977b6e4fbeb5effdb 00000000.00000001
0000a2948d8d534848124a606e43724e37f4b815 00000000.00000001
0000a635cad79b5825dab5176a0bdc59124068b7 00000000.00000001
0000aba36b6f4e822a12885a26d9392101070d4c 00000000.00000001
0000adbae47afaa49642252bb3ad5764aaa91f75 00000000.00000001
0000b7d68d18879c2a2c1e07001398cecb755180 00000000.00000001
0000c32bc79b9e8c8a2afb72462636be440dcc5d 00000000.00000001
0000cce1bcb7f8d8e34548e277cb43620ac50c6e 00000000.00000001
0000cd341be1f51cef57ac0207d098212a4b000a 00000000.00000001
0000cfcee541e4815bb92f4e6b8f5d6d210d2ace 00000000.00000001
0000d10e7744f0885a4fbd20c8ec1a0b82ece4a3 00000000.00000001
0000e30fb7a987abc3c28ca6398c18dc17edd608 00000100.29000000
0000ebb22c6afe1fd46bf1ca17cae2a9496df9ac 00001137.00000000
0000f02e3d9d88a95a015219a8b69a5b9d6cfbcb 00000078.21000000
000105c698a07fabe70f165eb6dae2ee681c03b3 00000517.88000000
000146b7dbf1ca1d1df70500d7c8ca13f19fa15f 00000000.05000000
00014bdcadd62ce646cdbbd68776102e802b1556 00000031.81000000
0001aaf0074a13876565da1abb94fb0ee1607467 00000000.05148120
0001c2d11f347e1d47d05fea3ad5d86efceda60a 00000009.49152769
...
ffff0c753b76620e152890565a7285171ad528ce 00000000.01000000
ffff235734d335de7da59b46d4e2229f03569dc9 00000041.26800000
ffff5ea334aadbe15678ef8ef9046296ee2ccdfa 00000004.80000000
ffff78aece539fb0dca39fbc2200bfb3583d477d 00000921.98226031
ffff97c97e1ccab5bc88350310e8ec76b30f7380 00000013.81000000
ffff9d832765e995c0e3a0e147934043f15add6b 00000003.80000000
ffffd66277094fb1186572d2c5a03056d1a7569f 00000000.50000000
fffff69ea5a3bdc76955591088ddfe5ec555d6cc 00001475.47000000
fffff9fabcf4e7a9bd5f9a44078fdba199c69b38 00000000.00000013
ffffffffffffffffffffffffffffffffffffffff 00000000.01000000
Small perl (64-bit) script to dump entire transaction database :
Code:
open F,';
while(/(.{8})\x19\x76\xA9\x14(.{20})\x88\xAC/sg){
  $c=unpack('Q',$1);
  $h=$2;
  $balance{$h}+=$c;
}
for(sort keys %balance){
  $c=$balance{$_};
  $s=sprintf('%016d',$c);
  substr($s,8,0)='.';
  print unpack('H*',$_)." $s\n";
}
1 million addresses soon!
(it counts only inputs, not generation or outputs)
legendary
Activity: 1974
Merit: 1029
Hmm, if I quote the regex in the shell, the generated address is shorter:

Code:
$ ./bitcoind getnewaddress '' '^11'

[...]

$ ./bitcoind getnewaddress '' ^11

In the shell, '^11' and ^11 are exactly the same thing, because the '^' character doesn't have any magical meaning here, so it doesn't need to be quoted.

Which is exactly the reason why generated addresses should be the same length.

...Or at least that's what I thought before I remembered (before reading your response) that addresses don't have a fixed length. The fact that giving a quoted parameter resulted in a shorter address must have been just a coincidence.

Thanks in any case Wink.
sr. member
Activity: 288
Merit: 263
Firstbits.com/1davux
Hmm, if I quote the regex in the shell, the generated address is shorter:

Code:
$ ./bitcoind getnewaddress '' '^11'

[...]

$ ./bitcoind getnewaddress '' ^11

In the shell, '^11' and ^11 are exactly the same thing, because the '^' character doesn't have any magical meaning here, so it doesn't need to be quoted.

Does that make sense? I understand addresses have a fixed length.

No, they don't.

There's no relation between the length of the addresses and the way you wrote the vanity regex.
legendary
Activity: 1974
Merit: 1029
I don't understand anything of what you just said. Anyway...

If you want a vanity address starting with any letter from "STUVWXYZabcdefghijkmnopqrstuvwxyz", you're going to have to spend a lot more cycles to find it.

That must be why "1ibm" was available Wink.
legendary
Activity: 1400
Merit: 1005
I have an observation to make about this.

The parts of the address after the leading "1" would appear to be computed from a pseudorandom integer ranging 0 .. (256^24)-1.

The largest possible value is 33 base-58 digits long, approximately:

23.33798 x 58^32

If the address value is chosen randomly between 0 and the value above, then:

95.715% will be equal or greater than 58^32, and that group will produce an address with 33 characters following the "1", where the first letter is in the set "23456789ABCDEFGHJKLMNPQR".

3.894% will be less than 58^32 and greater than or equal to 256^23.  These will produce an address with 32 characters following the "1", with any base-58 character except "1" as the first letter.

0.391% will be less than 256^23, i.e. the most significant byte is 0.  The base-58 encoder will prefix these with at least two 1s instead of one.

So, the easier vanity addresses start with "23456789ABCDEFGHJKLMNPQR".  If you want a vanity address starting with any letter from "STUVWXYZabcdefghijkmnopqrstuvwxyz", you're going to have to spend a lot more cycles to find it.
Interesting...  I have noticed a lot fewer lower case letters in addresses than upper case, and wondered why that was....
full member
Activity: 140
Merit: 430
Firstbits: 1samr7
I have an observation to make about this.

The parts of the address after the leading "1" would appear to be computed from a pseudorandom integer ranging 0 .. (256^24)-1.

The largest possible value is 33 base-58 digits long, approximately:

23.33798 x 58^32

If the address value is chosen randomly between 0 and the value above, then:

95.715% will be equal or greater than 58^32, and that group will produce an address with 33 characters following the "1", where the first letter is in the set "23456789ABCDEFGHJKLMNPQR".

3.894% will be less than 58^32 and greater than or equal to 256^23.  These will produce an address with 32 characters following the "1", with any base-58 character except "1" as the first letter.

0.391% will be less than 256^23, i.e. the most significant byte is 0.  The base-58 encoder will prefix these with at least two 1s instead of one.

So, the easier vanity addresses start with "23456789ABCDEFGHJKLMNPQR".  If you want a vanity address starting with any letter from "STUVWXYZabcdefghijkmnopqrstuvwxyz", you're going to have to spend a lot more cycles to find it.
legendary
Activity: 1974
Merit: 1029
Just curious - does the patch say how many addresses it generates and looks through per second?

Look in the debug.log for lines like "Vanity key tried 100000". Give it some minutes (20?) to appear though.

What I really miss in the debug log is a timestamp; shouldn't be hard to add even when not being able to say hello in C++ Smiley.
jr. member
Activity: 56
Merit: 1
It should dump a message in the log every 100K attempts though.
full member
Activity: 140
Merit: 100
BitVapes.com
Just curious - does the patch say how many addresses it generates and looks through per second?

not that I can tell, it just says "Searching..."
legendary
Activity: 1400
Merit: 1005
Anyway to generate a vanity address in windows with the current bitcoin client? My friend wants one.

someone posted a working patch for the latest bitcoin source, it compiled fine for me in linux.  I verified it worked by having it "search" for a 1-byte vanity address 'a' and it gave me one.

I let it run for a few minutes trying to find one with 'BitVapes' but I'm sure it would take over 9,000 years.   I did notice it only tied to one cpu core so I kicked off multiple instances to max out my cpus before shutting it down for fear of melting my box on this basically futile but fun effort.
Just curious - does the patch say how many addresses it generates and looks through per second?
full member
Activity: 140
Merit: 100
BitVapes.com
Anyway to generate a vanity address in windows with the current bitcoin client? My friend wants one.

someone posted a working patch for the latest bitcoin source, it compiled fine for me in linux.  I verified it worked by having it "search" for a 1-byte vanity address 'a' and it gave me one.

I let it run for a few minutes trying to find one with 'BitVapes' but I'm sure it would take over 9,000 years.   I did notice it only tied to one cpu core so I kicked off multiple instances to max out my cpus before shutting it down for fear of melting my box on this basically futile but fun effort.
Pages:
Jump to: