Closed zhaozhiming closed 6 years ago
@zhaozhiming you have two inputs.
You need to sign both.
@dcousens Thanks for your reply. I try sign twice but I get another error: Error: Signature already exists
txb.sign(0, keyPair, redeemScript, null, 2000000);
txb.sign(0, keyPair, redeemScript, null, 10000);
txb.sign(0, keyPair, redeemScript, null, 1990000);
The error:
Error: Signature already exists
at /Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/node_modules/bitcoinjs-lib/src/transaction_builder.js:707:36
at Array.some (<anonymous>)
at TransactionBuilder.sign (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/node_modules/bitcoinjs-lib/src/transaction_builder.js:705:30)
at createSegwitTransaction (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/bitcoin.js:33:9)
at Object.<anonymous> (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/bitcoin.js:40:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
These 2 inputs is the same segwit address so I think it should use the same keypair and redeemScript.
I have not idea what is wrong here. Please help. Thanks.
Oh, I understand now. I change the code as follow and it work.
I should change the first parameter of the second sign method to 1
.
Thanks.
txb.sign(0, keyPair, redeemScript, null, 10000);
txb.sign(1, keyPair, redeemScript, null, 1990000);
Hi, I create a transaction with a SegWit P2SH(P2WPKH) input. But when I run use my testnet address I got the error as follow:
My bitcoinjs-lib version is
3.3.2
Node version:8.9.0
Npm version:5.5.1
The reproduce github repository is here. My testnet address info: https://testnet.blockchain.info/address/2NBPFSS1aLjE9uf2rdzQVWhBT9VHoDxKvyh Please help. Thanks.