@@ -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 > {
@@ -244,7 +231,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
244
231
/// the probabilitity of satisfaction for the respective branch in the TapTree.
245
232
// TODO: We might require other compile errors for Taproot.
246
233
#[ 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 > {
248
235
self . is_valid ( ) ?; // Check for validity
249
236
match self . is_safe_nonmalleable ( ) {
250
237
( false , _) => Err ( Error :: from ( CompilerError :: TopLevelNonSafe ) ) ,
@@ -257,7 +244,18 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
257
244
internal_key,
258
245
match policy {
259
246
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
+ }
261
259
} ,
262
260
) ?;
263
261
Ok ( tree)
0 commit comments