-
Notifications
You must be signed in to change notification settings - Fork 390
Commit 1b50d88
committed
Merge #1581: Allow custom fallback algorithm for bnb
65be4ea test(coin_selection): add test for deterministic utxo selection (Steve Myers)
c18204d feat(wallet)!: allow custom fallback algorithm for bnb (志宇)
Pull request description:
### Description
This allows the caller to set a custom fallback algorithm when using `BranchAndBoundCoinSelection`. Previously, you were forced into using `SingleRandomDraw`.
Signature of `CoinSelectionAlgorithm::coin_select` has been changed to take in a `&mut RangCore`. This allows us to pass the random number generator directly to the cs algorithm.
Single random draw is now it's own type `SingleRandomDraw` and impls `CoinSelectionAlgorithm`.
`BranchAndBoundCoinSelection` now handles it's own fallback algorithm internally, and a generic type parameter is added to specify the fallback algorithm.
`coin_selection::Error` is renamed to `InsufficientFunds` and the BnB error variants are removed. The BnB error variants are no longer needed since those cases are handled internally by `BranchAndBoundCoinSelection` (via calling the fallback algorithm).
### Notes to the reviewers
This is breaking change. Not sure how useful this is for our users. If it's deemed useful, consider including in beta.
### Changelog notice
* Changed `CoinSelectionAlgorithm::coin_select` to take in an additional `&mut RangCore` variable. This allows us to pass a random number generator directly to the cs algorithm.
* Added `SingeRandomDraw` type which impls `CoinSelectAlgorithm`.
* Changed `BranchAndBoundCoinSelection` to call the fallback internally. An additional generic parameter is added set this.
* Changed `coin_selection::Error` to `coin_selection::InsufficientFunds` (which is now a struct) and therefore removing bnb error variants.
### 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
ACKs for top commit:
oleonardolima:
utACK 65be4ea
evanlinjin:
self-ACK 65be4ea
Tree-SHA512: 3699b65dd3e9b20ad5872a05321a54d0ece61ad582eabe340d4dafbf971cf23bf46b0daa7d1284ec7bc7472d52d54cfa592c9e869ace6e35b8a9dc6938c297a3File tree
4 files changed
+347
-174
lines changedFilter options
- crates/wallet
- src/wallet
- tests
4 files changed
+347
-174
lines changed
0 commit comments