@@ -159,19 +159,6 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
159
159
}
160
160
}
161
161
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
-
175
162
/// Extract the internal_key from policy tree.
176
163
#[ cfg( feature = "compiler" ) ]
177
164
fn extract_key ( self , unspendable_key : Option < Pk > ) -> Result < ( Pk , Policy < Pk > ) , Error > {
@@ -229,7 +216,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
229
216
/// the probabilitity of satisfaction for the respective branch in the TapTree.
230
217
// TODO: We might require other compile errors for Taproot.
231
218
#[ 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 > {
233
220
self . is_valid ( ) ?; // Check for validity
234
221
match self . is_safe_nonmalleable ( ) {
235
222
( false , _) => Err ( Error :: from ( CompilerError :: TopLevelNonSafe ) ) ,
@@ -242,7 +229,18 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
242
229
internal_key,
243
230
match policy {
244
231
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
+ }
246
244
} ,
247
245
) ?;
248
246
Ok ( tree)
0 commit comments