1use thiserror::Error;
4
5#[derive(Error, Debug, Clone, PartialEq, Eq)]
7pub enum Error {
8 #[error("invalid key length: expected {expected}, got {actual}")]
13 InvalidKeyLength { expected: usize, actual: usize },
14
15 #[error("invalid data length: expected {expected}, got {actual}")]
17 InvalidDataLength { expected: usize, actual: usize },
18
19 #[error("invalid hex string: {0}")]
21 InvalidHex(String),
22
23 #[error("invalid base58 string: {0}")]
25 InvalidBase58(String),
26
27 #[error("invalid base64 string: {0}")]
29 InvalidBase64(String),
30
31 #[error("cryptographic operation failed: {0}")]
33 CryptoError(String),
34
35 #[error("invalid signature: {0}")]
37 InvalidSignature(String),
38
39 #[error("invalid public key: {0}")]
41 InvalidPublicKey(String),
42
43 #[error("invalid private key: {0}")]
45 InvalidPrivateKey(String),
46
47 #[error("point at infinity")]
49 PointAtInfinity,
50
51 #[error("decryption failed")]
53 DecryptionFailed,
54
55 #[error("invalid nonce: {0}")]
57 InvalidNonce(String),
58
59 #[error("invalid authentication tag")]
61 InvalidTag,
62
63 #[error("invalid UTF-8 sequence: {0}")]
65 InvalidUtf8(String),
66
67 #[error("reader underflow: need {needed} bytes, only {available} available")]
69 ReaderUnderflow { needed: usize, available: usize },
70
71 #[error("invalid checksum")]
73 InvalidChecksum,
74
75 #[cfg(feature = "script")]
80 #[error("script parse error: {0}")]
81 ScriptParseError(String),
82
83 #[cfg(feature = "script")]
85 #[error("script execution error: {0}")]
86 ScriptExecutionError(String),
87
88 #[cfg(feature = "script")]
90 #[error("invalid opcode: 0x{0:02x}")]
91 InvalidOpcode(u8),
92
93 #[cfg(feature = "script")]
95 #[error("disabled opcode: 0x{0:02x}")]
96 DisabledOpcode(u8),
97
98 #[cfg(feature = "script")]
100 #[error("stack underflow")]
101 StackUnderflow,
102
103 #[cfg(feature = "script")]
105 #[error("stack overflow")]
106 StackOverflow,
107
108 #[cfg(feature = "script")]
110 #[error("BIP-276 error: {0}")]
111 Bip276Error(String),
112
113 #[cfg(feature = "script")]
115 #[error("invalid address: {0}")]
116 InvalidAddress(String),
117
118 #[cfg(feature = "script")]
120 #[error("invalid address length for '{0}'")]
121 InvalidAddressLength(String),
122
123 #[cfg(feature = "script")]
125 #[error("address not supported {0}")]
126 UnsupportedAddress(String),
127
128 #[cfg(feature = "transaction")]
133 #[error("transaction error: {0}")]
134 TransactionError(String),
135
136 #[cfg(feature = "transaction")]
138 #[error("merkle path error: {0}")]
139 MerklePathError(String),
140
141 #[cfg(feature = "transaction")]
143 #[error("BEEF error: {0}")]
144 BeefError(String),
145
146 #[cfg(feature = "transaction")]
148 #[error("fee model error: {0}")]
149 FeeModelError(String),
150
151 #[cfg(feature = "wallet")]
156 #[error("wallet error: {0}")]
157 WalletError(String),
158
159 #[cfg(feature = "wallet")]
161 #[error("key derivation error: {0}")]
162 KeyDerivationError(String),
163
164 #[cfg(feature = "wallet")]
166 #[error("protocol validation error: {0}")]
167 ProtocolValidationError(String),
168
169 #[cfg(feature = "wallet")]
171 #[error("invalid counterparty: {0}")]
172 InvalidCounterparty(String),
173
174 #[cfg(feature = "messages")]
179 #[error("message version mismatch: expected {expected}, got {actual}")]
180 MessageVersionMismatch { expected: String, actual: String },
181
182 #[cfg(feature = "messages")]
184 #[error("message error: {0}")]
185 MessageError(String),
186
187 #[cfg(feature = "messages")]
189 #[error("message recipient mismatch: expected {expected}, got {actual}")]
190 MessageRecipientMismatch { expected: String, actual: String },
191
192 #[cfg(feature = "compat")]
197 #[error("invalid mnemonic: {0}")]
198 InvalidMnemonic(String),
199
200 #[cfg(feature = "compat")]
202 #[error("invalid entropy length: expected {expected}, got {actual}")]
203 InvalidEntropyLength { expected: String, actual: usize },
204
205 #[cfg(feature = "compat")]
207 #[error("invalid word in mnemonic: {0}")]
208 InvalidMnemonicWord(String),
209
210 #[cfg(feature = "compat")]
212 #[error("invalid extended key: {0}")]
213 InvalidExtendedKey(String),
214
215 #[cfg(feature = "compat")]
217 #[error("cannot derive hardened child from public key")]
218 HardenedFromPublic,
219
220 #[cfg(feature = "compat")]
222 #[error("invalid derivation path: {0}")]
223 InvalidDerivationPath(String),
224
225 #[cfg(feature = "compat")]
227 #[error("ECIES decryption failed: {0}")]
228 EciesDecryptionFailed(String),
229
230 #[cfg(feature = "compat")]
232 #[error("ECIES HMAC verification failed")]
233 EciesHmacMismatch,
234
235 #[cfg(feature = "auth")]
240 #[error("authentication error: {0}")]
241 AuthError(String),
242
243 #[cfg(feature = "auth")]
245 #[error("session not found: {0}")]
246 SessionNotFound(String),
247
248 #[cfg(feature = "auth")]
250 #[error("certificate validation failed: {0}")]
251 CertificateValidationError(String),
252
253 #[cfg(feature = "auth")]
255 #[error("transport error: {0}")]
256 TransportError(String),
257
258 #[cfg(feature = "overlay")]
263 #[error("overlay error: {0}")]
264 OverlayError(String),
265
266 #[cfg(feature = "overlay")]
268 #[error("no hosts found for service: {0}")]
269 NoHostsFound(String),
270
271 #[cfg(feature = "overlay")]
273 #[error("overlay broadcast failed: {0}")]
274 OverlayBroadcastFailed(String),
275
276 #[cfg(feature = "registry")]
281 #[error("registry error: {0}")]
282 RegistryError(String),
283
284 #[cfg(feature = "registry")]
286 #[error("definition not found: {0}")]
287 DefinitionNotFound(String),
288
289 #[cfg(feature = "registry")]
291 #[error("invalid definition data: {0}")]
292 InvalidDefinitionData(String),
293
294 #[cfg(feature = "kvstore")]
299 #[error("kvstore error: {0}")]
300 KvStoreError(String),
301
302 #[cfg(feature = "kvstore")]
304 #[error("kvstore key not found: {0}")]
305 KvStoreKeyNotFound(String),
306
307 #[cfg(feature = "kvstore")]
309 #[error("corrupted kvstore state: {0}")]
310 KvStoreCorruptedState(String),
311
312 #[cfg(feature = "kvstore")]
314 #[error("context cannot be empty")]
315 KvStoreEmptyContext,
316
317 #[cfg(feature = "kvstore")]
319 #[error("invalid key")]
320 KvStoreInvalidKey,
321
322 #[cfg(feature = "kvstore")]
324 #[error("invalid value")]
325 KvStoreInvalidValue,
326
327 #[cfg(feature = "identity")]
332 #[error("identity error: {0}")]
333 IdentityError(String),
334
335 #[cfg(feature = "identity")]
337 #[error("identity not found: {0}")]
338 IdentityNotFound(String),
339
340 #[cfg(feature = "identity")]
342 #[error("contact not found: {0}")]
343 ContactNotFound(String),
344}
345
346pub type Result<T> = std::result::Result<T, Error>;