Skip to content
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

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

Conversation

notmandatory
Copy link
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
Contributor

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

crates/wallet/src/wallet/mod.rs Outdated Show resolved Hide resolved
crates/wallet/src/wallet/mod.rs Outdated Show resolved Hide resolved
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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
Contributor

@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
Member Author

closing in favor of #1514

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