@@ -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 ;
@@ -1067,16 +1069,12 @@ pub(crate) fn handle_compile_subcommand(
10671069) -> Result < String , Error > {
10681070 let policy = Concrete :: < String > :: from_str ( policy. as_str ( ) ) ?;
10691071
1070- let legacy_policy: Miniscript < String , Legacy > = policy. compile ( ) ?;
1071- let segwit_policy: Miniscript < String , Segwitv0 > = policy. compile ( ) ?;
1072- let taproot_policy: Miniscript < String , Tap > = policy. compile ( ) ?;
1073-
10741072 let mut r = None ;
10751073
10761074 let descriptor = match script_type. as_str ( ) {
1077- "sh" => Descriptor :: new_sh ( legacy_policy ) ,
1078- "wsh" => Descriptor :: new_wsh ( segwit_policy ) ,
1079- "sh-wsh" => Descriptor :: new_sh_wsh ( segwit_policy ) ,
1075+ "sh" => policy . compile :: < Legacy > ( ) ? . pipe ( Descriptor :: new_sh) ,
1076+ "wsh" => policy . compile :: < Segwitv0 > ( ) ? . pipe ( Descriptor :: new_wsh) ,
1077+ "sh-wsh" => policy . compile :: < Segwitv0 > ( ) ? . pipe ( Descriptor :: new_sh_wsh) ,
10801078 "tr" => {
10811079 // For tr descriptors, we use a randomized unspendable key (H + rG).
10821080 // This improves privacy by preventing observers from determining if key path spending is disabled.
@@ -1092,7 +1090,7 @@ pub(crate) fn handle_compile_subcommand(
10921090 let internal_key_point = nums_point. add_exp_tweak ( & secp, & Scalar :: from ( r_secret) ) ?;
10931091 let ( xonly_internal_key, _) = internal_key_point. x_only_public_key ( ) ;
10941092
1095- let tree = TapTree :: Leaf ( Arc :: new ( taproot_policy ) ) ;
1093+ let tree = TapTree :: Leaf ( Arc :: new ( policy . compile :: < Tap > ( ) ? ) ) ;
10961094
10971095 Descriptor :: new_tr ( xonly_internal_key. to_string ( ) , Some ( tree) )
10981096 }
0 commit comments