@@ -175,19 +175,6 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
175175 }
176176 }
177177
178- /// Compile [`Policy::Or`] and [`Policy::Threshold`] according to odds
179- #[ cfg( feature = "compiler" ) ]
180- fn compile_tr_policy ( & self ) -> Result < TapTree < Pk > , Error > {
181- let leaf_compilations: Vec < _ > = self
182- . to_tapleaf_prob_vec ( 1.0 )
183- . into_iter ( )
184- . filter ( |x| x. 1 != Policy :: Unsatisfiable )
185- . map ( |( prob, ref policy) | ( OrdF64 ( prob) , compiler:: best_compilation ( policy) . unwrap ( ) ) )
186- . collect ( ) ;
187- let taptree = with_huffman_tree :: < Pk > ( leaf_compilations) . unwrap ( ) ;
188- Ok ( taptree)
189- }
190-
191178 /// Extract the internal_key from policy tree.
192179 #[ cfg( feature = "compiler" ) ]
193180 fn extract_key ( self , unspendable_key : Option < Pk > ) -> Result < ( Pk , Policy < Pk > ) , Error > {
@@ -244,7 +231,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
244231 /// the probabilitity of satisfaction for the respective branch in the TapTree.
245232 // TODO: We might require other compile errors for Taproot.
246233 #[ cfg( feature = "compiler" ) ]
247- pub fn compile_tr ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
234+ pub fn compile_tr_private ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
248235 self . is_valid ( ) ?; // Check for validity
249236 match self . is_safe_nonmalleable ( ) {
250237 ( false , _) => Err ( Error :: from ( CompilerError :: TopLevelNonSafe ) ) ,
@@ -257,7 +244,18 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
257244 internal_key,
258245 match policy {
259246 Policy :: Trivial => None ,
260- policy => Some ( policy. compile_tr_policy ( ) ?) ,
247+ policy => {
248+ let leaf_compilations: Vec < _ > = policy
249+ . to_tapleaf_prob_vec ( 1.0 )
250+ . into_iter ( )
251+ . filter ( |x| x. 1 != Policy :: Unsatisfiable )
252+ . map ( |( prob, ref pol) | {
253+ ( OrdF64 ( prob) , compiler:: best_compilation ( pol) . unwrap ( ) )
254+ } )
255+ . collect ( ) ;
256+ let taptree = with_huffman_tree :: < Pk > ( leaf_compilations) . unwrap ( ) ;
257+ Some ( taptree)
258+ }
261259 } ,
262260 ) ?;
263261 Ok ( tree)
0 commit comments