-   Notifications  
You must be signed in to change notification settings  - Fork 2.2k
 
Closed
Labels
Description
I am trying to construct a transaction using TransactionBuilder and I am doing something wrong, but I can't tell what.
I have this transaction
 https://testnet.blockexplorer.com/tx/0eb90544be26a25942ee61bbaea5e990d0290895cd0ba94127432a0c930b5775
I want to use the first output as an input.
I am doing this:
const privkey = 'private key, belonging to address mowxUGLvamMSYyCUMMzChxgBosUQDvsAMk'; const privkeypair = bitcoin.ECPair.fromWIF(privkey, bitcoin.networks.testnet); const txhex = 'transaction in hex'; const transaction = bitcoin.Transaction.fromHex(txhex); const builder = new bitcoin.TransactionBuilder(bitcoin.networks.testnet); builder.addInput(transaction, 0, 0); builder.addOutput("n4pSwWQZm8Wter1wD6n8RDhEwgCqtQgpcY", 6000); builder.sign(0, privkeypair);And I get this error (using latest in npm)
Error: pubkeyhash not supported at TransactionBuilder.sign (.../node_modules/bitcoinjs-lib/src/transaction_builder.js:482:56) (my file here) Or this error, using master
node_modules/bitcoinjs-lib/src/transaction_builder.js:482 if (!valid) throw new Error('Key pair cannot sign for this input') ^ Error: Key pair cannot sign for this input at TransactionBuilder.sign (.../node_modules/bitcoinjs-lib/src/transaction_builder.js:482:21) (my file here) What am I doing wrong?