@@ -242,9 +242,27 @@ pub fn interpreter_check<C: secp256k1::Verification>(
242
242
/// For satisfaction of individual inputs, use the satisfy API.
243
243
/// This function also performs a sanity interpreter check on the
244
244
/// finalized psbt which involves checking the signatures/ preimages/timelocks.
245
+ /// The functions fails it is not possible to satisfy any of the inputs non-malleably
246
+ /// See [finalize_mall] if you want to allow malleable satisfactions
245
247
pub fn finalize < C : secp256k1:: Verification > (
246
248
psbt : & mut Psbt ,
247
249
secp : & Secp256k1 < C > ,
250
+ ) -> Result < ( ) , super :: Error > {
251
+ finalize_helper ( psbt, secp, false )
252
+ }
253
+
254
+ /// Same as [finalize], but allows for malleable satisfactions
255
+ pub fn finalize_mall < C : secp256k1:: Verification > (
256
+ psbt : & mut Psbt ,
257
+ secp : & Secp256k1 < C > ,
258
+ ) -> Result < ( ) , super :: Error > {
259
+ finalize_helper ( psbt, secp, true )
260
+ }
261
+
262
+ pub fn finalize_helper < C : secp256k1:: Verification > (
263
+ psbt : & mut Psbt ,
264
+ secp : & Secp256k1 < C > ,
265
+ allow_mall : bool ,
248
266
) -> Result < ( ) , super :: Error > {
249
267
sanity_check ( psbt) ?;
250
268
@@ -303,9 +321,12 @@ pub fn finalize<C: secp256k1::Verification>(
303
321
let desc = get_descriptor ( & psbt, index) . map_err ( |e| Error :: InputError ( e, index) ) ?;
304
322
305
323
//generate the satisfaction witness and scriptsig
306
- let ( witness, script_sig) = desc
307
- . get_satisfaction ( PsbtInputSatisfier :: new ( & psbt, index) )
308
- . map_err ( |e| Error :: InputError ( InputError :: MiniscriptError ( e) , index) ) ?;
324
+ let ( witness, script_sig) = if !allow_mall {
325
+ desc. get_satisfaction ( PsbtInputSatisfier :: new ( & psbt, index) )
326
+ } else {
327
+ desc. get_satisfaction_mall ( PsbtInputSatisfier :: new ( & psbt, index) )
328
+ }
329
+ . map_err ( |e| Error :: InputError ( InputError :: MiniscriptError ( e) , index) ) ?;
309
330
310
331
let input = & mut psbt. inputs [ index] ;
311
332
//Fill in the satisfactions
0 commit comments