Bitcoinjs-lib: transaction build error: Transaction is not complete

Created on 3 Jul 2018  路  3Comments  路  Source: bitcoinjs/bitcoinjs-lib

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:

Error: Transaction is not complete
    at /Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/node_modules/bitcoinjs-lib/src/transaction_builder.js:632:48
    at Array.forEach (<anonymous>)
    at TransactionBuilder.__build (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/node_modules/bitcoinjs-lib/src/transaction_builder.js:630:15)
    at TransactionBuilder.build (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/node_modules/bitcoinjs-lib/src/transaction_builder.js:616:15)
    at createSegwitTransaction (/Users/zhaozhiming/playground/bitcoinjs-transaction-not-complete/bitcoin.js:34: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)

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.

Most helpful comment

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);

All 3 comments

@dcousens Thanks for your reply. I try sign twice but I get another error: Error: Signature already exists

Change from

    txb.sign(0, keyPair, redeemScript, null, 2000000);

to

    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);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

itsMikeLowrey picture itsMikeLowrey  路  3Comments

panpan2 picture panpan2  路  3Comments

prahaladbelavadi picture prahaladbelavadi  路  3Comments

Beardcoding picture Beardcoding  路  3Comments

rbndg picture rbndg  路  3Comments