Script: adds Script.EMPTY constant

This commit is contained in:
Daniel Cousens 2014-06-12 12:48:04 +10:00
parent ad9a73a81b
commit 9a72c7437b
3 changed files with 7 additions and 4 deletions

View file

@ -414,4 +414,7 @@ Script.prototype.without = function(needle) {
}))
}
// Constants
Script.EMPTY = new Script()
module.exports = Script

View file

@ -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

View file

@ -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)
}
})