]> Untitled Git - bdk/commit
feat(wallet)!: allow custom fallback algorithm for bnb
author志宇 <hello@evanlinjin.me>
Wed, 28 Aug 2024 09:49:55 +0000 (09:49 +0000)
committerSteve Myers <steve@notmandatory.org>
Tue, 10 Sep 2024 15:52:11 +0000 (10:52 -0500)
commitc18204d05925c4398e139c6e62c9640dacb67e17
tree543cff749b377deb632f9fa5a06cb7ab791a8fcb
parent8760653339d3a4c66dfa9a54a7b9d943a065f924
feat(wallet)!: allow custom fallback algorithm for bnb

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).

Add test_bnb_fallback_algorithm test and docs cleanup suggested by @ValuedMammal.
crates/wallet/src/wallet/coin_selection.rs
crates/wallet/src/wallet/error.rs
crates/wallet/src/wallet/mod.rs
crates/wallet/tests/wallet.rs