@@ -48,13 +48,15 @@ use bdk_wallet::{
4848 key:: { Parity , rand} ,
4949 secp256k1:: { PublicKey , Scalar , SecretKey } ,
5050 } ,
51- descriptor:: { Descriptor , Legacy , Miniscript } ,
51+ descriptor:: { Descriptor , Legacy } ,
5252 miniscript:: { Tap , descriptor:: TapTree , policy:: Concrete } ,
5353} ;
5454
5555use clap:: CommandFactory ;
5656use cli_table:: { Cell , CellStruct , Style , Table , format:: Justify } ;
5757use serde_json:: json;
58+ #[ cfg( feature = "compiler" ) ]
59+ use tap:: Pipe ;
5860
5961#[ cfg( feature = "electrum" ) ]
6062use crate :: utils:: BlockchainClient :: Electrum ;
@@ -1021,16 +1023,12 @@ pub(crate) fn handle_compile_subcommand(
10211023) -> Result < String , Error > {
10221024 let policy = Concrete :: < String > :: from_str ( policy. as_str ( ) ) ?;
10231025
1024- let legacy_policy: Miniscript < String , Legacy > = policy. compile ( ) ?;
1025- let segwit_policy: Miniscript < String , Segwitv0 > = policy. compile ( ) ?;
1026- let taproot_policy: Miniscript < String , Tap > = policy. compile ( ) ?;
1027-
10281026 let mut r = None ;
10291027
10301028 let descriptor = match script_type. as_str ( ) {
1031- "sh" => Descriptor :: new_sh ( legacy_policy ) ,
1032- "wsh" => Descriptor :: new_wsh ( segwit_policy ) ,
1033- "sh-wsh" => Descriptor :: new_sh_wsh ( segwit_policy ) ,
1029+ "sh" => policy . compile :: < Legacy > ( ) ? . pipe ( Descriptor :: new_sh) ,
1030+ "wsh" => policy . compile :: < Segwitv0 > ( ) ? . pipe ( Descriptor :: new_wsh) ,
1031+ "sh-wsh" => policy . compile :: < Segwitv0 > ( ) ? . pipe ( Descriptor :: new_sh_wsh) ,
10341032 "tr" => {
10351033 // For tr descriptors, we use a randomized unspendable key (H + rG).
10361034 // This improves privacy by preventing observers from determining if key path spending is disabled.
@@ -1046,7 +1044,7 @@ pub(crate) fn handle_compile_subcommand(
10461044 let internal_key_point = nums_point. add_exp_tweak ( & secp, & Scalar :: from ( r_secret) ) ?;
10471045 let ( xonly_internal_key, _) = internal_key_point. x_only_public_key ( ) ;
10481046
1049- let tree = TapTree :: Leaf ( Arc :: new ( taproot_policy ) ) ;
1047+ let tree = TapTree :: Leaf ( Arc :: new ( policy . compile :: < Tap > ( ) ? ) ) ;
10501048
10511049 Descriptor :: new_tr ( xonly_internal_key. to_string ( ) , Some ( tree) )
10521050 }
0 commit comments