Skip to content

Adding descriptor generator #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AmosOO7
Copy link

@AmosOO7 AmosOO7 commented May 2, 2025

Description

This PR introduces a new descriptor subcommand to the BDK CLI that enables users to generate Bitcoin wallet descriptors for internal and external paths, supporting common BIP standards (44, 49, 84, 86). It includes support for both single-path and multipath descriptors using an extended key (tprv/tpub).

This resolves issue #175

Note: The --weak option for string-based key generation is intentionally excluded in this PR, pending further instruction.


Features Implemented

  • descriptor subcommand
  • Supports BIP44, BIP49, BIP84, and BIP86 script types
  • Generates internal and external descriptors
  • Supports --multipath for wildcard derivation paths
  • Rejects mismatched key-network pairs (e.g., xprv on testnet)
  • Reasonable defaults:
    • --type defaults to 84
    • --network default testnet
    • --multipath defaults to false

Usage Examples

1. Generate a Private Key (Seed Phrase)

cargo run key generate --entropy 12

2. Generate Descriptors from a Provided Private Key

cargo run -- --network testnet descriptor --type <example: 44, 49, 84, 86,> <XPRV>

Generate a Descriptor from a Seed Phrase (no key provided)

cargo run -- --network testnet descriptor --type 84

Generate Multipath Descriptor from Xpub key

cargo run -- --network testnet descriptor --type 84 --multipath <XPUB>
  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@AmosOO7 AmosOO7 marked this pull request as ready for review May 7, 2025 14:17
@AmosOO7 AmosOO7 force-pushed the adding_descriptor_generator branch from 09b4f4a to ebf6be3 Compare May 7, 2025 16:23
@AmosOO7 AmosOO7 requested a review from tvpeter May 19, 2025 16:21
Copy link
Contributor

@tvpeter tvpeter left a comment

Choose a reason for hiding this comment

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

Good work Amos.

Most of the fns in utils should be in the handlers file, while most of those in handlers should be placed in the utils.

@AmosOO7 AmosOO7 requested a review from tvpeter May 22, 2025 12:31
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.

2 participants