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

bitcoindevkit / bdk / 5398026791

pending completion
5398026791

Pull #1002

github

web-flow
Merge 8272aa35d into 26ade1172
Pull Request #1002: Implement linked-list `LocalChain` and add rpc-chain module/example

681 of 681 new or added lines in 9 files covered. (100.0%)

7903 of 10220 relevant lines covered (77.33%)

5078.37 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
use core::fmt;
15

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

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

31
    /// Invalid byte found in the descriptor checksum
32
    InvalidDescriptorCharacter(u8),
33

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

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

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

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

84
impl_error!(bitcoin::util::bip32::Error, Bip32);
85
impl_error!(bitcoin::util::base58::Error, Base58);
86
impl_error!(bitcoin::util::key::Error, Pk);
87
impl_error!(miniscript::Error, Miniscript);
88
impl_error!(bitcoin::hashes::hex::Error, Hex);
89
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