txout
listing and balance APIs for redesigned structures
ed89de752cf20cb80deefda3ddf65a137b669288 Improve txout filter/listing method docs for `TxGraph` (志宇) fb75aa94a9f47d53ce7246c14d739fc53dc38197 Clarify `TxGraph::try_filter_chain_unspents` logic (志宇) 96b10751325dc1bced09f9e864438216400e4ba3 Fix and improve `Persist::commit` method (志宇) e01d17d59bd6177bf5e457232219669782b727b7 Improve `txout` listing and balance APIs for redesigned structures (志宇) Pull request description: ### Description As noted in https://github.com/bitcoindevkit/bdk/issues/971#issuecomment-1542408941. Instead of relying on a `OwnedIndexer` trait to filter for relevant txouts, we move the listing and balance methods from `IndexedTxGraph` to `TxGraph` and add an additional input (list of relevant outpoints) to these methods. This provides a simpler implementation and a more flexible API. #### Other Fixes The `Persist::commit` method is fixed in 96b10751325dc1bced09f9e864438216400e4ba3. Previously, regardless of whether writing to persistence backend is successful or not, the logic always cleared `self.staged`. This is changed to only clear `self.staged` after successful write. Additionally, the written changeset (if any) is returned, and `PersistBackend::write_changes` will not be called if `self.staged` is empty. ### Notes to the reviewers Yes, slightly more boilerplate to do the same things, but less code to maintain and a much more flexible API. Very worth it IMO. ### Changelog notice ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: LLFourn: ACK ed89de752cf20cb80deefda3ddf65a137b669288 Tree-SHA512: efae18c13ee74eff801febca61cb16bf4d8f3203ced96172b9ef555d8d2a749a382f87d024e8c92aacbab7eb4e50a8337de798e10524291ad80c6b35c4dc0161
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.0
which 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_staging
repo where a lot of the component work is being done. The plan is that everything in thebdk_core_staging
repo will be moved into thecrates
directory here.
Architecture
The project is split up into several crates in the /crates
directory:
bdk
: Contains the central high levelWallet
type 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-client
crate with methods to fetch chain data from an esplora HTTP server in the form that [bdk_chain
] andWallet
can consume.electrum
: Extends theelectrum-client
crate with methods to fetch chain data from an electrum server in the form that [bdk_chain
] andWallet
can consume.
Fully working examples of how to use these components are in /example-crates