package com.itranswarp.bitcoin.keypair;

import java.util.Scanner;

public class PrettyAddressGenerator {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.print("Enter the prefix (e.g. Bob): ");
			String prefix = "1" + scanner.nextLine();
			System.out.println("Find address starts with prefix: " + prefix);
			long n = 0;
			long found = 0;
			for (;;) {
				if (n % 10000 == 0) {
					System.out.print('.');
				}
				n++;
				ECDSAKeyPair keyPair = ECDSAKeyPair.createNewKeyPair();
				String cwif = keyPair.toCompressedWIF();
				String caddr = keyPair.toEncodedCompressedPublicKey();
				if (caddr.startsWith(prefix)) {
					found++;
					n = 0;
					System.out.println("\n" + caddr + " " + cwif);
					if (found == 10) {
						break;
					}
				}
			}
			System.out.println("Found " + found + " addresses.");
		}
	}
}

@@ -61,16 +61,261 @@
 anner;%0A%0A
+/**%0A * Generate pretty address starts with specific word. e.g. %22BTC%22.%0A * %0A * For example:%0A * %0A * public key: 1BTC48PCwMQMhKr79xgjwdFJFe84iBTrdF private key:%0A * Kzgnp4nUukjYuDuJBp9h1hSW4JVigyCAzUXVNvbx2MsLAWUwug5n%0A * %0A * @author Michael Liao%0A */%0A
 public c
@@ -345,16 +345,54 @@
 ator %7B%0A%0A
+%09static final long NUM_OF_ADDR = 10;%0A%0A
 %09public 
@@ -525,10 +525,10 @@
 g. B
-ob
+TC
 ): %22
@@ -644,16 +644,78 @@
 refix);%0A
+%09%09%09final long step = 1 %3C%3C Math.min(60, prefix.length() * 11);%0A
 %09%09%09long 
@@ -770,13 +770,12 @@
 n %25 
-10000
+step
  == 
@@ -1118,18 +1118,27 @@
 ound == 
-10
+NUM_OF_ADDR
 ) %7B%0A%09%09%09%09
@@ -1159,16 +1159,117 @@
 %7D%0A%09%09%09%09%7D%0A
+%09%09%09%09if (n == Long.MAX_VALUE) %7B%0A%09%09%09%09%09System.out.println(%22Ooops NO ADDRESS FOUND!%22);%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A
 %09%09%09%7D%0A%09%09%09

add comment