From 9a72c7437b16731260ae539eb35ad487ea0550e6 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 12 Jun 2014 12:48:04 +1000 Subject: [PATCH] Script: adds Script.EMPTY constant --- src/script.js | 3 +++ src/transaction.js | 4 ++-- test/transaction.js | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/script.js b/src/script.js index cce5189..4b086b9 100644 --- a/src/script.js +++ b/src/script.js @@ -414,4 +414,7 @@ Script.prototype.without = function(needle) { })) } +// Constants +Script.EMPTY = new Script() + module.exports = Script diff --git a/src/transaction.js b/src/transaction.js index be0d0bb..e9590d8 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -76,7 +76,7 @@ Transaction.prototype.addInput = function (tx, outIndex) { hash: hash, index: outIndex }, - script: new Script() + script: Script.EMPTY })) } @@ -206,7 +206,7 @@ Transaction.prototype.hashForSignature = function(scriptPubKey, inIndex, hashTyp // Blank out other inputs' signatures txTmp.ins.forEach(function(txin) { - txin.script = new Script() + txin.script = Script.EMPTY }) txTmp.ins[inIndex].script = hashScript diff --git a/test/transaction.js b/test/transaction.js index e22f7f8..69f6b16 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -131,7 +131,7 @@ describe('Transaction', function() { verifyTransactionIn() }) - function verifyTransactionIn(){ + function verifyTransactionIn() { assert.equal(tx.ins.length, 1) var input = tx.ins[0] @@ -140,7 +140,7 @@ describe('Transaction', function() { assert.equal(input.outpoint.index, 0) assert.equal(input.outpoint.hash, "0cb859105100ebc3344f749c835c7af7d7103ec0d8cbc3d8ccbd5d28c3c36b57") - assert.deepEqual(input.script.buffer, []) + assert.equal(input.script, Script.EMPTY) } })