From c60a6418b57fe746107b5c92626449f2c3518616 Mon Sep 17 00:00:00 2001 From: Thomas Kerin Date: Sat, 12 Nov 2016 17:10:53 +0100 Subject: [PATCH] working again --- latest/spend_p2sh_p2wpkh.js | 2 +- latest/spend_p2sh_p2wsh.js | 2 +- src/transaction_signer.js | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/latest/spend_p2sh_p2wpkh.js b/latest/spend_p2sh_p2wpkh.js index 13e9799..ad8745f 100644 --- a/latest/spend_p2sh_p2wpkh.js +++ b/latest/spend_p2sh_p2wpkh.js @@ -43,4 +43,4 @@ signer.sign(0, root.keyPair, { value: txOut.value }) var txd = signer.done() -console.log(txd.toBufferWithWitness().toString('hex')) +console.log(txd.toBuffer().toString('hex')) diff --git a/latest/spend_p2sh_p2wsh.js b/latest/spend_p2sh_p2wsh.js index 069d008..0b3c8af 100644 --- a/latest/spend_p2sh_p2wsh.js +++ b/latest/spend_p2sh_p2wsh.js @@ -29,7 +29,7 @@ builder.addOutput('2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ', 10000) var unsigned = builder.buildIncomplete() var signer = new TxSigner(unsigned) signer.sign(0, root.keyPair, { - scriptPubKey: txOut.scriptPubKey, + scriptPubKey: txOut.script, redeemScript: p2shScript, witnessScript: witnessScript, value: txOut.value diff --git a/src/transaction_signer.js b/src/transaction_signer.js index 122d0b4..f56e659 100644 --- a/src/transaction_signer.js +++ b/src/transaction_signer.js @@ -355,7 +355,7 @@ InSigner.prototype.sign = function (key, sigHashType) { if (solution.type === bscript.types.P2SH) { // solution updated, type is the type of the redeemScript solution = this.redeemScript - if (bscript.P2SH_SCRIPTS.indexOf(solution.type)) { + if (ALLOWED_P2SH_SCRIPTS.indexOf(solution.type) !== -1) { if (solution.canSign) { [this.signatures, this.publicKeys] = signStandard(this.tx, this.nIn, undefined, this.signatures, this.publicKeys, key, solution, sigHashType, Transaction.SIG_V0) } @@ -484,7 +484,6 @@ TxSigner.prototype.sign = function (nIn, key, opts, sigHashType) { } // You can probably make this work with the current library, if you can work out the witnessScript above! // generate opts for the internal signer based off older way of positional arguments to TxSigner.sign - if (this.states[nIn] === undefined) { this.states[nIn] = new InSigner(this.tx, nIn, opts) }