bdk_chain/
lib.rs

1//! This crate is a collection of core structures for [Bitcoin Dev Kit].
2//!
3//! The goal of this crate is to give wallets the mechanisms needed to:
4//!
5//! 1. Figure out what data they need to fetch.
6//! 2. Process the data in a way that never leads to inconsistent states.
7//! 3. Fully index that data and expose it to be consumed without friction.
8//!
9//! Our design goals for these mechanisms are:
10//!
11//! 1. Data source agnostic -- nothing in `bdk_chain` cares about where you get data from or whether
12//!    you do it synchronously or asynchronously. If you know a fact about the blockchain, you can
13//!    just tell `bdk_chain`'s APIs about it, and that information will be integrated, if it can be
14//!    done consistently.
15//! 2. Data persistence agnostic -- `bdk_chain` does not care where you cache on-chain data, what
16//!    you cache or how you retrieve it from persistent storage.
17//!
18//! [Bitcoin Dev Kit]: https://bitcoindevkit.org/
19
20// only enables the `doc_cfg` feature when the `docsrs` configuration attribute is defined
21#![cfg_attr(docsrs, feature(doc_cfg))]
22#![cfg_attr(
23    docsrs,
24    doc(html_logo_url = "https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png")
25)]
26#![no_std]
27#![warn(missing_docs)]
28#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
29
30pub use bitcoin;
31mod balance;
32pub use balance::*;
33mod chain_data;
34pub use chain_data::*;
35pub mod indexed_tx_graph;
36pub use indexed_tx_graph::IndexedTxGraph;
37pub mod indexer;
38pub use indexer::spk_txout;
39pub use indexer::Indexer;
40pub mod local_chain;
41mod tx_data_traits;
42pub use tx_data_traits::*;
43pub mod tx_graph;
44pub use tx_graph::TxGraph;
45mod chain_oracle;
46pub use chain_oracle::*;
47mod canonical_iter;
48pub use canonical_iter::*;
49
50#[doc(hidden)]
51pub mod example_utils;
52
53#[cfg(feature = "miniscript")]
54pub use miniscript;
55#[cfg(feature = "miniscript")]
56mod descriptor_ext;
57#[cfg(feature = "miniscript")]
58pub use descriptor_ext::{DescriptorExt, DescriptorId};
59#[cfg(feature = "miniscript")]
60mod spk_iter;
61#[cfg(feature = "miniscript")]
62pub use indexer::keychain_txout;
63#[cfg(feature = "miniscript")]
64pub use spk_iter::*;
65#[cfg(feature = "rusqlite")]
66pub mod rusqlite_impl;
67
68pub extern crate bdk_core;
69pub use bdk_core::*;
70
71#[allow(unused_imports)]
72#[macro_use]
73extern crate alloc;
74#[cfg(feature = "rusqlite")]
75pub extern crate rusqlite;
76#[cfg(feature = "serde")]
77pub extern crate serde;
78
79#[cfg(feature = "std")]
80#[macro_use]
81extern crate std;
82
83/// A wrapper that we use to impl remote traits for types in our crate or dependency crates.
84pub struct Impl<T>(pub T);
85
86impl<T> Impl<T> {
87    /// Returns the inner `T`.
88    pub fn into_inner(self) -> T {
89        self.0
90    }
91}
92
93impl<T> From<T> for Impl<T> {
94    fn from(value: T) -> Self {
95        Self(value)
96    }
97}
98
99impl<T> core::ops::Deref for Impl<T> {
100    type Target = T;
101
102    fn deref(&self) -> &Self::Target {
103        &self.0
104    }
105}