This repository was archived by the owner on Oct 22, 2026. It is now read-only.
Repository navigation
descriptor: correct master_fingerprint docs for keys without origin - #1063
Merged
apoelstra merged 1 commit intoOct 13, 2026
Merged
Conversation
The docs for `DescriptorPublicKey::master_fingerprint` and `DefiniteDescriptorKey::master_fingerprint` claimed the result is `0x00000000` when the key has no origin. That has never been the behavior: a key without origin is treated as its own master key, so xpubs return their own fingerprint and single keys return the first four bytes of HASH160 of their serialization. This is the same key origin Bitcoin Core reports for constant pubkeys, and code such as `Assets` in `plan.rs` relies on it to tell origin-less keys apart. Fix the docs to describe the actual behavior, document what the PSBT `update_with_descriptor_unchecked` helpers write into `bip32_derivation` / `tap_key_origins` for such keys, and add tests pinning down the fingerprint for full and x-only keys and the PSBT entries for both segwit v0 and Taproot descriptors. Fixes rust-bitcoin#998
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #998.
The docs for
DescriptorPublicKey::master_fingerprintandDefiniteDescriptorKey::master_fingerprintsaid the result is0x00000000when the key has no origin. The code has never done that. A key without origin is treated as its own master key:Xpub::fingerprint)That is the same key origin Bitcoin Core's descriptor code reports for constant pubkeys (
ConstPubkeyProviderreturns the key ID's fingerprint with an empty path). It is also consistent with BIP-174, where an empty path means the key is its own master.This PR fixes the docs instead of the behavior. Returning
0x00000000would make every origin-less key look the same as(0x00000000, []), which would break key matching inplan::Assets(has_ecdsa_key,has_taproot_*_key). Leaving these keys out of the PSBT origin maps would lose the Taproot leaf-hash information carried intap_key_origins.Changes:
master_fingerprintdocs on both wrappers to describe the real behavior.PsbtInputExt/PsbtOutputExt::update_with_descriptor_uncheckedthat origin-less keys are recorded with their own fingerprint and an empty derivation path.test_master_fingerprintto cover x-only keys andDefiniteDescriptorKey.test_update_item_no_origin_single_key, which checks thebip32_derivation(wpkh) andtap_key_origins(tr) entries from the issue's reproductions.