@@ -53,7 +53,7 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
5353 const internalKey = bip32 . fromSeed ( rng ( 64 ) , regtest ) ;
5454 const p2pkhKey = bip32 . fromSeed ( rng ( 64 ) , regtest ) ;
5555
56- const { output, address } = bitcoin . payments . p2tr ( {
56+ const { output } = bitcoin . payments . p2tr ( {
5757 internalPubkey : toXOnly ( internalKey . publicKey ) ,
5858 network : regtest ,
5959 } ) ;
@@ -84,7 +84,17 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
8484 } ) ;
8585 psbt . addInput ( { index : 0 , hash : p2pkhUnspent . txId , nonWitnessUtxo } ) ;
8686
87- psbt . addOutput ( { value : sendAmount , address : address ! } ) ;
87+ const sendInternalKey = bip32 . fromSeed ( rng ( 64 ) , regtest ) ;
88+ const sendPubKey = toXOnly ( sendInternalKey . publicKey ) ;
89+ const { address : sendAddress } = bitcoin . payments . p2tr ( {
90+ internalPubkey : sendPubKey ,
91+ network : regtest ,
92+ } ) ;
93+
94+ psbt . addOutput ( {
95+ value : sendAmount ,
96+ tapInternalKey : sendPubKey ,
97+ } ) ;
8898
8999 const tweakedSigner = tweakSigner ( internalKey ! , { network : regtest } ) ;
90100 await psbt . signInputAsync ( 0 , tweakedSigner ) ;
@@ -99,7 +109,7 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
99109 await regtestUtils . broadcast ( hex ) ;
100110 await regtestUtils . verify ( {
101111 txId : tx . getId ( ) ,
102- address : address ! ,
112+ address : sendAddress ! ,
103113 vout : 0 ,
104114 value : sendAmount ,
105115 } ) ;
0 commit comments