@@ -159,19 +159,6 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
159159 }
160160 }
161161
162- /// Compile [`Policy::Or`] and [`Policy::Threshold`] according to odds
163- #[ cfg( feature = "compiler" ) ]
164- fn compile_tr_policy ( & self ) -> Result < TapTree < Pk > , Error > {
165- let leaf_compilations: Vec < _ > = self
166- . to_tapleaf_prob_vec ( 1.0 )
167- . into_iter ( )
168- . filter ( |x| x. 1 != Policy :: Unsatisfiable )
169- . map ( |( prob, ref policy) | ( OrdF64 ( prob) , compiler:: best_compilation ( policy) . unwrap ( ) ) )
170- . collect ( ) ;
171- let taptree = with_huffman_tree :: < Pk > ( leaf_compilations) . unwrap ( ) ;
172- Ok ( taptree)
173- }
174-
175162 /// Extract the internal_key from policy tree.
176163 #[ cfg( feature = "compiler" ) ]
177164 fn extract_key ( self , unspendable_key : Option < Pk > ) -> Result < ( Pk , Policy < Pk > ) , Error > {
@@ -229,7 +216,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
229216 /// the probabilitity of satisfaction for the respective branch in the TapTree.
230217 // TODO: We might require other compile errors for Taproot.
231218 #[ cfg( feature = "compiler" ) ]
232- pub fn compile_tr ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
219+ pub fn compile_tr_private ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
233220 self . is_valid ( ) ?; // Check for validity
234221 match self . is_safe_nonmalleable ( ) {
235222 ( false , _) => Err ( Error :: from ( CompilerError :: TopLevelNonSafe ) ) ,
@@ -242,7 +229,18 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
242229 internal_key,
243230 match policy {
244231 Policy :: Trivial => None ,
245- policy => Some ( policy. compile_tr_policy ( ) ?) ,
232+ policy => {
233+ let leaf_compilations: Vec < _ > = policy
234+ . to_tapleaf_prob_vec ( 1.0 )
235+ . into_iter ( )
236+ . filter ( |x| x. 1 != Policy :: Unsatisfiable )
237+ . map ( |( prob, ref pol) | {
238+ ( OrdF64 ( prob) , compiler:: best_compilation ( pol) . unwrap ( ) )
239+ } )
240+ . collect ( ) ;
241+ let taptree = with_huffman_tree :: < Pk > ( leaf_compilations) . unwrap ( ) ;
242+ Some ( taptree)
243+ }
246244 } ,
247245 ) ?;
248246 Ok ( tree)
0 commit comments