@@ -175,19 +175,6 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
175
175
}
176
176
}
177
177
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
-
191
178
/// Extract the internal_key from policy tree.
192
179
#[ cfg( feature = "compiler" ) ]
193
180
fn extract_key ( self , unspendable_key : Option < Pk > ) -> Result < ( Pk , Policy < Pk > ) , Error > {
@@ -245,7 +232,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
245
232
/// the probabilitity of satisfaction for the respective branch in the TapTree.
246
233
// TODO: We might require other compile errors for Taproot.
247
234
#[ cfg( feature = "compiler" ) ]
248
- pub fn compile_tr ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
235
+ pub fn compile_tr_private ( & self , unspendable_key : Option < Pk > ) -> Result < Descriptor < Pk > , Error > {
249
236
self . is_valid ( ) ?; // Check for validity
250
237
match self . is_safe_nonmalleable ( ) {
251
238
( false , _) => Err ( Error :: from ( CompilerError :: TopLevelNonSafe ) ) ,
@@ -258,7 +245,18 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
258
245
internal_key,
259
246
match policy {
260
247
Policy :: Trivial => None ,
261
- policy => Some ( policy. compile_tr_policy ( ) ?) ,
248
+ policy => {
249
+ let leaf_compilations: Vec < _ > = policy
250
+ . to_tapleaf_prob_vec ( 1.0 )
251
+ . into_iter ( )
252
+ . filter ( |x| x. 1 != Policy :: Unsatisfiable )
253
+ . map ( |( prob, ref pol) | {
254
+ ( OrdF64 ( prob) , compiler:: best_compilation ( pol) . unwrap ( ) )
255
+ } )
256
+ . collect ( ) ;
257
+ let taptree = with_huffman_tree :: < Pk > ( leaf_compilations) . unwrap ( ) ;
258
+ Some ( taptree)
259
+ }
262
260
} ,
263
261
) ?;
264
262
Ok ( tree)
0 commit comments