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