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

bitcoindevkit / bdk / 5834188079

pending completion
5834188079

Pull #1071

github

web-flow
Merge 68b42331c into 0ba6bbe11
Pull Request #1071: Update rust bitcoin (BDK 0.28)

563 of 563 new or added lines in 28 files covered. (100.0%)

14625 of 18342 relevant lines covered (79.74%)

9267.73 hits per line

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

3.45
/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)]
2✔
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
    /// The descriptor contains multipath keys
24
    MultiPath,
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::bip32::Error),
36
    /// Error during base58 decoding
37
    Base58(bitcoin::base58::Error),
38
    /// Key-related error
39
    Pk(bitcoin::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 std::fmt::Display for Error {
57
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::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::MultiPath => write!(
×
68
                f,
×
69
                "The descriptor contains multipath keys, which are not supported yet"
×
70
            ),
×
71
            Self::Key(err) => write!(f, "Key error: {}", err),
×
72
            Self::Policy(err) => write!(f, "Policy error: {}", err),
×
73
            Self::InvalidDescriptorCharacter(char) => {
×
74
                write!(f, "Invalid descriptor character: {}", char)
×
75
            }
76
            Self::Bip32(err) => write!(f, "BIP32 error: {}", err),
×
77
            Self::Base58(err) => write!(f, "Base58 error: {}", err),
×
78
            Self::Pk(err) => write!(f, "Key-related error: {}", err),
×
79
            Self::Miniscript(err) => write!(f, "Miniscript error: {}", err),
×
80
            Self::Hex(err) => write!(f, "Hex decoding error: {}", err),
×
81
        }
82
    }
×
83
}
84

85
impl std::error::Error for Error {}
86

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