Skip to main content

keep_bitcoin/
error.rs

1// SPDX-FileCopyrightText: © 2026 PrivKey LLC
2// SPDX-License-Identifier: MIT
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum BitcoinError {
7    #[error("Invalid secret key: {0}")]
8    InvalidSecretKey(String),
9
10    #[error("Invalid public key: {0}")]
11    InvalidPublicKey(String),
12
13    #[error("Invalid PSBT: {0}")]
14    InvalidPsbt(String),
15
16    #[error("Missing witness UTXO for input {0}")]
17    MissingWitnessUtxo(usize),
18
19    #[error("Sighash computation failed: {0}")]
20    Sighash(String),
21
22    #[error("Signing failed: {0}")]
23    Signing(String),
24
25    #[error("Derivation path error: {0}")]
26    DerivationPath(String),
27
28    #[error("Address generation failed: {0}")]
29    Address(String),
30
31    #[error("Policy denied: {0}")]
32    PolicyDenied(String),
33
34    #[error("Amount {amount} sats exceeds limit {limit} sats")]
35    AmountExceeded { amount: u64, limit: u64 },
36
37    #[error("Address {0} not in allowlist")]
38    AddressNotAllowed(String),
39
40    #[error("Descriptor error: {0}")]
41    Descriptor(String),
42
43    #[error("Recovery error: {0}")]
44    Recovery(String),
45}
46
47pub type Result<T> = std::result::Result<T, BitcoinError>;