rustywallet_multisig/
error.rs

1//! Error types for multisig operations.
2
3use thiserror::Error;
4
5/// Result type for multisig operations.
6pub type Result<T> = std::result::Result<T, MultisigError>;
7
8/// Errors that can occur during multisig operations.
9#[derive(Debug, Error)]
10pub enum MultisigError {
11    /// Invalid threshold (M must be >= 1 and <= N)
12    #[error("Invalid threshold: M={m} must be >= 1 and <= N={n}")]
13    InvalidThreshold { m: u8, n: u8 },
14
15    /// Too many keys (max 15 for standard multisig)
16    #[error("Too many keys: {count} (max 15)")]
17    TooManyKeys { count: usize },
18
19    /// Not enough keys
20    #[error("Not enough keys: need {need}, got {got}")]
21    NotEnoughKeys { need: usize, got: usize },
22
23    /// Duplicate public key
24    #[error("Duplicate public key at index {index}")]
25    DuplicateKey { index: usize },
26
27    /// Invalid public key
28    #[error("Invalid public key: {0}")]
29    InvalidPublicKey(String),
30
31    /// Invalid redeem script
32    #[error("Invalid redeem script: {0}")]
33    InvalidRedeemScript(String),
34
35    /// Not enough signatures
36    #[error("Not enough signatures: need {need}, got {got}")]
37    NotEnoughSignatures { need: usize, got: usize },
38
39    /// Invalid signature
40    #[error("Invalid signature at index {index}: {reason}")]
41    InvalidSignature { index: usize, reason: String },
42
43    /// Shamir share error
44    #[error("Shamir error: {0}")]
45    ShamirError(String),
46
47    /// Invalid share index
48    #[error("Invalid share index: {0} (must be 1-255)")]
49    InvalidShareIndex(u8),
50
51    /// Duplicate share index
52    #[error("Duplicate share index: {0}")]
53    DuplicateShareIndex(u8),
54
55    /// Signing failed
56    #[error("Signing failed: {0}")]
57    SigningFailed(String),
58
59    /// Address generation failed
60    #[error("Address generation failed: {0}")]
61    AddressFailed(String),
62}