btc_vanity/lib.rs
1#![allow(rustdoc::invalid_html_tags)]
2//! # btc-vanity
3//!
4//! `btc-vanity` is a blazingly fast Rust library and CLI tool designed for generating **vanity cryptocurrency addresses**.
5//! Whether you are looking to create Bitcoin, Ethereum, or Solana addresses with specific patterns or substrings,
6//! `btc-vanity` offers a customizable and highly performant solution to achieve your goals.
7//!
8//! With support for **prefix**, **suffix**, **substring**, or even **regex-based patterns**, this library
9//! ensures you can generate your desired address with ease. Built with multithreaded support, it maximizes
10//! performance to quickly find vanity addresses for various blockchains.
11//!
12//! ### Example Usages
13//!
14//! You can easily generate a random Bitcoin keypair and print the private and public keys along with the address:
15//!
16//! ```rust
17//! use btc_vanity::{BitcoinKeyPair, KeyPairGenerator};
18//!
19//! let random_address = BitcoinKeyPair::generate_random();
20//!
21//! println!("Randomly generated Bitcoin key pair:\n\
22//! private_key (WIF): {}\n\
23//! public_key (compressed): {}\n\
24//! address (compressed): {}\n",
25//! random_address.get_wif_private_key(),
26//! random_address.get_comp_public_key(),
27//! random_address.get_comp_address());
28//! ```
29//!
30//! Find a Bitcoin address that contains the substring `emiv` (case-insensitive) using 16 threads:
31//!
32//! ```rust
33//! use btc_vanity::{BitcoinKeyPair, VanityAddr, VanityMode};
34//!
35//! let vanity_address: BitcoinKeyPair = VanityAddr::generate(
36//! "emiv", // Desired substring
37//! 16, // Number of threads
38//! false, // Case-insensitive
39//! true, // Enable fast mode
40//! VanityMode::Anywhere // Match substring anywhere in the address
41//! ).unwrap();
42//!
43//! println!("Vanity address:\n\
44//! private_key (WIF): {}\n\
45//! public_key (compressed): {}\n\
46//! address (compressed): {}\n",
47//! vanity_address.get_wif_private_key(),
48//! vanity_address.get_comp_public_key(),
49//! vanity_address.get_comp_address());
50//! ```
51//!
52//! Create a Bitcoin address with `meow` anywhere in the address (case-sensitive) using 4 threads:
53//!
54//! ```rust
55//! use btc_vanity::{BitcoinKeyPair, VanityAddr, VanityMode};
56//!
57//! let vanity_address: BitcoinKeyPair = VanityAddr::generate(
58//! "meow", // Desired substring
59//! 4, // Number of threads
60//! true, // Case-sensitive
61//! true, // Enable fast mode
62//! VanityMode::Anywhere // Match substring anywhere in the address
63//! ).unwrap();
64//!
65//! println!("Vanity address:\n\
66//! private_key (WIF): {}\n\
67//! public_key (compressed): {}\n\
68//! address (compressed): {}\n",
69//! vanity_address.get_wif_private_key(),
70//! vanity_address.get_comp_public_key(),
71//! vanity_address.get_comp_address());
72//! ```
73//!
74//! Find a Bitcoin address that matches a regex pattern `^1E.ET.*T$` with using 12 threads:
75//!
76//! ```rust
77//! use btc_vanity::{BitcoinKeyPair, VanityAddr};
78//!
79//! let vanity_address = VanityAddr::generate_regex::<BitcoinKeyPair>(
80//! "^1E.*ET.*T$", // The regex pattern
81//! 12 // Number of threads
82//! ).unwrap();
83//!
84//! println!("Bitcoin regex-matched vanity address:\n\
85//! private_key (WIF): {}\n\
86//! public_key (compressed): {}\n\
87//! address (compressed): {}\n",
88//! vanity_address.get_wif_private_key(),
89//! vanity_address.get_comp_public_key(),
90//! vanity_address.get_comp_address());
91//! ```
92
93pub const BATCH_SIZE: usize = 256;
94
95pub mod cli;
96pub mod error;
97pub mod file;
98pub mod flags;
99pub mod keys_and_address;
100pub mod vanity_addr_generator;
101
102#[cfg(feature = "ethereum")]
103pub use crate::keys_and_address::EthereumKeyPair;
104#[cfg(feature = "solana")]
105pub use crate::keys_and_address::SolanaKeyPair;
106pub use crate::keys_and_address::{BitcoinKeyPair, KeyPairGenerator};
107pub use vanity_addr_generator::vanity_addr::{VanityAddr, VanityMode};