Skip to main content

zinc_core/
error.rs

1//! Unified error types for Zinc wallet
2
3use thiserror::Error;
4
5/// All errors that can occur in Zinc wallet operations.
6#[derive(Error, Debug)]
7pub enum ZincError {
8    /// Unsupported BIP-39 word count was requested.
9    #[error("Invalid word count: {0}. Must be 12 or 24.")]
10    InvalidWordCount(u8),
11
12    /// Mnemonic parsing/validation failure.
13    #[error("Mnemonic error: {0}")]
14    MnemonicError(String),
15
16    /// HD key derivation failure.
17    #[error("Key derivation error: {0}")]
18    KeyDerivation(String),
19
20    /// Generic wallet operation failure.
21    #[error("Wallet error: {0}")]
22    WalletError(String),
23
24    /// Encryption operation failure.
25    #[error("Encryption error: {0}")]
26    EncryptionError(String),
27
28    /// Decryption failed due to invalid password or malformed payload.
29    #[error("Decryption failed: wrong password or corrupted data")]
30    DecryptionError,
31
32    /// JSON or binary serialization/deserialization failure.
33    #[error("Serialization error: {0}")]
34    SerializationError(String),
35
36    /// Invalid runtime configuration.
37    #[error("Configuration error: {0}")]
38    ConfigError(String),
39
40    /// Wrapped error from BDK primitives.
41    #[error("BDK error: {0}")]
42    BdkError(String),
43
44    /// Offer envelope creation/validation/signature failure.
45    #[error("Offer error: {0}")]
46    OfferError(String),
47}
48
49/// Convenience type alias for Results with `ZincError`.
50pub type ZincResult<T> = Result<T, ZincError>;