From: 志宇 Date: Thu, 11 May 2023 13:00:23 +0000 (+0800) Subject: Merge bitcoindevkit/bdk#975: Improve `txout` listing and balance APIs for redesigned... X-Git-Tag: v1.0.0-alpha.1~12 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CommandStringError.html?a=commitdiff_plain;h=34d60870ac1bc4a3f83bfa143c6aff7933904933;p=bdk Merge bitcoindevkit/bdk#975: Improve `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 --- 34d60870ac1bc4a3f83bfa143c6aff7933904933