-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Taking input from a transaction that already has one signature (which the library was able to do successfully) and wanting to add another signature to it results in "cannot set property 'script' of undefined" exception when calling buildIncomplete(). The transaction I am importing appears to be valid and it has a single signature on it. I am wanting to sign it with a different private key. Use the below code to reproduce the issue:
var publicKeys = [];
var transaction = bitcoin.TransactionBuilder.fromTransaction(bitcoin.Transaction.fromHex('0100000001a5c7aa80ab9d6326a6379f1d58c81cbdfaa8b62f5b33f5db6398eae090260f5001000000d60047304402206337ac8e557f19642e4f047499d0f35f5aee226ecbded985c43693bac1a38ba90220723f6f62b6bf39c6a0d648333bb16906da06c51037d5eb7a79276c55283605e2014c8b5321033a7c7f13517bfc91d6f0eed0521c0d3bf9efd02c1b53c2cfe4c120ed43fd94bf2103e7bec34f0acb7212b0609c7eb838f68bdd53f46b167aca6b74a32fc8487550c321024e5f6acc4d8c44a0fb5387debcb40b878cdf968dfdc7a12ca245d032fe57022f210284e749647cfc487e2c3789451c836e00142ea755e49c8e88adc80a048c66485e54aeffffffff0130d39700000000001976a9140cb09972f3b035bd303406d3abc6b4945ffc523488ac00000000'));
var privateKey = 'tprv8eNcQizEgG3CMDnUccjj9NdnUb56wvEa48oE5nvG6ydMgFzrjihXR5sNaZcXdQWkv6wyrJDwp6CjRWuPoRgXP1qXNm6nrcXC43Gnj35Q955';
var publicKey1 = 'tpubDBsWPdF1MGjUY5NThEswfH8sMYfzW8Unuoxc6iEScu2ixZuaWvkjerRaZsmao7sySsLghLMLBrujcAkLPCCuK8V9m5WamK5S8UqVsn2PCEE';
var publicKey2 = 'tpubDB4eZ92UpdisEgpGWGQKYnHu3cb37FRUdSQ1NJxZXFRkWkFdN7X7baVEkhVffCTpAvincs3Wa5eFKDQhX3hfSu9L62yV1xraz2aw4hCs5Xe';
var publicKey3 = 'tpubDBfvq13GD9tYHVxsJiqEEcnZ3E9w3SA7eo6kNQYB4gAhNJXbNkDv3mZfkNpKFuR6xh2GEDrf2GB7WpCoo2vyFhYhbMuJa5nqmAA1XzKKSdQ';
var publicKey4 = 'tpubDBU7L1S1cn6iwNTbGJjvoExmmFSfo9YifD9YDZD6oBPdeXWAAGydcXJgxhQg21WNC4PLF2jbt13aL8Jtcjooev1i2Z6FXPjL5W4hMgZnw2G';
var addressIndex = 0;
var privateKeyWallet = bitcoin.HDNode.fromBase58(privateKey).derive(addressIndex);
publicKeys.push(bitcoin.HDNode.fromBase58(publicKey1).derive(addressIndex).pubKey);
publicKeys.push(bitcoin.HDNode.fromBase58(publicKey2).derive(addressIndex).pubKey);
publicKeys.push(bitcoin.HDNode.fromBase58(publicKey3).derive(addressIndex).pubKey);
publicKeys.push(bitcoin.HDNode.fromBase58(publicKey4).derive(addressIndex).pubKey);
var redeemScript = bitcoin.scripts.multisigOutput(3, publicKeys);
for (var i = 0; i < transaction.tx.ins.length; i++) {
transaction.sign(i, privateKeyWallet.privKey, redeemScript);
}
var builtTransaction = transaction.buildIncomplete();
console.log(builtTransaction.toHex());Metadata
Metadata
Assignees
Labels
No labels