feat(wallet): add transactions_sort_by function
Description
Added new type alias WalletTx which represents a CanonicalTx<'a, Arc<Transaction>, ConfirmationTimeHeightAnchor> and new Wallet::transactions_sort_by that returns a Vec<WalletTx> sorted by the given compare function.
Notes to the reviewers
fixes #794
Changelog notice
- Add new type alias
WalletTxwhich represents aCanonicalTx<'a, Arc<Transaction>, ConfirmationTimeHeightAnchor>. - Add
Wallet::transactions_sort_by()that returns aVec<WalletTx>sorted by a given compare function.
Checklists
All Submissions:
- [x] I've signed all my commits
- [x] I followed the contribution guidelines
- [x] I ran
cargo fmtandcargo clippybefore committing
New Features:
- [x] I've added tests for the new feature
- [x] I've added docs for the new feature
I'm curious if users will also be interested in a list that includes transactions that may not be in the current active chain as was mentioned in #794 (comment)
I like the idea of being able to show TX that are not in the valid chain due to RBF or reorg for a future PR. The idea with this one is to provide only the basic sort functionality for lang bindings to expose.
This only adds a new function and doesn't break any existing APIs so I'm moving this to the beta milestone so we can focus on breaking changes.
Also, we'll still need to work on https://github.com/bitcoindevkit/bdk_wallet/issues/106 in the future, right ?
Also, we'll still need to work on bitcoindevkit/bdk_wallet#106 in the future, right ?
Yes because this is a simple collect() into a Vec and then sorting the vec in the Wallet API.
bitcoindevkit/bdk_wallet#106 is in the Chain API.
@notmandatory I'm happy to merge this now tbh. It doesn't conflict or break anything.
Just adding a +1 for merging this PR 🚀
Rebased and fixed docs.
Back by popular demand, merging this now instead of later.
woohoo!