use thiserror::Error;
pub type Result<T> = std::result::Result<T, MultisigError>;
#[derive(Debug, Error)]
pub enum MultisigError {
#[error("Invalid threshold: M={m} must be >= 1 and <= N={n}")]
InvalidThreshold { m: u8, n: u8 },
#[error("Too many keys: {count} (max 15)")]
TooManyKeys { count: usize },
#[error("Not enough keys: need {need}, got {got}")]
NotEnoughKeys { need: usize, got: usize },
#[error("Duplicate public key at index {index}")]
DuplicateKey { index: usize },
#[error("Invalid public key: {0}")]
InvalidPublicKey(String),
#[error("Invalid redeem script: {0}")]
InvalidRedeemScript(String),
#[error("Not enough signatures: need {need}, got {got}")]
NotEnoughSignatures { need: usize, got: usize },
#[error("Invalid signature at index {index}: {reason}")]
InvalidSignature { index: usize, reason: String },
#[error("Shamir error: {0}")]
ShamirError(String),
#[error("Invalid share index: {0} (must be 1-255)")]
InvalidShareIndex(u8),
#[error("Duplicate share index: {0}")]
DuplicateShareIndex(u8),
#[error("Signing failed: {0}")]
SigningFailed(String),
#[error("Address generation failed: {0}")]
AddressFailed(String),
}