@@ -435,32 +435,59 @@ pub trait PsbtExt {
435
435
/// See [finalizer::finalize_mall] if you want to allow malleable satisfactions
436
436
///
437
437
/// For finalizing individual inputs, see also [`PsbtExt::finalize_inp`]
438
- fn finalize < C : secp256k1:: Verification > (
438
+ fn finalize_mut < C : secp256k1:: Verification > (
439
439
& mut self ,
440
440
secp : & secp256k1:: Secp256k1 < C > ,
441
441
) -> Result < ( ) , Vec < Error > > ;
442
442
443
- /// Same as [finalize], but allows for malleable satisfactions
444
- fn finalize_mall < C : secp256k1:: Verification > (
443
+ /// Same as [`PsbtExt::finalize_mut`], but does not mutate the input psbt and
444
+ /// returns a new psbt
445
+ fn finalize < C : secp256k1:: Verification > (
446
+ & self ,
447
+ secp : & secp256k1:: Secp256k1 < C > ,
448
+ ) -> Result < Psbt , Vec < Error > > ;
449
+
450
+ /// Same as [PsbtExt::finalize_mut], but allows for malleable satisfactions
451
+ fn finalize_mall_mut < C : secp256k1:: Verification > (
445
452
& mut self ,
446
453
secp : & Secp256k1 < C > ,
447
454
) -> Result < ( ) , Vec < Error > > ;
448
455
449
- /// Same as [finalize], but only tries to finalize a single input leaving other
456
+ /// Same as [PsbtExt::finalize], but allows for malleable satisfactions
457
+ fn finalize_mall < C : secp256k1:: Verification > (
458
+ & self ,
459
+ secp : & Secp256k1 < C > ,
460
+ ) -> Result < Psbt , Vec < Error > > ;
461
+
462
+ /// Same as [`PsbtExt::finalize_mut`], but only tries to finalize a single input leaving other
450
463
/// inputs as is. Use this when not all of inputs that you are trying to
451
464
/// satisfy are miniscripts
465
+ fn finalize_inp_mut < C : secp256k1:: Verification > (
466
+ & mut self ,
467
+ secp : & secp256k1:: Secp256k1 < C > ,
468
+ index : usize ,
469
+ ) -> Result < ( ) , Error > ;
470
+
471
+ /// Same as [`PsbtExt::finalize_inp_mut`], but does not mutate the psbt and returns a new one
452
472
fn finalize_inp < C : secp256k1:: Verification > (
473
+ & self ,
474
+ secp : & secp256k1:: Secp256k1 < C > ,
475
+ index : usize ,
476
+ ) -> Result < Psbt , Error > ;
477
+
478
+ /// Same as [`PsbtExt::finalize_inp_mut`], but allows for malleable satisfactions
479
+ fn finalize_inp_mall_mut < C : secp256k1:: Verification > (
453
480
& mut self ,
454
481
secp : & secp256k1:: Secp256k1 < C > ,
455
482
index : usize ,
456
483
) -> Result < ( ) , Error > ;
457
484
458
- /// Same as [finalize_inp], but allows for malleable satisfactions
485
+ /// Same as [`PsbtExt:: finalize_inp` ], but allows for malleable satisfactions
459
486
fn finalize_inp_mall < C : secp256k1:: Verification > (
460
487
& mut self ,
461
488
secp : & secp256k1:: Secp256k1 < C > ,
462
489
index : usize ,
463
- ) -> Result < ( ) , Error > ;
490
+ ) -> Result < Psbt , Error > ;
464
491
465
492
/// Psbt extractor as defined in BIP174 that takes in a psbt reference
466
493
/// and outputs a extracted bitcoin::Transaction
@@ -517,7 +544,7 @@ pub trait PsbtExt {
517
544
}
518
545
519
546
impl PsbtExt for Psbt {
520
- fn finalize < C : secp256k1:: Verification > (
547
+ fn finalize_mut < C : secp256k1:: Verification > (
521
548
& mut self ,
522
549
secp : & secp256k1:: Secp256k1 < C > ,
523
550
) -> Result < ( ) , Vec < Error > > {
@@ -538,7 +565,16 @@ impl PsbtExt for Psbt {
538
565
}
539
566
}
540
567
541
- fn finalize_mall < C : secp256k1:: Verification > (
568
+ fn finalize < C : secp256k1:: Verification > (
569
+ & self ,
570
+ secp : & secp256k1:: Secp256k1 < C > ,
571
+ ) -> Result < Psbt , Vec < Error > > {
572
+ let mut psbt = self . clone ( ) ;
573
+ psbt. finalize_mut ( secp) ?;
574
+ Ok ( psbt)
575
+ }
576
+
577
+ fn finalize_mall_mut < C : secp256k1:: Verification > (
542
578
& mut self ,
543
579
secp : & secp256k1:: Secp256k1 < C > ,
544
580
) -> Result < ( ) , Vec < Error > > {
@@ -558,7 +594,16 @@ impl PsbtExt for Psbt {
558
594
}
559
595
}
560
596
561
- fn finalize_inp < C : secp256k1:: Verification > (
597
+ fn finalize_mall < C : secp256k1:: Verification > (
598
+ & self ,
599
+ secp : & Secp256k1 < C > ,
600
+ ) -> Result < Psbt , Vec < Error > > {
601
+ let mut psbt = self . clone ( ) ;
602
+ psbt. finalize_mall_mut ( secp) ?;
603
+ Ok ( psbt)
604
+ }
605
+
606
+ fn finalize_inp_mut < C : secp256k1:: Verification > (
562
607
& mut self ,
563
608
secp : & secp256k1:: Secp256k1 < C > ,
564
609
index : usize ,
@@ -572,7 +617,17 @@ impl PsbtExt for Psbt {
572
617
finalizer:: finalize_input ( self , index, secp, /*allow_mall*/ false )
573
618
}
574
619
575
- fn finalize_inp_mall < C : secp256k1:: Verification > (
620
+ fn finalize_inp < C : secp256k1:: Verification > (
621
+ & self ,
622
+ secp : & secp256k1:: Secp256k1 < C > ,
623
+ index : usize ,
624
+ ) -> Result < Psbt , Error > {
625
+ let mut psbt = self . clone ( ) ;
626
+ psbt. finalize_inp_mut ( secp, index) ?;
627
+ Ok ( psbt)
628
+ }
629
+
630
+ fn finalize_inp_mall_mut < C : secp256k1:: Verification > (
576
631
& mut self ,
577
632
secp : & secp256k1:: Secp256k1 < C > ,
578
633
index : usize ,
@@ -586,6 +641,16 @@ impl PsbtExt for Psbt {
586
641
finalizer:: finalize_input ( self , index, secp, /*allow_mall*/ false )
587
642
}
588
643
644
+ fn finalize_inp_mall < C : secp256k1:: Verification > (
645
+ & mut self ,
646
+ secp : & secp256k1:: Secp256k1 < C > ,
647
+ index : usize ,
648
+ ) -> Result < Psbt , Error > {
649
+ let mut psbt = self . clone ( ) ;
650
+ psbt. finalize_inp_mall_mut ( secp, index) ?;
651
+ Ok ( psbt)
652
+ }
653
+
589
654
fn extract < C : secp256k1:: Verification > (
590
655
& self ,
591
656
secp : & Secp256k1 < C > ,
0 commit comments