bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Introduce `bdk::Wallet` builder API

Open evanlinjin opened this issue 2 years ago • 5 comments

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 and Wallet::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 in bdk::Wallet and persisted. However, @LLFourn is against this idea of persisting the lookahead. This can be of discussion for a future change.

Changelog notice

  • Changed wallet-construction API to use the builder pattern.
  • Changed NewError to InitError and NewOrLoadError to InitOrLoadError.

Checklists

All Submissions:

  • [x] I've signed all my commits
  • [x] I followed the contribution guidelines
  • [x] I ran cargo fmt and cargo clippy before committing

New Features:

  • [ ] I've added tests for the new feature
  • [x] I've added docs for the new feature

evanlinjin avatar Dec 28 '23 05:12 evanlinjin

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 avatar Dec 28 '23 20:12 notmandatory

@notmandatory if we wish to make the lookahead configurable in bdk::Wallet for alpha.3, I think it will be a good idea to include this in the release. Otherwise, I am okay with pushing this back.

evanlinjin avatar Dec 29 '23 04:12 evanlinjin

Concept ACK

LLFourn avatar Jan 03 '24 05:01 LLFourn

It makes sense to complete this AFTER #1203 is merged (as that PR also touches wallet constructors).

evanlinjin avatar Jan 31 '24 16:01 evanlinjin

This one needs a rebase after alpha.5 release.

notmandatory avatar Jan 31 '24 16:01 notmandatory

Builder pattern already introduced.

evanlinjin avatar Aug 25 '24 13:08 evanlinjin