Skip to content

feat: public key generation from descriptors#355

Open
sdmg15 wants to merge 1 commit intobitcoindevkit:masterfrom
sdmg15:feat/pubkey-generation
Open

feat: public key generation from descriptors#355
sdmg15 wants to merge 1 commit intobitcoindevkit:masterfrom
sdmg15:feat/pubkey-generation

Conversation

@sdmg15
Copy link
Copy Markdown

@sdmg15 sdmg15 commented Dec 15, 2025

Description

This PR as a new function to the wallet API public_key_at_index(keychain, index) which returns the public key found at the specified index. It closes #209

Notes to the reviewers

I explicitly matched all arms branches of the Descriptor<DefiniteDescriptorKey> so that if a new type is added in the future it signals there is a need to update this function too.

Changelog notice

  • Add a helper function public_key_at_index(keychain, index) which returns the public key found at the specified index.

Checklists

All Submissions:

New Features:

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 88.37209% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.26%. Comparing base (bec219a) to head (7ac497f).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/wallet/mod.rs 88.37% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage   85.24%   85.26%   +0.01%     
==========================================
  Files          23       23              
  Lines        8230     8273      +43     
==========================================
+ Hits         7016     7054      +38     
- Misses       1214     1219       +5     
Flag Coverage Δ
rust 85.26% <88.37%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sdmg15 sdmg15 marked this pull request as ready for review December 24, 2025 08:57
Copy link
Copy Markdown
Contributor

@AdamuAbba AdamuAbba left a comment

Choose a reason for hiding this comment

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

tACK 7ac497f

Ran the test locally and it was successful.
Screenshot 2026-01-16 at 4 01 28 PM

Comment thread src/wallet/mod.rs Outdated
use crate::test_utils::insert_tx;

#[test]
fn test_generate_publick_keys() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor typo in function name k in public

Suggested change
fn test_generate_publick_keys() {
fn test_generate_public_keys() {

@ValuedMammal ValuedMammal added the new feature New feature or request label Jan 16, 2026
@ValuedMammal ValuedMammal added this to the Wallet 3.0.0 milestone Jan 16, 2026
@ValuedMammal ValuedMammal moved this to In Progress in BDK Wallet Jan 16, 2026
@ValuedMammal
Copy link
Copy Markdown
Collaborator

Since it can be done using rust-miniscript I don't think it's a high priority. Out of curiosity are you sure there's no way to return a public key (or keys) from a Bare, Sh, or Wsh? or is there a reason why that's not desirable?

@sdmg15
Copy link
Copy Markdown
Author

sdmg15 commented Apr 12, 2026

Since it can be done using rust-miniscript I don't think it's a high priority. Out of curiosity are you sure there's no way to return a public key (or keys) from a Bare, Sh, or Wsh? or is there a reason why that's not desirable?

I'm happy to review the API if we want to return multiple public keys. The initial thought was returning only a single one. For wsh, sh to get the keys should require to parse the raw miniscript looking for pk, pkh no?

@sdmg15 sdmg15 force-pushed the feat/pubkey-generation branch from 7ac497f to e925f73 Compare May 5, 2026 09:46
@sdmg15 sdmg15 force-pushed the feat/pubkey-generation branch from e925f73 to 4827e92 Compare May 5, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add deriving public keys from wallet

4 participants