use thiserror::Error;
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
#[error("invalid key length: expected {expected}, got {actual}")]
InvalidKeyLength { expected: usize, actual: usize },
#[error("invalid data length: expected {expected}, got {actual}")]
InvalidDataLength { expected: usize, actual: usize },
#[error("invalid hex string: {0}")]
InvalidHex(String),
#[error("invalid base58 string: {0}")]
InvalidBase58(String),
#[error("invalid base64 string: {0}")]
InvalidBase64(String),
#[error("cryptographic operation failed: {0}")]
CryptoError(String),
#[error("invalid signature: {0}")]
InvalidSignature(String),
#[error("invalid public key: {0}")]
InvalidPublicKey(String),
#[error("invalid private key: {0}")]
InvalidPrivateKey(String),
#[error("point at infinity")]
PointAtInfinity,
#[error("decryption failed")]
DecryptionFailed,
#[error("invalid nonce: {0}")]
InvalidNonce(String),
#[error("invalid authentication tag")]
InvalidTag,
#[error("invalid UTF-8 sequence: {0}")]
InvalidUtf8(String),
#[error("reader underflow: need {needed} bytes, only {available} available")]
ReaderUnderflow { needed: usize, available: usize },
#[error("invalid checksum")]
InvalidChecksum,
#[cfg(feature = "script")]
#[error("script parse error: {0}")]
ScriptParseError(String),
#[cfg(feature = "script")]
#[error("script execution error: {0}")]
ScriptExecutionError(String),
#[cfg(feature = "script")]
#[error("invalid opcode: 0x{0:02x}")]
InvalidOpcode(u8),
#[cfg(feature = "script")]
#[error("disabled opcode: 0x{0:02x}")]
DisabledOpcode(u8),
#[cfg(feature = "script")]
#[error("stack underflow")]
StackUnderflow,
#[cfg(feature = "script")]
#[error("stack overflow")]
StackOverflow,
#[cfg(feature = "script")]
#[error("BIP-276 error: {0}")]
Bip276Error(String),
#[cfg(feature = "script")]
#[error("invalid address: {0}")]
InvalidAddress(String),
#[cfg(feature = "script")]
#[error("invalid address length for '{0}'")]
InvalidAddressLength(String),
#[cfg(feature = "script")]
#[error("address not supported {0}")]
UnsupportedAddress(String),
#[cfg(feature = "transaction")]
#[error("transaction error: {0}")]
TransactionError(String),
#[cfg(feature = "transaction")]
#[error("merkle path error: {0}")]
MerklePathError(String),
#[cfg(feature = "transaction")]
#[error("BEEF error: {0}")]
BeefError(String),
#[cfg(feature = "transaction")]
#[error("fee model error: {0}")]
FeeModelError(String),
#[cfg(feature = "wallet")]
#[error("wallet error: {0}")]
WalletError(String),
#[cfg(feature = "wallet")]
#[error("key derivation error: {0}")]
KeyDerivationError(String),
#[cfg(feature = "wallet")]
#[error("protocol validation error: {0}")]
ProtocolValidationError(String),
#[cfg(feature = "wallet")]
#[error("invalid counterparty: {0}")]
InvalidCounterparty(String),
#[cfg(feature = "messages")]
#[error("message version mismatch: expected {expected}, got {actual}")]
MessageVersionMismatch { expected: String, actual: String },
#[cfg(feature = "messages")]
#[error("message error: {0}")]
MessageError(String),
#[cfg(feature = "messages")]
#[error("message recipient mismatch: expected {expected}, got {actual}")]
MessageRecipientMismatch { expected: String, actual: String },
#[cfg(feature = "compat")]
#[error("invalid mnemonic: {0}")]
InvalidMnemonic(String),
#[cfg(feature = "compat")]
#[error("invalid entropy length: expected {expected}, got {actual}")]
InvalidEntropyLength { expected: String, actual: usize },
#[cfg(feature = "compat")]
#[error("invalid word in mnemonic: {0}")]
InvalidMnemonicWord(String),
#[cfg(feature = "compat")]
#[error("invalid extended key: {0}")]
InvalidExtendedKey(String),
#[cfg(feature = "compat")]
#[error("cannot derive hardened child from public key")]
HardenedFromPublic,
#[cfg(feature = "compat")]
#[error("invalid derivation path: {0}")]
InvalidDerivationPath(String),
#[cfg(feature = "compat")]
#[error("ECIES decryption failed: {0}")]
EciesDecryptionFailed(String),
#[cfg(feature = "compat")]
#[error("ECIES HMAC verification failed")]
EciesHmacMismatch,
#[cfg(feature = "auth")]
#[error("authentication error: {0}")]
AuthError(String),
#[cfg(feature = "auth")]
#[error("session not found: {0}")]
SessionNotFound(String),
#[cfg(feature = "auth")]
#[error("certificate validation failed: {0}")]
CertificateValidationError(String),
#[cfg(feature = "auth")]
#[error("transport error: {0}")]
TransportError(String),
#[cfg(feature = "overlay")]
#[error("overlay error: {0}")]
OverlayError(String),
#[cfg(feature = "overlay")]
#[error("no hosts found for service: {0}")]
NoHostsFound(String),
#[cfg(feature = "overlay")]
#[error("overlay broadcast failed: {0}")]
OverlayBroadcastFailed(String),
#[cfg(feature = "registry")]
#[error("registry error: {0}")]
RegistryError(String),
#[cfg(feature = "registry")]
#[error("definition not found: {0}")]
DefinitionNotFound(String),
#[cfg(feature = "registry")]
#[error("invalid definition data: {0}")]
InvalidDefinitionData(String),
#[cfg(feature = "kvstore")]
#[error("kvstore error: {0}")]
KvStoreError(String),
#[cfg(feature = "kvstore")]
#[error("kvstore key not found: {0}")]
KvStoreKeyNotFound(String),
#[cfg(feature = "kvstore")]
#[error("corrupted kvstore state: {0}")]
KvStoreCorruptedState(String),
#[cfg(feature = "kvstore")]
#[error("context cannot be empty")]
KvStoreEmptyContext,
#[cfg(feature = "kvstore")]
#[error("invalid key")]
KvStoreInvalidKey,
#[cfg(feature = "kvstore")]
#[error("invalid value")]
KvStoreInvalidValue,
#[cfg(feature = "identity")]
#[error("identity error: {0}")]
IdentityError(String),
#[cfg(feature = "identity")]
#[error("identity not found: {0}")]
IdentityNotFound(String),
#[cfg(feature = "identity")]
#[error("contact not found: {0}")]
ContactNotFound(String),
}
pub type Result<T> = std::result::Result<T, Error>;