1pub mod chain;
2pub mod chains;
3pub mod estimate;
4#[cfg(feature = "native")]
5pub mod grinder;
6pub mod pattern;
7#[cfg(feature = "native")]
8pub mod system;
9pub mod verify;
10
11pub use chain::{ChainGrinder, GrindAttempt, KeyExport, KeypairResult};
12pub use chains::{Chain, Create2Grinder, EvmGrinder, SolanaGrinder, MENU_CHAINS};
13pub use estimate::{
14 default_keys_per_sec, effective_pattern_chars, format_attempts, format_duration,
15 grind_estimate, GrindEstimate, PatternRisk,
16};
17#[cfg(feature = "native")]
18pub use grinder::{benchmark, grind, grind_n, grind_patterns, CancelToken, GrindResult};
19pub use pattern::{
20 expand_pattern_alternatives, expected_attempts_any, matches_full, Pattern, PatternAlternative,
21};
22#[cfg(feature = "native")]
23pub use system::{build_thread_pool, MemoryPressure, SystemProfile};
24pub use verify::verify_address;
25
26pub fn build_pattern_list(
28 chain: &impl ChainGrinder,
29 prefix: Option<&str>,
30 suffix: Option<&str>,
31 contains: Option<&str>,
32 exact: bool,
33) -> Result<Vec<Pattern>, String> {
34 let alts = expand_pattern_alternatives(prefix, suffix, contains)?;
35 let mut patterns = Vec::with_capacity(alts.len());
36 for (p, s, c) in &alts {
37 patterns.push(chain.build_pattern(p.as_deref(), s.as_deref(), c.as_deref(), exact)?);
38 }
39 if patterns.is_empty() {
40 return Err("Provide at least one of --prefix, --suffix, or --contains".into());
41 }
42 Ok(patterns)
43}
44
45pub fn patterns_description(patterns: &[Pattern]) -> String {
47 if patterns.is_empty() {
48 return String::new();
49 }
50 if patterns.len() == 1 {
51 return patterns[0].description();
52 }
53 patterns
54 .iter()
55 .map(|p| p.description())
56 .collect::<Vec<_>>()
57 .join(" OR ")
58}