@@ -443,9 +443,9 @@ pub trait PsbtExt {
443443 /// Same as [`PsbtExt::finalize_mut`], but does not mutate the input psbt and
444444 /// returns a new psbt
445445 fn finalize < C : secp256k1:: Verification > (
446- & self ,
446+ self ,
447447 secp : & secp256k1:: Secp256k1 < C > ,
448- ) -> Result < Psbt , Vec < Error > > ;
448+ ) -> Result < Psbt , ( Psbt , Vec < Error > ) > ;
449449
450450 /// Same as [PsbtExt::finalize_mut], but allows for malleable satisfactions
451451 fn finalize_mall_mut < C : secp256k1:: Verification > (
@@ -455,9 +455,9 @@ pub trait PsbtExt {
455455
456456 /// Same as [PsbtExt::finalize], but allows for malleable satisfactions
457457 fn finalize_mall < C : secp256k1:: Verification > (
458- & self ,
458+ self ,
459459 secp : & Secp256k1 < C > ,
460- ) -> Result < Psbt , Vec < Error > > ;
460+ ) -> Result < Psbt , ( Psbt , Vec < Error > ) > ;
461461
462462 /// Same as [`PsbtExt::finalize_mut`], but only tries to finalize a single input leaving other
463463 /// inputs as is. Use this when not all of inputs that you are trying to
@@ -470,10 +470,10 @@ pub trait PsbtExt {
470470
471471 /// Same as [`PsbtExt::finalize_inp_mut`], but does not mutate the psbt and returns a new one
472472 fn finalize_inp < C : secp256k1:: Verification > (
473- & self ,
473+ self ,
474474 secp : & secp256k1:: Secp256k1 < C > ,
475475 index : usize ,
476- ) -> Result < Psbt , Error > ;
476+ ) -> Result < Psbt , ( Psbt , Error ) > ;
477477
478478 /// Same as [`PsbtExt::finalize_inp_mut`], but allows for malleable satisfactions
479479 fn finalize_inp_mall_mut < C : secp256k1:: Verification > (
@@ -484,10 +484,10 @@ pub trait PsbtExt {
484484
485485 /// Same as [`PsbtExt::finalize_inp`], but allows for malleable satisfactions
486486 fn finalize_inp_mall < C : secp256k1:: Verification > (
487- & mut self ,
487+ self ,
488488 secp : & secp256k1:: Secp256k1 < C > ,
489489 index : usize ,
490- ) -> Result < Psbt , Error > ;
490+ ) -> Result < Psbt , ( Psbt , Error ) > ;
491491
492492 /// Psbt extractor as defined in BIP174 that takes in a psbt reference
493493 /// and outputs a extracted bitcoin::Transaction
@@ -566,12 +566,13 @@ impl PsbtExt for Psbt {
566566 }
567567
568568 fn finalize < C : secp256k1:: Verification > (
569- & self ,
569+ mut self ,
570570 secp : & secp256k1:: Secp256k1 < C > ,
571- ) -> Result < Psbt , Vec < Error > > {
572- let mut psbt = self . clone ( ) ;
573- psbt. finalize_mut ( secp) ?;
574- Ok ( psbt)
571+ ) -> Result < Psbt , ( Psbt , Vec < Error > ) > {
572+ match self . finalize_mut ( secp) {
573+ Ok ( ..) => Ok ( self ) ,
574+ Err ( e) => Err ( ( self , e) ) ,
575+ }
575576 }
576577
577578 fn finalize_mall_mut < C : secp256k1:: Verification > (
@@ -595,12 +596,13 @@ impl PsbtExt for Psbt {
595596 }
596597
597598 fn finalize_mall < C : secp256k1:: Verification > (
598- & self ,
599+ mut self ,
599600 secp : & Secp256k1 < C > ,
600- ) -> Result < Psbt , Vec < Error > > {
601- let mut psbt = self . clone ( ) ;
602- psbt. finalize_mall_mut ( secp) ?;
603- Ok ( psbt)
601+ ) -> Result < Psbt , ( Psbt , Vec < Error > ) > {
602+ match self . finalize_mall_mut ( secp) {
603+ Ok ( ..) => Ok ( self ) ,
604+ Err ( e) => Err ( ( self , e) ) ,
605+ }
604606 }
605607
606608 fn finalize_inp_mut < C : secp256k1:: Verification > (
@@ -618,13 +620,14 @@ impl PsbtExt for Psbt {
618620 }
619621
620622 fn finalize_inp < C : secp256k1:: Verification > (
621- & self ,
623+ mut self ,
622624 secp : & secp256k1:: Secp256k1 < C > ,
623625 index : usize ,
624- ) -> Result < Psbt , Error > {
625- let mut psbt = self . clone ( ) ;
626- psbt. finalize_inp_mut ( secp, index) ?;
627- Ok ( psbt)
626+ ) -> Result < Psbt , ( Psbt , Error ) > {
627+ match self . finalize_inp_mut ( secp, index) {
628+ Ok ( ..) => Ok ( self ) ,
629+ Err ( e) => Err ( ( self , e) ) ,
630+ }
628631 }
629632
630633 fn finalize_inp_mall_mut < C : secp256k1:: Verification > (
@@ -642,13 +645,14 @@ impl PsbtExt for Psbt {
642645 }
643646
644647 fn finalize_inp_mall < C : secp256k1:: Verification > (
645- & mut self ,
648+ mut self ,
646649 secp : & secp256k1:: Secp256k1 < C > ,
647650 index : usize ,
648- ) -> Result < Psbt , Error > {
649- let mut psbt = self . clone ( ) ;
650- psbt. finalize_inp_mall_mut ( secp, index) ?;
651- Ok ( psbt)
651+ ) -> Result < Psbt , ( Psbt , Error ) > {
652+ match self . finalize_inp_mall_mut ( secp, index) {
653+ Ok ( ..) => Ok ( self ) ,
654+ Err ( e) => Err ( ( self , e) ) ,
655+ }
652656 }
653657
654658 fn extract < C : secp256k1:: Verification > (
0 commit comments