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