@@ -22,6 +22,7 @@ mod witness;
22
22
23
23
use std:: sync:: Arc ;
24
24
25
+ use simplicity:: jet:: elements:: ElementsEnv ;
25
26
use simplicity:: { jet:: Elements , CommitNode , RedeemNode } ;
26
27
27
28
pub extern crate either;
@@ -133,15 +134,31 @@ impl CompiledProgram {
133
134
/// - Witness values have a different type than declared in the Simfony program.
134
135
/// - There are missing witness values.
135
136
pub fn satisfy ( & self , witness_values : WitnessValues ) -> Result < SatisfiedProgram , String > {
137
+ self . satisfy_with_env ( witness_values, None )
138
+ }
139
+
140
+ /// Satisfy the Simfony program with the given `witness_values`.
141
+ /// If `env` is `None`, the program is not pruned, otherwise it is pruned with the given environment.
142
+ ///
143
+ /// ## Errors
144
+ ///
145
+ /// - Witness values have a different type than declared in the Simfony program.
146
+ /// - There are missing witness values.
147
+ pub fn satisfy_with_env (
148
+ & self ,
149
+ witness_values : WitnessValues ,
150
+ env : Option < & ElementsEnv < Arc < elements:: Transaction > > > ,
151
+ ) -> Result < SatisfiedProgram , String > {
136
152
witness_values
137
153
. is_consistent ( & self . witness_types )
138
154
. map_err ( |e| e. to_string ( ) ) ?;
139
155
let simplicity_witness = named:: to_witness_node ( & self . simplicity , witness_values) ;
140
- let simplicity_redeem = simplicity_witness
141
- . finalize_unpruned ( )
142
- . map_err ( |e| e. to_string ( ) ) ?;
156
+ let simplicity_redeem = match env {
157
+ Some ( env) => simplicity_witness. finalize_pruned ( env) ,
158
+ None => simplicity_witness. finalize_unpruned ( ) ,
159
+ } ;
143
160
Ok ( SatisfiedProgram {
144
- simplicity : simplicity_redeem,
161
+ simplicity : simplicity_redeem. map_err ( |e| e . to_string ( ) ) ? ,
145
162
debug_symbols : self . debug_symbols . clone ( ) ,
146
163
} )
147
164
}
0 commit comments