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

bitcoindevkit / bdk / 10348217438

12 Aug 2024 08:10AM UTC coverage: 81.794% (-0.02%) from 81.813%
10348217438

Pull #1535

github

web-flow
Merge 2c0bc45ec into 98c49592d
Pull Request #1535: test(electrum): Test sync in reorg and no-reorg situations

19 of 25 new or added lines in 1 file covered. (76.0%)

1 existing line in 1 file now uncovered.

10908 of 13336 relevant lines covered (81.79%)

12995.15 hits per line

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

36.36
/crates/chain/src/descriptor_ext.rs
1
use crate::miniscript::{Descriptor, DescriptorPublicKey};
2
use bitcoin::hashes::{hash_newtype, sha256, Hash};
3

4
hash_newtype! {
5
    /// Represents the unique ID of a descriptor.
6
    ///
7
    /// This is useful for having a fixed-length unique representation of a descriptor,
8
    /// in particular, we use it to persist application state changes related to the
9
    /// descriptor without having to re-write the whole descriptor each time.
10
    ///
11
    pub struct DescriptorId(pub sha256::Hash);
12
}
13

14
/// A trait to extend the functionality of a miniscript descriptor.
15
pub trait DescriptorExt {
16
    /// Returns the minimum value (in satoshis) at which an output is broadcastable.
17
    /// Panics if the descriptor wildcard is hardened.
18
    fn dust_value(&self) -> u64;
19

20
    /// Returns the descriptor ID, calculated as the sha256 hash of the spk derived from the
21
    /// descriptor at index 0.
22
    fn descriptor_id(&self) -> DescriptorId;
23
}
24

25
impl DescriptorExt for Descriptor<DescriptorPublicKey> {
26
    fn dust_value(&self) -> u64 {
×
27
        self.at_derivation_index(0)
×
28
            .expect("descriptor can't have hardened derivation")
×
29
            .script_pubkey()
×
30
            .minimal_non_dust()
×
31
            .to_sat()
×
32
    }
×
33

34
    fn descriptor_id(&self) -> DescriptorId {
9,452✔
35
        let spk = self.at_derivation_index(0).unwrap().script_pubkey();
9,452✔
36
        DescriptorId(sha256::Hash::hash(spk.as_bytes()))
9,452✔
37
    }
9,452✔
38
}
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