rustywallet_psbt/
error.rs

1//! PSBT error types
2
3use thiserror::Error;
4
5/// Errors that can occur when working with PSBTs
6#[derive(Debug, Error, Clone, PartialEq, Eq)]
7pub enum PsbtError {
8    /// Invalid magic bytes (expected 0x70736274ff)
9    #[error("invalid PSBT magic bytes")]
10    InvalidMagic,
11
12    /// Invalid PSBT format
13    #[error("invalid PSBT format: {0}")]
14    InvalidFormat(String),
15
16    /// Missing required field
17    #[error("missing required field: {0}")]
18    MissingField(String),
19
20    /// Duplicate key in map
21    #[error("duplicate key in PSBT map")]
22    DuplicateKey,
23
24    /// Invalid key type
25    #[error("invalid key type: 0x{0:02x}")]
26    InvalidKeyType(u8),
27
28    /// Input index out of bounds
29    #[error("input index {0} out of bounds")]
30    InputIndexOutOfBounds(usize),
31
32    /// Output index out of bounds
33    #[error("output index {0} out of bounds")]
34    OutputIndexOutOfBounds(usize),
35
36    /// Cannot sign input
37    #[error("cannot sign input: {0}")]
38    CannotSign(String),
39
40    /// Incompatible PSBTs for combination
41    #[error("incompatible PSBTs for combination")]
42    IncompatiblePsbts,
43
44    /// PSBT not finalized
45    #[error("PSBT is not finalized")]
46    NotFinalized,
47
48    /// Already finalized
49    #[error("input is already finalized")]
50    AlreadyFinalized,
51
52    /// Invalid signature
53    #[error("invalid signature")]
54    InvalidSignature,
55
56    /// Unsupported PSBT version
57    #[error("unsupported PSBT version: {0}")]
58    UnsupportedVersion(u32),
59
60    /// Serialization error
61    #[error("serialization error: {0}")]
62    SerializationError(String),
63
64    /// Base64 decode error
65    #[error("base64 decode error: {0}")]
66    Base64Error(String),
67
68    /// Invalid public key
69    #[error("invalid public key: {0}")]
70    InvalidPublicKey(String),
71
72    /// Invalid script
73    #[error("invalid script: {0}")]
74    InvalidScript(String),
75
76    /// Missing UTXO information
77    #[error("missing UTXO information for input {0}")]
78    MissingUtxo(usize),
79
80    /// Sighash mismatch
81    #[error("sighash type mismatch")]
82    SighashMismatch,
83
84    /// Transaction mismatch
85    #[error("transaction mismatch between PSBTs")]
86    TransactionMismatch,
87
88    /// No unsigned transaction
89    #[error("PSBT has no unsigned transaction")]
90    NoUnsignedTx,
91}