@@ -425,23 +425,26 @@ fn sanity_check(psbt: &Psbt) -> Result<(), Error> {
425
425
pub trait PsbtExt {
426
426
/// Finalize the psbt. This function takes in a mutable reference to psbt
427
427
/// and populates the final_witness and final_scriptsig
428
- /// of the psbt assuming all of the inputs are miniscript as per BIP174 .
429
- /// If any of the inputs is not miniscript, this returns a parsing error
430
- /// For satisfaction of individual inputs, use the satisfy API.
431
- /// This function also performs a sanity interpreter check on the
428
+ /// for all miniscript inputs .
429
+ ///
430
+ /// Finalizes all inputs that it can finalize, and returns an error for each input
431
+ /// that it cannot finalize. Also performs a sanity interpreter check on the
432
432
/// finalized psbt which involves checking the signatures/ preimages/timelocks.
433
- /// The functions fails it is not possible to satisfy any of the inputs non-malleably
433
+ ///
434
+ /// Input finalization also fails if it is not possible to satisfy any of the inputs non-malleably
434
435
/// See [finalizer::finalize_mall] if you want to allow malleable satisfactions
436
+ ///
437
+ /// For finalizing individual inputs, see also [`PsbtExt::finalize_inp`]
435
438
fn finalize < C : secp256k1:: Verification > (
436
439
& mut self ,
437
440
secp : & secp256k1:: Secp256k1 < C > ,
438
- ) -> Result < ( ) , Error > ;
441
+ ) -> Result < ( ) , Vec < Error > > ;
439
442
440
443
/// Same as [finalize], but allows for malleable satisfactions
441
444
fn finalize_mall < C : secp256k1:: Verification > (
442
445
& mut self ,
443
446
secp : & Secp256k1 < C > ,
444
- ) -> Result < ( ) , Error > ;
447
+ ) -> Result < ( ) , Vec < Error > > ;
445
448
446
449
/// Same as [finalize], but only tries to finalize a single input leaving other
447
450
/// inputs as is. Use this when not all of inputs that you are trying to
@@ -517,15 +520,42 @@ impl PsbtExt for Psbt {
517
520
fn finalize < C : secp256k1:: Verification > (
518
521
& mut self ,
519
522
secp : & secp256k1:: Secp256k1 < C > ,
520
- ) -> Result < ( ) , Error > {
521
- finalizer:: finalize_helper ( self , secp, /*allow_mall*/ false )
523
+ ) -> Result < ( ) , Vec < Error > > {
524
+ // Actually construct the witnesses
525
+ let mut errors = vec ! [ ] ;
526
+ for index in 0 ..self . inputs . len ( ) {
527
+ match finalizer:: finalize_input ( self , index, secp, /*allow_mall*/ false ) {
528
+ Ok ( ..) => { }
529
+ Err ( e) => {
530
+ errors. push ( e) ;
531
+ }
532
+ }
533
+ }
534
+ if errors. is_empty ( ) {
535
+ Ok ( ( ) )
536
+ } else {
537
+ Err ( errors)
538
+ }
522
539
}
523
540
524
541
fn finalize_mall < C : secp256k1:: Verification > (
525
542
& mut self ,
526
543
secp : & secp256k1:: Secp256k1 < C > ,
527
- ) -> Result < ( ) , Error > {
528
- finalizer:: finalize_helper ( self , secp, /*allow_mall*/ true )
544
+ ) -> Result < ( ) , Vec < Error > > {
545
+ let mut errors = vec ! [ ] ;
546
+ for index in 0 ..self . inputs . len ( ) {
547
+ match finalizer:: finalize_input ( self , index, secp, /*allow_mall*/ true ) {
548
+ Ok ( ..) => { }
549
+ Err ( e) => {
550
+ errors. push ( e) ;
551
+ }
552
+ }
553
+ }
554
+ if errors. is_empty ( ) {
555
+ Ok ( ( ) )
556
+ } else {
557
+ Err ( errors)
558
+ }
529
559
}
530
560
531
561
fn finalize_inp < C : secp256k1:: Verification > (
0 commit comments