From de0259a820cb759c0147da85dc6be79eafaa4830 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 20 Jul 2018 17:30:18 +1000 Subject: [PATCH] tests/integration/payments: enable failing P2SH(P2WSH(P2WPKH)) tests --- src/transaction_builder.js | 14 ++++++++++++-- test/integration/payments.js | 4 ---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/transaction_builder.js b/src/transaction_builder.js index c4724d0..4545107 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -232,6 +232,11 @@ function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScri expanded.signatures = input.signatures } + let signScript = witnessScript + if (expanded.type === SCRIPT_TYPES.P2WPKH) { + signScript = payments.p2pkh({ pubkey: expanded.pubkeys[0] }).output + } + return { redeemScript, redeemScriptType: SCRIPT_TYPES.P2WSH, @@ -243,7 +248,7 @@ function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScri prevOutScript: p2sh.output, hasWitness: true, - signScript: witnessScript, + signScript, signType: expanded.type, pubkeys: expanded.pubkeys, @@ -303,6 +308,11 @@ function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScri expanded.signatures = input.signatures } + let signScript = witnessScript + if (expanded.type === SCRIPT_TYPES.P2WPKH) { + signScript = payments.p2pkh({ pubkey: expanded.pubkeys[0] }).output + } + return { witnessScript, witnessScriptType: expanded.type, @@ -311,7 +321,7 @@ function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScri prevOutScript: p2wsh.output, hasWitness: true, - signScript: witnessScript, + signScript, signType: expanded.type, pubkeys: expanded.pubkeys, diff --git a/test/integration/payments.js b/test/integration/payments.js index d657f3c..c996f55 100644 --- a/test/integration/payments.js +++ b/test/integration/payments.js @@ -55,15 +55,11 @@ function buildAndSign (depends, prevOutput, redeemScript, witnessScript, done) { }) it('can (as P2WSH(' + k + ')) broadcast as an output, and be spent as an input', (done) => { - if (k === 'p2wpkh') return done() // skip P2WSH(P2WPKH) - const p2wsh = bitcoin.payments.p2wsh({ redeem: { output }, network: NETWORK }) buildAndSign(depends, p2wsh.output, null, p2wsh.redeem.output, done) }) it('can (as P2SH(P2WSH(' + k + '))) broadcast as an output, and be spent as an input', (done) => { - if (k === 'p2wpkh') return done() // skip P2SH(P2WSH(P2WPKH)) - const p2wsh = bitcoin.payments.p2wsh({ redeem: { output }, network: NETWORK }) const p2sh = bitcoin.payments.p2sh({ redeem: { output: p2wsh.output }, network: NETWORK })