8
8
//! `https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki`
9
9
//!
10
10
11
+ use core:: mem;
12
+
11
13
use bitcoin:: hashes:: hash160;
12
14
use bitcoin:: key:: XOnlyPublicKey ;
13
15
use bitcoin:: secp256k1:: { self , Secp256k1 } ;
@@ -415,8 +417,10 @@ pub(super) fn finalize_input<C: secp256k1::Verification>(
415
417
// Now mutate the psbt input. Note that we cannot error after this point.
416
418
// If the input is mutated, it means that the finalization succeeded.
417
419
{
420
+ let original = mem:: replace ( & mut psbt. inputs [ index] , Default :: default ( ) ) ;
418
421
let input = & mut psbt. inputs [ index] ;
419
- //Fill in the satisfactions
422
+ input. non_witness_utxo = original. non_witness_utxo ;
423
+ input. witness_utxo = original. witness_utxo ;
420
424
input. final_script_sig = if script_sig. is_empty ( ) {
421
425
None
422
426
} else {
@@ -427,25 +431,6 @@ pub(super) fn finalize_input<C: secp256k1::Verification>(
427
431
} else {
428
432
Some ( witness)
429
433
} ;
430
- //reset everything
431
- input. partial_sigs . clear ( ) ; // 0x02
432
- input. sighash_type = None ; // 0x03
433
- input. redeem_script = None ; // 0x04
434
- input. witness_script = None ; // 0x05
435
- input. bip32_derivation . clear ( ) ; // 0x05
436
- // finalized witness 0x06 and 0x07 are not clear
437
- // 0x09 Proof of reserves not yet supported
438
- input. ripemd160_preimages . clear ( ) ; // 0x0a
439
- input. sha256_preimages . clear ( ) ; // 0x0b
440
- input. hash160_preimages . clear ( ) ; // 0x0c
441
- input. hash256_preimages . clear ( ) ; // 0x0d
442
- // psbt v2 fields till 0x012 not supported
443
- input. tap_key_sig = None ; // 0x013
444
- input. tap_script_sigs . clear ( ) ; // 0x014
445
- input. tap_scripts . clear ( ) ; // 0x015
446
- input. tap_key_origins . clear ( ) ; // 0x16
447
- input. tap_internal_key = None ; // x017
448
- input. tap_merkle_root = None ; // 0x018
449
434
}
450
435
451
436
Ok ( ( ) )
0 commit comments