@@ -53,25 +53,14 @@ describe('BIP322 toSign', function () {
5353 const toSpendTx = bip322 . buildToSpendTransactionFromChainAndIndex ( rootWalletKeys , chain , index , message ) ;
5454 const toSignPsbt = bip322 . buildToSignPsbtForChainAndIndex ( message , rootWalletKeys , chain , index ) ;
5555
56- const derivedKeys = rootWalletKeys . deriveForChainAndIndex ( chain , index ) ;
57- const prv1 = derivedKeys . triple [ 0 ] ;
58- const prv2 = derivedKeys . triple [ 1 ] ;
59- assert . ok ( prv1 ) ;
60- assert . ok ( prv2 ) ;
61-
6256 // Can sign the PSBT with the keys
63- toSignPsbt . signAllInputs ( prv1 , [ utxolib . Transaction . SIGHASH_ALL ] ) ;
64- toSignPsbt . signAllInputs ( prv2 , [ utxolib . Transaction . SIGHASH_ALL ] ) ;
57+ // Should be able to use HD because we have the bip32Derivation information
58+ toSignPsbt . signAllInputsHD ( rootWalletKeys . triple [ 0 ] ) ;
59+ toSignPsbt . signAllInputsHD ( rootWalletKeys . triple [ 1 ] ) ;
6560
6661 // Wrap the PSBT as a UtxoPsbt so that we can use the validateSignaturesOfInputCommon method
6762 const utxopsbt = utxolib . bitgo . createPsbtFromBuffer ( toSignPsbt . toBuffer ( ) , utxolib . networks . bitcoin ) ;
68- derivedKeys . publicKeys . forEach ( ( pubkey , i ) => {
69- assert . deepStrictEqual (
70- utxopsbt . validateSignaturesOfInputCommon ( 0 , pubkey ) ,
71- i !== 2 ,
72- `Signature validation failed for public key at index ${ i } `
73- ) ;
74- } ) ;
63+ utxopsbt . validateSignaturesOfAllInputs ( ) ;
7564
7665 // finalize and extract
7766 const tx = toSignPsbt . finalizeAllInputs ( ) . extractTransaction ( ) ;
@@ -100,6 +89,7 @@ describe('BIP322 toSign', function () {
10089 assert . deepStrictEqual ( toSpendTx . ins . length , 1 , 'to_spend transaction must have one input' ) ;
10190 assert . deepStrictEqual ( toSpendTx . outs . length , 1 , 'to_spend transaction must have one output' ) ;
10291 assert . deepStrictEqual ( toSpendTx . outs [ 0 ] . value , BigInt ( 0 ) , 'output value must be 0' ) ;
92+ const derivedKeys = rootWalletKeys . deriveForChainAndIndex ( chain , index ) ;
10393 assert . deepStrictEqual (
10494 toSpendTx . outs [ 0 ] . script . toString ( 'hex' ) ,
10595 utxolib . bitgo . outputScripts
0 commit comments