Skip to content

feat: expose two path descriptor wallet loading#1042

Merged
reez merged 5 commits into
bitcoindevkit:masterfrom
reez:two-path
Jul 9, 2026
Merged

feat: expose two path descriptor wallet loading#1042
reez merged 5 commits into
bitcoindevkit:masterfrom
reez:two-path

Conversation

@reez

@reez reez commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

#1030 needs to go in first

Description

Adds Wallet::load_from_two_path_descriptor, allowing bindings consumers to load a persisted wallet from a BIP 389 two-path descriptor while checking both external and internal keychains.

This mirrors the upstream bdk_wallet load flow using Wallet::load().two_path_descriptor(...).load_wallet(...).

Notes to the reviewers

Documentation

Changelog

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing
  • I've added exactly one changelog:* label
  • I've linked the relevant upstream docs or specs above

New Features:

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

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@thunderbiscuit thunderbiscuit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few things that need fixing IMO, otherwise the feature is good.

Comment thread bdk-ffi/src/wallet.rs
})
}

/// Build a two-path descriptor `Wallet` by loading from persistence.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Merged yesterday was an update to the API docs for this. See bitcoindevkit/bdk_wallet@77a727d

They now read:

/// The provided descriptor may only contain extended public keys (`xpub`) with exactly 2 paths,
/// or an error will occur at load time.

In our case you can't use that sentence directly because it's just pure impossible to create the Descriptor with private keys so you won't "error at load time", but I would use the first part:

/// The provided descriptor may only contain extended public keys (`xpub`) with exactly 2 paths

Note that this goes away with miniscript 13 so bdk_wallet 4.0. Issue here: bitcoindevkit/bdk_wallet#511.

Comment thread bdk-ffi/src/wallet.rs Outdated
/// Checks that the provided two-path descriptor matches exactly what is loaded
/// for both the external and internal keychains.
///
/// Note that descriptor secret keys are not persisted to the db. This method

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This cannot be done so should be removed from API docs.

Comment thread bdk-ffi/src/wallet.rs Outdated
let wallet: PersistedWallet<PersistenceType> = BdkWallet::load()
.two_path_descriptor(descriptor)
.lookahead(lookahead)
.extract_keys()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And this one too.

Comment thread bdk-ffi/src/wallet.rs Outdated
persister: Arc<Persister>,
lookahead: u32,
) -> Result<Wallet, LoadWithPersistError> {
let descriptor = two_path_descriptor.to_string_with_secret();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can remove this line.

@thunderbiscuit

Copy link
Copy Markdown
Member

Oh shoot sorry @reez I reviewed this commit by commit and was only looking at your commit 3 when I made the comments! My bad.

@thunderbiscuit thunderbiscuit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can keep the API docs you have here if you like, or you can take the ones that were merged on the Rust side if you prefer.

The only valid comment from the review above is that line 199 can be removed, as there are no keys to extract.

@reez

reez commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

undrafted, ready for review

updated pr to address previous comments.

I will squash everything into one commit when I merge after ack

but I made separate commits for the things I addressed so it would be clearer what was addressed and how

@reez reez marked this pull request as ready for review July 9, 2026 16:43
@reez reez requested a review from thunderbiscuit July 9, 2026 16:43

@thunderbiscuit thunderbiscuit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 3141d04. Glad to see this one go in!

@reez reez changed the base branch from master to release/0.30 July 9, 2026 16:51
@reez reez changed the base branch from release/0.30 to master July 9, 2026 16:51
@reez reez merged commit 9e20a7f into bitcoindevkit:master Jul 9, 2026
9 checks passed
@reez reez deleted the two-path branch July 9, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants