bdk_core/
lib.rs

1//! This crate is a collection of core structures for [Bitcoin Dev Kit].
2
3// only enables the `doc_cfg` feature when the `docsrs` configuration attribute is defined
4#![cfg_attr(docsrs, feature(doc_cfg))]
5#![cfg_attr(
6    docsrs,
7    doc(html_logo_url = "https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png")
8)]
9#![no_std]
10#![warn(missing_docs)]
11
12pub use bitcoin;
13
14#[allow(unused_imports)]
15#[macro_use]
16extern crate alloc;
17
18#[allow(unused_imports)]
19#[cfg(feature = "std")]
20#[macro_use]
21extern crate std;
22
23#[cfg(feature = "serde")]
24pub extern crate serde;
25
26#[cfg(all(not(feature = "std"), feature = "hashbrown"))]
27extern crate hashbrown;
28
29// When no-std use `alloc`'s Hash collections. This is activated by default
30#[cfg(all(not(feature = "std"), not(feature = "hashbrown")))]
31#[doc(hidden)]
32pub mod collections {
33    #![allow(dead_code)]
34    pub type HashSet<K> = alloc::collections::BTreeSet<K>;
35    pub type HashMap<K, V> = alloc::collections::BTreeMap<K, V>;
36    pub use alloc::collections::{btree_map as hash_map, *};
37}
38
39// When we have std, use `std`'s all collections
40#[cfg(all(feature = "std", not(feature = "hashbrown")))]
41#[doc(hidden)]
42pub mod collections {
43    pub use std::collections::{hash_map, *};
44}
45
46// With this special feature `hashbrown`, use `hashbrown`'s hash collections, and else from `alloc`.
47#[cfg(feature = "hashbrown")]
48#[doc(hidden)]
49pub mod collections {
50    #![allow(dead_code)]
51    pub type HashSet<K> = hashbrown::HashSet<K>;
52    pub type HashMap<K, V> = hashbrown::HashMap<K, V>;
53    pub use alloc::collections::*;
54    pub use hashbrown::hash_map;
55}
56
57/// A tuple of keychain index and `T` representing the indexed value.
58pub type Indexed<T> = (u32, T);
59/// A tuple of keychain `K`, derivation index (`u32`) and a `T` associated with them.
60pub type KeychainIndexed<K, T> = ((K, u32), T);
61
62mod block_id;
63pub use block_id::*;
64
65mod checkpoint;
66pub use checkpoint::*;
67
68mod tx_update;
69pub use tx_update::*;
70
71mod merge;
72pub use merge::*;
73
74pub mod spk_client;