Browse Source

Script: adds Script.EMPTY constant

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
9a72c7437b
  1. 3
      src/script.js
  2. 4
      src/transaction.js
  3. 4
      test/transaction.js

3
src/script.js

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

4
src/transaction.js

@ -76,7 +76,7 @@ Transaction.prototype.addInput = function (tx, outIndex) {
hash: hash, hash: hash,
index: outIndex index: outIndex
}, },
script: new Script() script: Script.EMPTY
})) }))
} }
@ -206,7 +206,7 @@ Transaction.prototype.hashForSignature = function(scriptPubKey, inIndex, hashTyp
// Blank out other inputs' signatures // Blank out other inputs' signatures
txTmp.ins.forEach(function(txin) { txTmp.ins.forEach(function(txin) {
txin.script = new Script() txin.script = Script.EMPTY
}) })
txTmp.ins[inIndex].script = hashScript txTmp.ins[inIndex].script = hashScript

4
test/transaction.js

@ -131,7 +131,7 @@ describe('Transaction', function() {
verifyTransactionIn() verifyTransactionIn()
}) })
function verifyTransactionIn(){ function verifyTransactionIn() {
assert.equal(tx.ins.length, 1) assert.equal(tx.ins.length, 1)
var input = tx.ins[0] var input = tx.ins[0]
@ -140,7 +140,7 @@ describe('Transaction', function() {
assert.equal(input.outpoint.index, 0) assert.equal(input.outpoint.index, 0)
assert.equal(input.outpoint.hash, "0cb859105100ebc3344f749c835c7af7d7103ec0d8cbc3d8ccbd5d28c3c36b57") assert.equal(input.outpoint.hash, "0cb859105100ebc3344f749c835c7af7d7103ec0d8cbc3d8ccbd5d28c3c36b57")
assert.deepEqual(input.script.buffer, []) assert.equal(input.script, Script.EMPTY)
} }
}) })

Loading…
Cancel
Save