|
| 1 | +use lwk_wollet::blocking::EsploraClient; |
| 2 | +use std::sync::{MutexGuard, PoisonError}; |
| 3 | +use lwk_wollet::elements::UnblindError; |
| 4 | +use thiserror::Error; |
| 5 | + |
| 6 | +#[derive(Debug, Error)] |
| 7 | +pub enum WalletAbiError { |
| 8 | + #[error("Schema parse failed: {0}")] |
| 9 | + SchemaParse(String), |
| 10 | + |
| 11 | + #[error("Schema compilation failed: {0}")] |
| 12 | + SchemaCompile(String), |
| 13 | + |
| 14 | + #[error("Schema validation failed: {0}")] |
| 15 | + SchemaValidation(String), |
| 16 | + |
| 17 | + #[error("Schema checksum mismatch: expected {expected}, actual {actual}")] |
| 18 | + SchemaChecksumMismatch { expected: String, actual: String }, |
| 19 | + |
| 20 | + #[error("Invalid request: {0}")] |
| 21 | + InvalidRequest(String), |
| 22 | + |
| 23 | + #[error("Invalid response: {0}")] |
| 24 | + InvalidResponse(String), |
| 25 | + |
| 26 | + #[error("Unsupported branch: {0}")] |
| 27 | + UnsupportedBranch(String), |
| 28 | + |
| 29 | + #[error("Invalid expression: {0}")] |
| 30 | + InvalidExpression(String), |
| 31 | + |
| 32 | + #[error("Missing expression reference: {0}")] |
| 33 | + MissingExpressionReference(String), |
| 34 | + |
| 35 | + #[error("Unsupported expression operation: {0}")] |
| 36 | + UnsupportedExpressionOperation(String), |
| 37 | + |
| 38 | + #[error("Invalid typed binding '{name}' with type '{ty}': {message}")] |
| 39 | + InvalidTypedBinding { |
| 40 | + name: String, |
| 41 | + ty: String, |
| 42 | + message: String, |
| 43 | + }, |
| 44 | + |
| 45 | + #[error("Blinding key is required for output '{0}' when explicit=false")] |
| 46 | + MissingBlindingKey(String), |
| 47 | + |
| 48 | + #[error("Confidential output '{0}' was not blinded")] |
| 49 | + ConfidentialOutputNotBlinded(String), |
| 50 | + |
| 51 | + #[error("Unknown finalization engine: {0}")] |
| 52 | + UnknownFinalizationEngine(String), |
| 53 | + |
| 54 | + #[error("Invalid finalization steps: {0}")] |
| 55 | + InvalidFinalizationSteps(String), |
| 56 | + |
| 57 | + #[error("Invalid signer configuration: {0}")] |
| 58 | + InvalidSignerConfig(String), |
| 59 | + |
| 60 | + #[error("Funding failed: {0}")] |
| 61 | + Funding(String), |
| 62 | + |
| 63 | + #[error("Invalid hex for field '{field}': {message}")] |
| 64 | + InvalidHex { field: String, message: String }, |
| 65 | + |
| 66 | + #[error("I/O error: {0}")] |
| 67 | + Io(#[from] std::io::Error), |
| 68 | + |
| 69 | + #[error("JSON error: {0}")] |
| 70 | + Serde(#[from] serde_json::Error), |
| 71 | + |
| 72 | + #[error("Hex decode error: {0}")] |
| 73 | + Hex(#[from] hex::FromHexError), |
| 74 | + |
| 75 | + #[error("PSET error: {0}")] |
| 76 | + Pset(#[from] simplicityhl::elements::pset::Error), |
| 77 | + |
| 78 | + #[error("PSET blinding error: {0}")] |
| 79 | + PsetBlind(#[from] simplicityhl::elements::pset::PsetBlindError), |
| 80 | + |
| 81 | + #[error("Transaction decode error: {0}")] |
| 82 | + TxDecode(#[from] simplicityhl::elements::encode::Error), |
| 83 | + |
| 84 | + #[error("Transaction amount proof verification failed: {0}")] |
| 85 | + AmountProofVerification(#[from] simplicityhl::elements::VerificationError), |
| 86 | + |
| 87 | + #[error("Program error: {0}")] |
| 88 | + Program(#[from] lwk_simplicity::error::ProgramError), |
| 89 | + |
| 90 | + #[error("esplora mutex poisoned: {0}")] |
| 91 | + EsploraPoisoned(String), |
| 92 | + |
| 93 | + #[error("LWK Signer error: {0}")] |
| 94 | + LWKSigner(#[from] lwk_signer::NewError), |
| 95 | + |
| 96 | + #[error("LWK sign error: {0}")] |
| 97 | + LWKSign(#[from] lwk_signer::SignError), |
| 98 | + |
| 99 | + #[error("LWK wollet error: {0}")] |
| 100 | + LWKWollet(#[from] lwk_wollet::Error), |
| 101 | + |
| 102 | + #[error("TXOut unblinding error: {0}")] |
| 103 | + Unblind(#[from] UnblindError) |
| 104 | +} |
| 105 | + |
| 106 | +/// Errors that occur during binary or hex encoding/decoding operations. |
| 107 | +#[derive(Debug, thiserror::Error)] |
| 108 | +pub enum EncodingError { |
| 109 | + #[error("Failed to encode to binary: {0}")] |
| 110 | + BinaryEncode(#[from] bincode::error::EncodeError), |
| 111 | + |
| 112 | + #[error("Failed to decode from binary: {0}")] |
| 113 | + BinaryDecode(#[from] bincode::error::DecodeError), |
| 114 | + |
| 115 | + #[error("Failed to decode hex string: {0}")] |
| 116 | + HexDecode(#[from] hex::FromHexError), |
| 117 | +} |
0 commit comments