Skip to main content

silent_payments_descriptor/
error.rs

1//! Per-domain error enum for BIP 392 descriptor operations.
2
3use thiserror::Error;
4
5/// Errors from parsing or generating BIP 392 `sp()` descriptors.
6#[derive(Debug, Error)]
7pub enum DescriptorError {
8    /// The descriptor string is malformed (missing parens, missing hash, etc.).
9    #[error("invalid descriptor format: {reason}")]
10    InvalidFormat { reason: String },
11
12    /// A key in the descriptor is invalid (bad hex, wrong length, invalid EC point).
13    #[error("invalid key: {reason}")]
14    InvalidKey { reason: String },
15
16    /// An annotation value is invalid (non-numeric, unknown key).
17    #[error("invalid annotation: {reason}")]
18    InvalidAnnotation { reason: String },
19
20    /// The descriptor checksum does not match the computed value.
21    #[error("checksum mismatch: expected {expected}, got {actual}")]
22    ChecksumMismatch { expected: String, actual: String },
23
24    /// The descriptor uses an unknown expression (not `sp()`).
25    #[error("unknown expression: {expression}")]
26    UnknownExpression { expression: String },
27}