]> Untitled Git - bdk/commitdiff
Merge bitcoindevkit/bdk#1581: Allow custom fallback algorithm for bnb
authormerge-script <hello@evanlinjin.me>
Thu, 12 Sep 2024 13:46:44 +0000 (21:46 +0800)
committermerge-script <hello@evanlinjin.me>
Thu, 12 Sep 2024 13:46:44 +0000 (21:46 +0800)
65be4ead03126430ab47bf192d0de0db1b1b883a test(coin_selection): add test for deterministic utxo selection (Steve Myers)
c18204d05925c4398e139c6e62c9640dacb67e17 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 65be4ead03126430ab47bf192d0de0db1b1b883a
  evanlinjin:
    self-ACK 65be4ead03126430ab47bf192d0de0db1b1b883a

Tree-SHA512: 3699b65dd3e9b20ad5872a05321a54d0ece61ad582eabe340d4dafbf971cf23bf46b0daa7d1284ec7bc7472d52d54cfa592c9e869ace6e35b8a9dc6938c297a3

1  2 
crates/wallet/src/wallet/mod.rs

Simple merge