This commit is contained in:
2020-04-20 00:19:05 +08:00
parent 4eea25af9d
commit dbb46bc18a

View File

@@ -1,15 +1,24 @@
use std::thread;
use std::{
thread,
sync::{ Arc, Mutex, },
};
use rand::rngs::OsRng;
use secp256k1::{Secp256k1, key::PublicKey, };
use secp256k1::{ Secp256k1, key::PublicKey, };
use sha2::Sha256;
use ripemd160::Ripemd160;
use digest::{ Input, FixedOutput, };
const PREFIX: &[&str] = &["1Hatter"];
fn main() {
println!("Prefix: {:?}", PREFIX);
let stop_flag = Arc::new(Mutex::new(false));
let mut handles = vec![];
for ind in 0..8 {
for ind in 0..4 {
let the_stop_flag = Arc::clone(&stop_flag);
let child = thread::spawn(move || {
run_one_task(ind);
run_one_task(ind, the_stop_flag);
});
handles.push(child);
}
@@ -19,21 +28,29 @@ fn main() {
println!("Finished!");
}
fn run_one_task(ind: usize) {
fn run_one_task(ind: usize, the_stop_flag: Arc<Mutex<bool>>) {
let secp = Secp256k1::new();
let mut rng = OsRng::new().expect("OsRng");
for i in 0..1_000_000 {
for i in 0..10_000_000 {
let (secret_key, public_key) = secp.generate_keypair(&mut rng);
let s = make_btc_address(&public_key);
if i > 0 && i % 10000 == 0 {
println!("> {} - {}", ind, i);
if i % 10_000 == 0 {
if *the_stop_flag.lock().unwrap() {
return;
}
if i > 0 && i % 100_000 == 0 {
println!("> {} - {}", ind, i);
}
}
if s.starts_with("1Hatt") {
if PREFIX.iter().any(|p| s.starts_with(p)) {
println!("{}", s);
println!("{}", secret_key);
*the_stop_flag.lock().unwrap() = true;
break;
}
}
}