@@ -72,7 +72,7 @@ impl Compilable for bitcoin::XOnlyPublicKey {
7272 }
7373}
7474
75- #[ derive( PartialEq , Eq ) ]
75+ #[ derive( PartialEq , Eq , Debug ) ]
7676enum Nullable {
7777 Yes ,
7878 No ,
@@ -90,19 +90,20 @@ fn compute_all_effects<C, A: Default>(
9090 return Ok ( def) ;
9191 }
9292 let mut applied_effects_ctx = top_effect_ctx. derive ( PathFragment :: Effects ) ?;
93- top_effect_ctx
93+ let r = top_effect_ctx
9494 . get_effects ( InternalCompilerTag { _secret : ( ) } )
9595 . get_value ( top_effect_ctx. path ( ) )
9696 // always gets the default expansion, but will also attempt
9797 // operating with the effects passed in through the Context Object.
98- . fold ( Ok ( def) , |a : TxTmplIt , ( k, arg) | -> TxTmplIt {
99- let v = a? ;
98+ . try_fold ( def, |a, ( k, arg) | -> TxTmplIt {
99+ let v = a;
100100 let c = applied_effects_ctx
101101 . derive ( PathFragment :: Named ( SArc ( k. clone ( ) ) ) )
102102 . expect ( UNIQUE_DERIVE_PANIC_MSG ) ;
103103 let w = func. call_json ( self_ref, c, arg. clone ( ) ) ?;
104104 Ok ( Box :: new ( v. chain ( w) ) )
105- } )
105+ } ) ;
106+ r
106107}
107108
108109struct Renamer {
@@ -252,6 +253,7 @@ where
252253 }
253254 . entry ( h)
254255 . or_insert ( txtmpl) ;
256+
255257 let extractor = func. get_extract_clause_from_txtmpl ( ) ;
256258 ( extractor) ( txtmpl, & ctx)
257259 } )
@@ -262,11 +264,12 @@ where
262264
263265 // N.B. the order of the matches below is significant
264266 Ok ( if func. get_returned_txtmpls_modify_guards ( ) {
265- (
267+ let r = (
266268 None ,
267269 combine_txtmpls ( nullability, txtmpl_clauses, guards) ?,
268270 guard_metadata,
269- )
271+ ) ;
272+ r
270273 } else {
271274 let mut cp =
272275 ContinuationPoint :: at ( func. get_schema ( ) . clone ( ) , effect_path. clone ( ) ) ;
@@ -346,6 +349,9 @@ where
346349 Err ( CompilationError :: MinFeerateError )
347350 } else {
348351 let metadata_ctx = ctx. derive ( PathFragment :: Metadata ) ?;
352+ let metadata = self
353+ . metadata ( metadata_ctx) ?
354+ . add_guard_simps ( all_guard_simps) ?;
349355 Ok ( Compiled {
350356 ctv_to_tx : comitted_txns,
351357 suggested_txs : other_txns,
@@ -354,9 +360,7 @@ where
354360 address,
355361 descriptor,
356362 amount_range,
357- metadata : self
358- . metadata ( metadata_ctx) ?
359- . add_guard_simps ( all_guard_simps) ?,
363+ metadata,
360364 } )
361365 }
362366 }
@@ -394,10 +398,13 @@ fn combine_txtmpls(
394398 // Error if 0 templates return and we don't want to be nullable
395399 ( Nullable :: No , 0 , _) => Err ( CompilationError :: MissingTemplates ) ,
396400 // If the guard is trivial, return the hashes standalone
397- ( _, _, Clause :: Trivial ) => Ok ( txtmpl_clauses
398- . into_iter ( )
399- . map ( |policy| policy. compile ( ) . map_err ( Into :: < CompilationError > :: into) )
400- . collect :: < Result < Vec < _ > , _ > > ( ) ?) ,
401+ ( _, _, Clause :: Trivial ) => {
402+ let r = Ok ( txtmpl_clauses
403+ . into_iter ( )
404+ . map ( |policy| policy. compile ( ) . map_err ( Into :: < CompilationError > :: into) )
405+ . collect :: < Result < Vec < _ > , _ > > ( ) ?) ;
406+ r
407+ }
401408 // If the guard is non-trivial, zip it to each hash
402409 // TODO: Arc in miniscript to dedup memory?
403410 // This could be Clause::Shared(x) or something...
0 commit comments