Skip to main content

smplx_sdk/signer/
error.rs

1use crate::program::ProgramError;
2use crate::provider::ProviderError;
3
4#[derive(Debug, thiserror::Error)]
5pub enum SignerError {
6    #[error(transparent)]
7    Program(#[from] ProgramError),
8
9    #[error(transparent)]
10    Provider(#[from] ProviderError),
11
12    #[error(transparent)]
13    WtnsInjectError(#[from] WtnsWrappingError),
14
15    #[error("Failed to parse a mnemonic: {0}")]
16    Mnemonic(String),
17
18    #[error("Failed to extract tx from pst: {0}")]
19    TxExtraction(#[from] simplicityhl::elements::pset::Error),
20
21    #[error("Failed to unblind txout: {0}")]
22    Unblind(#[from] simplicityhl::elements::UnblindError),
23
24    #[error("Failed to blind a PST: {0}")]
25    PsetBlind(#[from] simplicityhl::elements::pset::PsetBlindError),
26
27    #[error("Failed to construct a message for the input spending: {0}")]
28    SighashConstruction(#[from] elements_miniscript::psbt::SighashError),
29
30    #[error("Fee amount is too low: {0}")]
31    DustAmount(i64),
32
33    #[error("Not enough fee amount {0} to cover transaction costs: {1}")]
34    NotEnoughFeeAmount(i64, u64),
35
36    #[error("Not enough funds on account to cover transaction costs: {0}")]
37    NotEnoughFunds(u64),
38
39    #[error("Invalid secret key")]
40    InvalidSecretKey(#[from] simplicityhl::elements::secp256k1_zkp::UpstreamError),
41
42    #[error("Failed to derive a private key: {0}")]
43    PrivateKeyDerivation(#[from] elements_miniscript::bitcoin::bip32::Error),
44
45    #[error("Failed to construct a derivation path: {0}")]
46    DerivationPath(String),
47
48    #[error("Failed to construct a wpkh descriptor: {0}")]
49    WpkhDescriptor(String),
50
51    #[error("Failed to construct a slip77 descriptor: {0}")]
52    Slip77Descriptor(String),
53
54    #[error("Failed to convert a descriptor: {0}")]
55    DescriptorConversion(#[from] elements_miniscript::descriptor::ConversionError),
56
57    #[error("Failed to construct a wpkh address: {0}")]
58    WpkhAddressConstruction(#[from] elements_miniscript::Error),
59
60    #[error("Missing such witness field: {0}")]
61    WtnsFieldNotFound(String),
62}
63
64#[derive(Debug, thiserror::Error)]
65pub enum WtnsWrappingError {
66    #[error("Failed to parse path")]
67    ParsingError,
68
69    #[error("Unsupported path type: {0}")]
70    UnsupportedPathType(String),
71
72    #[error("Path index out of bounds: len is {0}, got {1}")]
73    IdxOutOfBounds(usize, usize),
74
75    #[error("Root type mismatch: expected {0}, got {1}")]
76    RootTypeMismatch(String, String),
77
78    #[error("Path reached undefined branch of Either")]
79    EitherBranchMismatch,
80}