LocalChain and update chain-src crates/examples
This commit changes the `LocalChain` implementation to have blocks stored as a linked-list. This allows the data-src thread to hold a shared ref to a single checkpoint and have access to the whole history of checkpoints without cloning or keeping a lock on `LocalChain`. The APIs of `bdk::Wallet`, `esplora` and `electrum` are also updated to reflect these changes. Note that the `esplora` crate is rewritten to anchor txs in the confirmation block (using the esplora API's tx status block_hash). This guarantees 100% consistency between anchor blocks and their transactions (instead of anchoring txs to the latest tip). `ExploraExt` now has separate methods for updating the `TxGraph` and `LocalChain`. A new method `TxGraph::missing_blocks` is introduced for finding "floating anchors" of a `TxGraph` update (given a chain). Additional changes: * `test_local_chain.rs` is refactored to make test cases easier to write. Additional tests are also added. * Examples are updated. * Fix `tempfile` dev dependency of `bdk_file_store` to work with MSRV Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
The Bitcoin Dev Kit
BDK
A modern, lightweight, descriptor-based wallet library written in Rust!
Project Homepage | Documentation
About
The bdk libraries aims to provide well engineered and reviewed components for Bitcoin based applications.
It is built upon the excellent rust-bitcoin and rust-miniscript crates.
⚠ The Bitcoin Dev Kit developers are in the process of releasing a
v1.0which is a fundamental re-write of how the library works. See for some background on this project: https://bitcoindevkit.org/blog/road-to-bdk-1/ (ignore the timeline 😁) For a release timeline see thebdk_core_stagingrepo where a lot of the component work is being done. The plan is that everything in thebdk_core_stagingrepo will be moved into thecratesdirectory here.
Architecture
The project is split up into several crates in the /crates directory:
bdk: Contains the central high levelWallettype that is built from the low-level mechanisms provided by the other componentschain: Tools for storing and indexing chain datafile_store: A (experimental) persistence backend for storing chain data in a single file.esplora: Extends theesplora-clientcrate with methods to fetch chain data from an esplora HTTP server in the form that [bdk_chain] andWalletcan consume.electrum: Extends theelectrum-clientcrate with methods to fetch chain data from an electrum server in the form that [bdk_chain] andWalletcan consume.
Fully working examples of how to use these components are in /example-crates