Skip to content

refactor(wallet)!: Replace new_or_load() with load_with_descriptors()#1512

Closed
notmandatory wants to merge 1 commit intobitcoindevkit:masterfrom
notmandatory:refactor/wallet_construct
Closed

refactor(wallet)!: Replace new_or_load() with load_with_descriptors()#1512
notmandatory wants to merge 1 commit intobitcoindevkit:masterfrom
notmandatory:refactor/wallet_construct

Conversation

@notmandatory
Copy link
Copy Markdown
Member

Description

Replace Wallet::new_or_load() with Wallet::load_with_descriptors(). Updated Wallet::load_with_descriptors() now requires a ChangeSet and descriptors, and validates they match, if the given descriptors have private keys it adds signers.

Also rename Wallet::load_from_changeset() to Wallet::load() and remove no longer needed NewOrLoadError.

Notes to the reviewers

Based on discussion in #1500.

Changelog notice

Changed

  • Replace Wallet::new_or_load() with Wallet::load_with_descriptors().
  • Rename Wallet::load_from_changeset() to load() and remove no longer needed NewOrLoadError.

Checklists

All Submissions:

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

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@notmandatory notmandatory force-pushed the refactor/wallet_construct branch 3 times, most recently from c639329 to 91fd8d8 Compare July 12, 2024 00:17
@notmandatory notmandatory self-assigned this Jul 12, 2024
@notmandatory notmandatory added module-wallet api A breaking API change labels Jul 12, 2024
@notmandatory notmandatory added this to the 1.0.0-alpha milestone Jul 12, 2024
@notmandatory notmandatory force-pushed the refactor/wallet_construct branch from 91fd8d8 to fa2f2ab Compare July 12, 2024 02:17
@notmandatory notmandatory marked this pull request as ready for review July 12, 2024 02:23
Copy link
Copy Markdown

@storopoli storopoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some brief notes that I saw while skimming over.

Comment thread crates/wallet/src/wallet/mod.rs Outdated
Comment thread crates/wallet/src/wallet/mod.rs Outdated
Updated load_with_descriptors() requires a ChangeSet and descriptors, validates they match. If the given descriptors have private keys signers are added.

Also rename load_from_changeset() to load() and remove no longer needed NewOrLoadError.
let mut wallet = if let Some(changeset) = changeset {
Wallet::load_with_descriptors(external_descriptor, internal_descriptor, changeset)?
} else {
Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency should we have Signet here?

Suggested change
Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)?
Wallet::new(external_descriptor, internal_descriptor, Network::Signet)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed already in #1442.

let mut wallet = if let Some(changeset) = changeset {
Wallet::load_with_descriptors(&args.descriptor, &args.change_descriptor, changeset)?
} else {
Wallet::new(&args.descriptor, &args.change_descriptor, Network::Testnet)?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Wallet::new(&args.descriptor, &args.change_descriptor, Network::Testnet)?
Wallet::new(&args.descriptor, &args.change_descriptor, args.network)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed already in #1442.

Copy link
Copy Markdown
Collaborator

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking good, the API got much more intelligible to me.
Concept ACK

@notmandatory
Copy link
Copy Markdown
Member Author

closing in favor of #1514

@notmandatory notmandatory deleted the refactor/wallet_construct branch May 26, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A breaking API change module-wallet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants