push
github
Merge bitcoindevkit/bdk#1581: Allow custom fallback algorithm for bnb 65be4ead0 test(coin_selection): add test for deterministic utxo selection (Steve Myers) c18204d05 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 ... (continued)
245 of 258 new or added lines in 3 files covered. (94.96%)
2 existing lines in 1 file now uncovered.11316 of 13703 relevant lines covered (82.58%)
13651.38 hits per line