@@ -1256,11 +1256,8 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
12561256 }
12571257 Ok ( "" . to_string ( ) )
12581258 }
1259- CliSubCommand :: Descriptor {
1260- subcommand : descriptor_subcommand,
1261- } => {
1262- let network = cli_opts. network ;
1263- let descriptor = handle_descriptor_subcommand ( network, descriptor_subcommand, pretty) ?;
1259+ CliSubCommand :: Descriptor { desc_type, key } => {
1260+ let descriptor = handle_descriptor_command ( cli_opts. network , desc_type, key, pretty) ?;
12641261 Ok ( descriptor)
12651262 }
12661263 } ;
@@ -1310,6 +1307,11 @@ async fn respond(
13101307 . map_err ( |e| e. to_string ( ) ) ?;
13111308 Some ( value)
13121309 }
1310+ ReplSubCommand :: Descriptor { desc_type, key } => {
1311+ let value = handle_descriptor_command ( network, desc_type, key, cli_opts. pretty )
1312+ . map_err ( |e| e. to_string ( ) ) ?;
1313+ Some ( value)
1314+ }
13131315 ReplSubCommand :: Exit => None ,
13141316 } ;
13151317 if let Some ( value) = response {
@@ -1336,30 +1338,29 @@ fn readline() -> Result<String, Error> {
13361338 Ok ( buffer)
13371339}
13381340
1339- pub fn handle_descriptor_subcommand (
1341+ /// Handle the descriptor command
1342+ pub fn handle_descriptor_command (
13401343 network : Network ,
1341- subcommand : DescriptorSubCommand ,
1344+ desc_type : String ,
1345+ key : Option < String > ,
13421346 pretty : bool ,
13431347) -> Result < String , Error > {
1344- let result = match subcommand {
1345- DescriptorSubCommand :: Generate { desc_type, key } => {
1346- match key {
1347- Some ( key) => {
1348- if is_mnemonic ( & key) {
1349- // User provided mnemonic
1350- generate_descriptor_from_mnemonic ( & key, network, & desc_type)
1351- } else {
1352- // User provided xprv/xpub
1353- generate_descriptors ( & desc_type, & key, network)
1354- }
1355- }
1356- // Generate new mnemonic and descriptors
1357- None => generate_descriptor_with_mnemonic ( network, & desc_type) ,
1348+ let result = match key {
1349+ Some ( key) => {
1350+ if is_mnemonic ( & key) {
1351+ // User provided mnemonic
1352+ generate_descriptor_from_mnemonic ( & key, network, & desc_type)
1353+ } else {
1354+ // User provided xprv/xpub
1355+ generate_descriptors ( & desc_type, & key, network)
13581356 }
13591357 }
1358+ // Generate new mnemonic and descriptors
1359+ None => generate_descriptor_with_mnemonic ( network, & desc_type) ,
13601360 } ?;
13611361 format_descriptor_output ( & result, pretty)
13621362}
1363+
13631364#[ cfg( any(
13641365 feature = "electrum" ,
13651366 feature = "esplora" ,
0 commit comments