/*** 生成地址
*@return
*/
public static Map<String, String>createAddress() {
KeyPair keyPair=KeyPair.generate();
String privateKey=keyPair.toPrivateKey();
String base58CheckAddress=keyPair.toBase58CheckAddress();
Map<String, String> stringMap = new HashMap<>();
stringMap.put("address", base58CheckAddress);
stringMap.put("privateKey", privateKey);returnstringMap;
启动看了下大概一秒能生成几百个,速度太慢,写多线程来增加速度。/*** 新建一个线程生成地址
*@paramminLength*/
public static void runGenerate(intminLength ) {new Thread(()->{while (true){
Map<String, String> address =createAddress();if ( isPrettyAddress(address.get("address"), minLength) ){
writeText(address.toString());
System.out.println("address = " +address);
}
}
}).start();
}/*** start
*@paramnum
*@paramminLength*/
public static void start(int num, intminLength) {for (int i = 1; i <= num; i++) {
System.out.println("启动第"+i+"个线程");
runGenerate(minLength);
}
}