1#[cfg(feature = "alloc")]
4use alloc::{string::String, vec::Vec};
5
6#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10 #[error("invalid mnemonic: {0}")]
12 Mnemonic(#[from] bip39::Error),
13
14 #[error("invalid word count {0}, must be 12, 15, 18, 21, or 24")]
16 InvalidWordCount(usize),
17
18 #[cfg(feature = "camouflage")]
20 #[error("password must not be empty")]
21 EmptyPassword,
22
23 #[cfg(feature = "camouflage")]
25 #[error("PBKDF2 key derivation failed")]
26 KeyDerivation,
27
28 #[cfg(feature = "alloc")]
30 #[error("prefix \"{prefix}\" is too short (minimum {min_len} characters)")]
31 PrefixTooShort {
32 prefix: String,
34 min_len: usize,
36 },
37
38 #[cfg(feature = "alloc")]
40 #[error("prefix \"{0}\" does not match any BIP-39 word")]
41 UnknownPrefix(String),
42
43 #[cfg(feature = "alloc")]
45 #[error("prefix \"{prefix}\" is ambiguous, matches: {}", candidates.join(", "))]
46 AmbiguousPrefix {
47 prefix: String,
49 candidates: Vec<String>,
51 },
52
53 #[error("index overflow")]
55 IndexOverflow,
56
57 #[cfg(feature = "slip10")]
59 #[error("SLIP-10: invalid seed length")]
60 Slip10InvalidSeed,
61
62 #[cfg(feature = "slip10")]
64 #[error("SLIP-10: {0}")]
65 Slip10InvalidPath(String),
66
67 #[cfg(feature = "bip32")]
69 #[error("BIP-32: {0}")]
70 Bip32Derivation(String),
71}