wallet-wizard 0.2.0

Embark on a cryptographic journey with wallet-wizard, a Rust library that opens portals to the blockchain realm. This mystical tool harnesses the ancient art of BIP-39 mnemonics to generate secure wallets. Whether you're a seasoned sorcerer of the blockchain world or a novice in the cryptographic universe, wallet-wizard offers a seamless and secure way to create wallets. Perfect for applications needing robust wallet functionality, it's your go-to spellbook for generating, managing, and utilizing wallets in your Rust applications.
Documentation
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();
}