Skip to content

fix(keymap): backport use of correct derivation_path for keys with origin#867

Open
oleonardolima wants to merge 2 commits into
rust-bitcoin:release-12.xfrom
oleonardolima:backport-863-to-12.x
Open

fix(keymap): backport use of correct derivation_path for keys with origin#867
oleonardolima wants to merge 2 commits into
rust-bitcoin:release-12.xfrom
oleonardolima:backport-863-to-12.x

Conversation

@oleonardolima

@oleonardolima oleonardolima commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

backports #872

Description

It backports the fix for deriving the private key correctly in scenarios where the key origin is available, see #872.

The GetKey for DescriptorSecretKey (and thus KeyMap) returned the wrong key when an extended private key with key origin info was queried via KeyRequest::Bip32.

The key request path is master-relative, but the xkey is anchored at its origin (e.g. [d34db33f/84h/1h/0h]). The old code stripped the path returned by matches(); the fix strips the origin prefix instead (and uses the full path when there is no origin) before deriving from the xkey.

cherry-picks 20ae466 and a2f4497.

Changelog notice

### Fixed
- keymap: fix `GetKey` derivation path for `Xprv` with key origin info [#872](https://github.com/rust-bitcoin/rust-miniscript/pull/872)

Checklists

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

@tcharding

Copy link
Copy Markdown
Member

Do you want review mate? Why's it draft?

@oleonardolima oleonardolima marked this pull request as ready for review October 18, 2025 21:19
@oleonardolima

Copy link
Copy Markdown
Contributor Author

Do you want review mate? Why's it draft?

Yeah, I was just waiting for CI, it should be ready to go.

@tcharding tcharding 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 10fd701

@oleonardolima

Copy link
Copy Markdown
Contributor Author

I'll move this one back to draft while I fix the issue mentioned at the summit, and backport all the fixes at once.

@notmandatory

Copy link
Copy Markdown
Contributor

@oleonardolima just a ping, can this be updated and made ready to review now?

@oleonardolima

Copy link
Copy Markdown
Contributor Author

@oleonardolima just a ping, can this be updated and made ready to review now?

I'll rebase it and get it ready for review today.

@oleonardolima

Copy link
Copy Markdown
Contributor Author

@oleonardolima just a ping, can this be updated and made ready to review now?

@notmandatory I updated the original fix in #872 (also needs review), I'm backporting it here now.

@oleonardolima oleonardolima force-pushed the backport-863-to-12.x branch from d6a94e3 to f3d1b63 Compare June 16, 2026 20:49
- backports rust-bitcoin#872 fixes for the implementation of `GetKey` for `Xprv` with
  `KeyRequest::Bip32`, when the the key_origin information is available.
- introduces a new test for a scenario with no wildcard used, a specific
  derivation index is used instead.
- backports introduced rust-bitcoin#872 table-driven test cases for
  `get_key_xpriv_with_key_origin` with named fields
- drop redundant key parsing, and build requests from explicit
  key sources

Assisted-by: Claude Opus 4.8
@oleonardolima oleonardolima force-pushed the backport-863-to-12.x branch from f3d1b63 to 3f77767 Compare June 16, 2026 21:29
@oleonardolima oleonardolima marked this pull request as ready for review June 16, 2026 21:45
@oleonardolima

Copy link
Copy Markdown
Contributor Author

@oleonardolima just a ping, can this be updated and made ready to review now?

@notmandatory I updated the original fix in #872 (also needs review), I'm backporting it here now.

I updated this PR and added new test scenarios, it should be ready to review.

cc'in @noahjoeris as you had interest in this and a review would be appreciated.

@notmandatory notmandatory left a comment

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.

ACK 3f77767

Accurately back ports #872, should be good to go after that one is merged.

@noahjoeris noahjoeris left a comment

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.

ACK 3f77767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants