|
13 | 13 | //! All subcommands are defined in the below enums.
|
14 | 14 |
|
15 | 15 | #![allow(clippy::large_enum_variant)]
|
16 |
| - |
17 | 16 | use bdk_wallet::bitcoin::{
|
18 | 17 | bip32::{DerivationPath, Xpriv},
|
19 | 18 | Address, Network, OutPoint, ScriptBuf,
|
@@ -109,8 +108,48 @@ pub enum CliSubCommand {
|
109 | 108 | #[command(flatten)]
|
110 | 109 | wallet_opts: WalletOpts,
|
111 | 110 | },
|
| 111 | + /// Generate a random Bitcoin descriptor and mnemonic. |
| 112 | + /// |
| 113 | + /// This function generates a new 12-word BIP39 mnemonic phrase and uses it to derive a BIP32 |
| 114 | + /// extended private key (XPRV). It constructs two BIP86-compatible single-sig descriptors: |
| 115 | + /// - An **external descriptor** used for receiving funds (`/0/*`) |
| 116 | + /// - An **internal descriptor** used for change outputs (`/1/*`) |
| 117 | + /// |
| 118 | + /// These descriptors follow the standard derivation path `m/86h/0h/0h` for mainnet (or `86h/1h/0h` |
| 119 | + /// for testnet), and use `wpkh` (native SegWit) script format. |
| 120 | + /// |
| 121 | + /// The output includes both the public and private forms of the descriptors, along with the mnemonic. |
| 122 | + /// |
| 123 | + /// > ⚠️ This feature is **EXPERIMENTAL** and is intended for testing or development. Do **not** use |
| 124 | + /// > this output to secure real Bitcoin funds on mainnet. |
| 125 | + /// |
| 126 | + /// Returns a JSON object containing: |
| 127 | + /// - `mnemonic`: the 12-word phrase |
| 128 | + /// - `external_descriptor`: public and private forms for receive addresses |
| 129 | + /// - `internal_descriptor`: public and private forms for change addresses. |
| 130 | + Descriptor(GenerateDescriptorArgs), |
112 | 131 | }
|
| 132 | +#[derive(Debug, Clone, PartialEq, Args)] |
| 133 | +pub struct GenerateDescriptorArgs { |
| 134 | + #[clap(long)] |
| 135 | + pub network: Network, |
| 136 | + |
| 137 | + #[clap(long, value_parser = clap::value_parser!(u8).range(44..=86))] |
| 138 | + pub r#type: u8, // 44, 49, 84, 86 |
| 139 | + |
| 140 | + #[clap(long)] |
| 141 | + pub multipath: bool, |
113 | 142 |
|
| 143 | + pub key: Option<String>, // Positional argument (tprv/tpub/xprv/xpub) |
| 144 | +} |
| 145 | + |
| 146 | +#[derive(Debug, Clone, PartialEq, ValueEnum)] |
| 147 | +pub enum ScriptType { |
| 148 | + Bip44, |
| 149 | + Bip49, |
| 150 | + Bip84, |
| 151 | + Bip86, |
| 152 | +} |
114 | 153 | /// Wallet operation subcommands.
|
115 | 154 | #[derive(Debug, Subcommand, Clone, PartialEq)]
|
116 | 155 | pub enum WalletSubCommand {
|
|
0 commit comments