1use thiserror::Error;
4
5#[derive(Error, Debug, Clone, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum Error {
9 #[error("invalid key length: expected {expected}, got {actual}")]
14 InvalidKeyLength {
15 expected: usize,
17 actual: usize,
19 },
20
21 #[error("invalid data length: expected {expected}, got {actual}")]
23 InvalidDataLength {
24 expected: usize,
26 actual: usize,
28 },
29
30 #[error("invalid hex string: {0}")]
32 InvalidHex(String),
33
34 #[error("invalid base58 string: {0}")]
36 InvalidBase58(String),
37
38 #[error("invalid base64 string: {0}")]
40 InvalidBase64(String),
41
42 #[error("cryptographic operation failed: {0}")]
44 CryptoError(String),
45
46 #[error("invalid signature: {0}")]
48 InvalidSignature(String),
49
50 #[error("invalid public key: {0}")]
52 InvalidPublicKey(String),
53
54 #[error("invalid private key: {0}")]
56 InvalidPrivateKey(String),
57
58 #[error("point at infinity")]
60 PointAtInfinity,
61
62 #[error("decryption failed")]
64 DecryptionFailed,
65
66 #[error("invalid nonce: {0}")]
68 InvalidNonce(String),
69
70 #[error("invalid authentication tag")]
72 InvalidTag,
73
74 #[error("invalid UTF-8 sequence: {0}")]
76 InvalidUtf8(String),
77
78 #[error("reader underflow: need {needed} bytes, only {available} available")]
80 ReaderUnderflow {
81 needed: usize,
83 available: usize,
85 },
86
87 #[error("non-canonical varint: {value} encoded in {width} bytes")]
89 NonCanonicalVarInt {
90 width: u8,
92 value: u64,
94 },
95
96 #[error("compact size too large: {0}")]
98 CompactSizeTooLarge(u64),
99
100 #[error("invalid checksum")]
102 InvalidChecksum,
103
104 #[cfg(feature = "script")]
109 #[error("script parse error: {0}")]
110 ScriptParseError(String),
111
112 #[cfg(feature = "script")]
114 #[error("script execution error: {0}")]
115 ScriptExecutionError(String),
116
117 #[cfg(feature = "script")]
119 #[error("invalid opcode: 0x{0:02x}")]
120 InvalidOpcode(u8),
121
122 #[cfg(feature = "script")]
124 #[error("disabled opcode: 0x{0:02x}")]
125 DisabledOpcode(u8),
126
127 #[cfg(feature = "script")]
129 #[error("stack underflow")]
130 StackUnderflow,
131
132 #[cfg(feature = "script")]
134 #[error("stack overflow")]
135 StackOverflow,
136
137 #[cfg(feature = "script")]
139 #[error("BIP-276 error: {0}")]
140 Bip276Error(String),
141
142 #[cfg(feature = "script")]
144 #[error("invalid address: {0}")]
145 InvalidAddress(String),
146
147 #[cfg(feature = "script")]
149 #[error("invalid address length for '{0}'")]
150 InvalidAddressLength(String),
151
152 #[cfg(feature = "script")]
154 #[error("address not supported {0}")]
155 UnsupportedAddress(String),
156
157 #[cfg(feature = "transaction")]
162 #[error("transaction error: {0}")]
163 TransactionError(String),
164
165 #[cfg(feature = "transaction")]
167 #[error("merkle path error: {0}")]
168 MerklePathError(String),
169
170 #[cfg(feature = "transaction")]
172 #[error("BEEF error: {0}")]
173 BeefError(String),
174
175 #[cfg(feature = "transaction")]
177 #[error("fee model error: {0}")]
178 FeeModelError(String),
179
180 #[cfg(feature = "wallet")]
185 #[error("wallet error: {0}")]
186 WalletError(String),
187
188 #[cfg(feature = "wallet")]
199 #[error("wallet busy: {detail}")]
200 WalletBusy {
201 detail: String,
203 retry_after_ms: Option<u64>,
208 },
209
210 #[cfg(feature = "wallet")]
220 #[error("wallet transport fault: {detail}")]
221 WalletTransport {
222 status: Option<u16>,
226 detail: String,
228 },
229
230 #[cfg(feature = "wallet")]
232 #[error("key derivation error: {0}")]
233 KeyDerivationError(String),
234
235 #[cfg(feature = "wallet")]
237 #[error("protocol validation error: {0}")]
238 ProtocolValidationError(String),
239
240 #[cfg(feature = "wallet")]
242 #[error("invalid counterparty: {0}")]
243 InvalidCounterparty(String),
244
245 #[cfg(feature = "messages")]
250 #[error("message version mismatch: expected {expected}, got {actual}")]
251 MessageVersionMismatch {
252 expected: String,
254 actual: String,
256 },
257
258 #[cfg(feature = "messages")]
260 #[error("message error: {0}")]
261 MessageError(String),
262
263 #[cfg(feature = "messages")]
265 #[error("message recipient mismatch: expected {expected}, got {actual}")]
266 MessageRecipientMismatch {
267 expected: String,
269 actual: String,
271 },
272
273 #[cfg(feature = "compat")]
278 #[error("invalid mnemonic: {0}")]
279 InvalidMnemonic(String),
280
281 #[cfg(feature = "compat")]
283 #[error("invalid entropy length: expected {expected}, got {actual}")]
284 InvalidEntropyLength {
285 expected: String,
287 actual: usize,
289 },
290
291 #[cfg(feature = "compat")]
293 #[error("invalid word in mnemonic: {0}")]
294 InvalidMnemonicWord(String),
295
296 #[cfg(feature = "compat")]
298 #[error("invalid extended key: {0}")]
299 InvalidExtendedKey(String),
300
301 #[cfg(feature = "compat")]
303 #[error("cannot derive hardened child from public key")]
304 HardenedFromPublic,
305
306 #[cfg(feature = "compat")]
308 #[error("invalid derivation path: {0}")]
309 InvalidDerivationPath(String),
310
311 #[cfg(feature = "compat")]
313 #[error("ECIES decryption failed: {0}")]
314 EciesDecryptionFailed(String),
315
316 #[cfg(feature = "compat")]
318 #[error("ECIES HMAC verification failed")]
319 EciesHmacMismatch,
320
321 #[cfg(feature = "auth")]
326 #[error("authentication error: {0}")]
327 AuthError(String),
328
329 #[cfg(feature = "auth")]
331 #[error("session not found: {0}")]
332 SessionNotFound(String),
333
334 #[cfg(feature = "auth")]
336 #[error("certificate validation failed: {0}")]
337 CertificateValidationError(String),
338
339 #[cfg(feature = "auth")]
341 #[error("transport error: {0}")]
342 TransportError(String),
343
344 #[cfg(feature = "overlay")]
349 #[error("overlay error: {0}")]
350 OverlayError(String),
351
352 #[cfg(feature = "overlay")]
354 #[error("no hosts found for service: {0}")]
355 NoHostsFound(String),
356
357 #[cfg(feature = "overlay")]
359 #[error("overlay broadcast failed: {0}")]
360 OverlayBroadcastFailed(String),
361
362 #[cfg(feature = "registry")]
367 #[error("registry error: {0}")]
368 RegistryError(String),
369
370 #[cfg(feature = "registry")]
372 #[error("definition not found: {0}")]
373 DefinitionNotFound(String),
374
375 #[cfg(feature = "registry")]
377 #[error("invalid definition data: {0}")]
378 InvalidDefinitionData(String),
379
380 #[cfg(feature = "kvstore")]
385 #[error("kvstore error: {0}")]
386 KvStoreError(String),
387
388 #[cfg(feature = "kvstore")]
390 #[error("kvstore key not found: {0}")]
391 KvStoreKeyNotFound(String),
392
393 #[cfg(feature = "kvstore")]
395 #[error("corrupted kvstore state: {0}")]
396 KvStoreCorruptedState(String),
397
398 #[cfg(feature = "kvstore")]
400 #[error("context cannot be empty")]
401 KvStoreEmptyContext,
402
403 #[cfg(feature = "kvstore")]
405 #[error("invalid key")]
406 KvStoreInvalidKey,
407
408 #[cfg(feature = "kvstore")]
410 #[error("invalid value")]
411 KvStoreInvalidValue,
412
413 #[cfg(feature = "identity")]
418 #[error("identity error: {0}")]
419 IdentityError(String),
420
421 #[cfg(feature = "identity")]
423 #[error("identity not found: {0}")]
424 IdentityNotFound(String),
425
426 #[cfg(feature = "identity")]
428 #[error("contact not found: {0}")]
429 ContactNotFound(String),
430}
431
432pub type Result<T> = std::result::Result<T, Error>;