use bip39::Mnemonic;
use clap::{Arg, Command};
use colored::*;
use prettytable::{row, Table};
use std::process;
use wallet_wizard::generate_ethereum_wallet;
fn main() {
let matches = Command::new("Wallet Wizard")
.arg(
Arg::new("mnemonic")
.short('m')
.long("mnemonic")
.value_name("MNEMONIC")
.help("Sets the BIP-39 mnemonic to use"),
)
.arg(
Arg::new("num_wallets")
.short('n')
.long("num-wallets")
.value_name("NUM_WALLETS")
.help("Sets the number of wallets to generate"),
)
.get_matches();
let num_wallets: u32 = matches
.get_one::<String>("num_wallets")
.unwrap_or(&"1".to_string())
.parse()
.expect("Invalid number of wallets");
let mnemonic = matches
.get_one::<String>("mnemonic")
.map(|s| s.to_string())
.unwrap_or_else(|| Mnemonic::generate(12).unwrap().to_string());
println!("Mnemonic is {}", mnemonic.green());
let mut table = Table::new();
table.add_row(row!["Ethereum Address".red(), "Private Key".red()]);
for i in 0..num_wallets {
match generate_ethereum_wallet(mnemonic.as_str(), i) {
Ok((address, private_key)) => {
table.add_row(row![address, private_key]);
}
Err(e) => {
eprintln!("Error generating Ethereum wallet: {}", e);
process::exit(1);
}
}
}
table.printstd();
}