1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("invalid mnemonic word count")]
6 InvalidMnemonicWordCount,
7 #[error("invalid mnemonic phrase")]
8 InvalidMnemonic,
9 #[error("invalid derivation path")]
10 InvalidDerivationPath,
11 #[error("invalid extended key")]
12 InvalidExtendedKey,
13 #[error("extended key network mismatch")]
14 ExtendedKeyNetworkMismatch,
15 #[error("cannot derive a hardened child from an extended public key")]
16 HardenedPublicDerivation,
17 #[error("invalid WIF")]
18 InvalidWif,
19 #[error("invalid address")]
20 InvalidAddress,
21 #[error("unsupported address type")]
22 UnsupportedAddressType,
23 #[error("invalid transaction hex")]
24 InvalidTransactionHex,
25 #[error("invalid script: {0}")]
26 InvalidScript(String),
27 #[error("invalid UTXO data: {0}")]
28 InvalidUtxo(String),
29 #[error("insufficient funds: input {input} sat, required {required} sat")]
30 InsufficientFunds { input: u64, required: u64 },
31 #[error("dust output: {0} sat")]
32 DustOutput(u64),
33 #[error("missing private key for input")]
34 MissingPrivateKey,
35 #[error("signature failure")]
36 SignatureFailure,
37 #[error("signed transaction fee did not converge")]
38 FeeDidNotConverge,
39 #[error("broadcast failure: {0}")]
40 BroadcastFailure(String),
41 #[error(
42 "TOKEN_INPUTS_INCOMPATIBLE: token balance is fragmented across input limits or lock-time domains"
43 )]
44 TokenInputsIncompatible,
45 #[error("index API HTTP {status}, code {code}: {message}")]
46 IndexApi {
47 code: String,
48 status: u16,
49 request_id: Option<String>,
50 message: String,
51 },
52 #[error("API error: {0}")]
53 Api(String),
54 #[error("hex error: {0}")]
55 Hex(#[from] hex::FromHexError),
56 #[error("secp256k1 error: {0}")]
57 Secp256k1(#[from] secp256k1::Error),
58 #[error("HTTP error: {0}")]
59 Http(#[from] reqwest::Error),
60 #[error("JSON error: {0}")]
61 Json(#[from] serde_json::Error),
62}