@@ -4,7 +4,7 @@ import { getPsbtFixtures } from "./psbtFixtures";
44import { Descriptor , Psbt } from "../js" ;
55
66import { getDescriptorForScriptType } from "./descriptorUtil" ;
7- import { toUtxoPsbt , toWrappedPsbt } from "./psbt.util" ;
7+ import { toUtxoPsbt , toWrappedPsbt , updateInputWithDescriptor } from "./psbt.util" ;
88
99const rootWalletKeys = new utxolib . bitgo . RootWalletKeys ( utxolib . testutil . getKeyTriple ( "wasm" ) ) ;
1010
@@ -25,11 +25,12 @@ function describeUpdateInputWithDescriptor(
2525 throw new Error ( "Could not find fullsigned fixture" ) ;
2626 }
2727
28- describe ( "updateInputWithDescriptor" , function ( ) {
28+ const descriptorStr = getDescriptorForScriptType ( rootWalletKeys , scriptType , "internal" ) ;
29+ const index = 0 ;
30+ const descriptor = Descriptor . fromString ( descriptorStr , "derivable" ) ;
31+
32+ describe ( "Wrapped PSBT updateInputWithDescriptor" , function ( ) {
2933 it ( "should update the input with the descriptor" , function ( ) {
30- const descriptorStr = getDescriptorForScriptType ( rootWalletKeys , scriptType , "internal" ) ;
31- const index = 0 ;
32- const descriptor = Descriptor . fromString ( descriptorStr , "derivable" ) ;
3334 const wrappedPsbt = toWrappedPsbt ( psbt ) ;
3435 wrappedPsbt . updateInputWithDescriptor ( 0 , descriptor . atDerivationIndex ( index ) ) ;
3536 const updatedPsbt = toUtxoPsbt ( wrappedPsbt ) ;
@@ -47,6 +48,21 @@ function describeUpdateInputWithDescriptor(
4748 ) ;
4849 } ) ;
4950 } ) ;
51+
52+ describe ( "updateInputWithDescriptor util" , function ( ) {
53+ it ( "should update the input with the descriptor" , function ( ) {
54+ const cloned = psbt . clone ( ) ;
55+ updateInputWithDescriptor ( cloned , 0 , descriptor . atDerivationIndex ( index ) ) ;
56+ cloned . signAllInputsHD ( rootWalletKeys . triple [ 0 ] ) ;
57+ cloned . signAllInputsHD ( rootWalletKeys . triple [ 2 ] ) ;
58+ cloned . finalizeAllInputs ( ) ;
59+
60+ assertEqualBuffer (
61+ fullSignedFixture . psbt . clone ( ) . finalizeAllInputs ( ) . extractTransaction ( ) . toBuffer ( ) ,
62+ cloned . extractTransaction ( ) . toBuffer ( ) ,
63+ ) ;
64+ } ) ;
65+ } ) ;
5066}
5167
5268fixtures . forEach ( ( { psbt, scriptType, stage } ) => {
0 commit comments