@@ -322,7 +322,7 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
322322 redeemVersion : 192 ,
323323 } ;
324324
325- const { output, address , witness } = bitcoin . payments . p2tr ( {
325+ const { output, witness } = bitcoin . payments . p2tr ( {
326326 internalPubkey : toXOnly ( internalKey . publicKey ) ,
327327 scriptTree,
328328 redeem,
@@ -352,7 +352,21 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
352352 } ,
353353 ] ,
354354 } ) ;
355- psbt . addOutput ( { value : sendAmount , address : address ! } ) ;
355+
356+ const sendInternalKey = bip32 . fromSeed ( rng ( 64 ) , regtest ) ;
357+ const sendPubKey = toXOnly ( sendInternalKey . publicKey ) ;
358+ const { address : sendAddress } = bitcoin . payments . p2tr ( {
359+ internalPubkey : sendPubKey ,
360+ scriptTree : scriptTree ,
361+ network : regtest ,
362+ } ) ;
363+
364+ psbt . addOutput ( { value : sendAmount , address : sendAddress ! } ) ;
365+ // just to test that updateOutput works as expected
366+ psbt . updateOutput ( 0 , {
367+ tapInternalKey : sendPubKey ,
368+ tapTree : { leaves : tapTreeToList ( scriptTree ) } ,
369+ } ) ;
356370
357371 await psbt . signInputAsync ( 0 , leafKey ) ;
358372
@@ -376,7 +390,7 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
376390 await regtestUtils . broadcast ( hex ) ;
377391 await regtestUtils . verify ( {
378392 txId : tx . getId ( ) ,
379- address : address ! ,
393+ address : sendAddress ! ,
380394 vout : 0 ,
381395 value : sendAmount ,
382396 } ) ;
0 commit comments