Skip to content

Implement Fingerprint Extraction from BIP380 descriptors#24

Closed
cc-unchained wants to merge 1 commit intocaravan-bitcoin:mainfrom
cc-unchained:bip380-fingerprint
Closed

Implement Fingerprint Extraction from BIP380 descriptors#24
cc-unchained wants to merge 1 commit intocaravan-bitcoin:mainfrom
cc-unchained:bip380-fingerprint

Conversation

@cc-unchained
Copy link
Copy Markdown

Summary

Implement fingerprint extraction from BIP380 descriptors

This change adds a new function getFingerprintFromBip380Descriptor to extract the master key fingerprint from BIP380 descriptor strings. The function parses the key origin information (enclosed in square brackets) and returns the fingerprint as a lowercase hex string.

Key Changes

  • New function: getFingerprintFromBip380Descriptor(descriptor: string): string | null

  • Uses regex pattern to match [fingerprint]/ format

  • Returns fingerprint in lowercase hex or null if not found

  • Handles both uppercase and lowercase input

  • Comprehensive tests covering:

  • wpkh descriptors with key origin

  • sh(wpkh) descriptors with key origin

  • Descriptors without key origin (returns null)

  • Invalid descriptors (returns null)

  • Case normalization to lowercase

Usage

const descriptor = "wpkh([d34db33f/44'/0'/0']xpub.../1/*)";
const fingerprint = getFingerprintFromBip380Descriptor(descriptor);
// Returns: "d34db33f"

This enhancement improves compatibility with BIP380 standards and provides
convenient access to fingerprint information for wallet management and key
identification.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: d69b9ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@caravan/descriptors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant