From e5618bb8bd0c69ea9d5677d4a6fc4a3bf8698a49 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sat, 30 Aug 2014 12:52:05 +1000 Subject: [PATCH] TxBuilder: add test for missing redeemScript if P2SH --- test/transaction_builder.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/transaction_builder.js b/test/transaction_builder.js index 7f16dbc..fb2ae67 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -110,6 +110,18 @@ describe('TransactionBuilder', function() { }) }) + describe('when redeemScript is undefined', function() { + it('throws if prevOutScript is P2SH', function() { + var privScriptP2SH = scripts.scriptHashOutput(privScript.getHash()) + + txb.addInput(prevTxHash, 0, undefined, privScriptP2SH) + + assert.throws(function() { + txb.sign(0, privKey) + }, /PrevOutScript is P2SH, missing redeemScript/) + }) + }) + describe('when redeemScript is defined', function() { it('assumes scriptHash', function() { txb.addInput(prevTxHash, 0)