-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce bdk::Wallet
builder API
#1250
Conversation
The wallet is currently created without setting any lookahead value for the keychain. This implicitly makes it a lookahead of 0. As this is a high-level interface we should avoid footguns and aim for a reasonable default. Instead of simply patching it for wallet, we alter `KeychainTxOutIndex` to have a default lookahead value. Additionally, instead of a per-keychain lookahead, the constructor asks for a `lookahead` value. This avoids the footguns of having methods which allows the caller the decrease the `lookahead` (and therefore panicing). This also simplifies the API. Co-authored-by: Antoine Poisot <darosior@protonmail.com> Co-authored-by: 志宇 <hello@evanlinjin.me>
Previously, the genesis block is not initialized properly. Thank you @notmandatory for identifying this bug.
7084501
to
514f5af
Compare
Wallet error types `NewError` and `NewOrLoadError` have been renamed to `InitError` and `InitOrLoadError`.
514f5af
to
1662340
Compare
Concept ACK, this pattern should also be easier to extend to support future features like custom coin selection. But I'd like to push it to the alpha.4 release, alpha.3 is already long overdue. |
@notmandatory if we wish to make the |
Concept ACK |
use super::{InitError, InitOrLoadError}; | ||
|
||
/// Helper structure to initialize a fresh [`Wallet`] instance. | ||
pub struct WalletBuilder<E> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you feel about just calling this Builder
, i.e. bdk::wallet::Builder
?
It makes sense to complete this AFTER #1203 is merged (as that PR also touches wallet constructors). |
This one needs a rebase after alpha.5 release. |
Builder pattern already introduced. |
Description
This changes the wallet-construction API to use the builder pattern. This is a simpler API and allows us to avoid multiple constructor methods.
I.e. previously, we had
Wallet::new
andWallet::new_with_genesis_hash
. If in the future, we added more parameters, it will turn into an absolute mess.Notes to the reviewers
This PR is based on #1229. Consider reviewing/merging that first!
I think it makes sense to have the
lookahead
configurable inbdk::Wallet
and persisted. However, @LLFourn is against this idea of persisting thelookahead
. This can be of discussion for a future change.Changelog notice
NewError
toInitError
andNewOrLoadError
toInitOrLoadError
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: