• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bitcoindevkit / bdk / 5119600689

pending completion
5119600689

Pull #976

github

web-flow
Merge 250458ae0 into 9bc7fe855
Pull Request #976: Reimplement `Wallet`, `ElectrumExt` and `Esplora{Async}Ext` with redesigned structures.

909 of 909 new or added lines in 13 files covered. (100.0%)

7569 of 9556 relevant lines covered (79.21%)

5314.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.0
/crates/bdk/src/descriptor/error.rs
1
// Bitcoin Dev Kit
2
// Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
3
//
4
// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
5
//
6
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
7
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
9
// You may not use this file except in accordance with one or both of these
10
// licenses.
11

12
//! Descriptor errors
13

14
/// Errors related to the parsing and usage of descriptors
15
#[derive(Debug)]
1✔
16
pub enum Error {
17
    /// Invalid HD Key path, such as having a wildcard but a length != 1
18
    InvalidHdKeyPath,
19
    /// The provided descriptor doesn't match its checksum
20
    InvalidDescriptorChecksum,
21
    /// The descriptor contains hardened derivation steps on public extended keys
22
    HardenedDerivationXpub,
23

24
    /// Error thrown while working with [`keys`](crate::keys)
25
    Key(crate::keys::KeyError),
26
    /// Error while extracting and manipulating policies
27
    Policy(crate::descriptor::policy::PolicyError),
28

29
    /// Invalid byte found in the descriptor checksum
30
    InvalidDescriptorCharacter(u8),
31

32
    /// BIP32 error
33
    Bip32(bitcoin::util::bip32::Error),
34
    /// Error during base58 decoding
35
    Base58(bitcoin::util::base58::Error),
36
    /// Key-related error
37
    Pk(bitcoin::util::key::Error),
38
    /// Miniscript error
39
    Miniscript(miniscript::Error),
40
    /// Hex decoding error
41
    Hex(bitcoin::hashes::hex::Error),
42
}
43

44
impl From<crate::keys::KeyError> for Error {
45
    fn from(key_error: crate::keys::KeyError) -> Error {
×
46
        match key_error {
×
47
            crate::keys::KeyError::Miniscript(inner) => Error::Miniscript(inner),
×
48
            crate::keys::KeyError::Bip32(inner) => Error::Bip32(inner),
×
49
            e => Error::Key(e),
×
50
        }
51
    }
×
52
}
53

54
impl std::fmt::Display for Error {
55
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
×
56
        match self {
×
57
            Self::InvalidHdKeyPath => write!(f, "Invalid HD key path"),
×
58
            Self::InvalidDescriptorChecksum => {
59
                write!(f, "The provided descriptor doesn't match its checksum")
×
60
            }
61
            Self::HardenedDerivationXpub => write!(
×
62
                f,
×
63
                "The descriptor contains hardened derivation steps on public extended keys"
×
64
            ),
×
65
            Self::Key(err) => write!(f, "Key error: {}", err),
×
66
            Self::Policy(err) => write!(f, "Policy error: {}", err),
×
67
            Self::InvalidDescriptorCharacter(char) => {
×
68
                write!(f, "Invalid descriptor character: {}", char)
×
69
            }
70
            Self::Bip32(err) => write!(f, "BIP32 error: {}", err),
×
71
            Self::Base58(err) => write!(f, "Base58 error: {}", err),
×
72
            Self::Pk(err) => write!(f, "Key-related error: {}", err),
×
73
            Self::Miniscript(err) => write!(f, "Miniscript error: {}", err),
×
74
            Self::Hex(err) => write!(f, "Hex decoding error: {}", err),
×
75
        }
76
    }
×
77
}
78

79
#[cfg(feature = "std")]
80
impl std::error::Error for Error {}
81

82
impl_error!(bitcoin::util::bip32::Error, Bip32);
83
impl_error!(bitcoin::util::base58::Error, Base58);
84
impl_error!(bitcoin::util::key::Error, Pk);
85
impl_error!(miniscript::Error, Miniscript);
86
impl_error!(bitcoin::hashes::hex::Error, Hex);
87
impl_error!(crate::descriptor::policy::PolicyError, Policy);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc