From 20fd3cee8cba2c8f973658f306b8fa4de6fe0d01 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 18 Aug 2015 09:04:07 +1000 Subject: [PATCH] rename EMPTY to EMPTY_SCRIPT, extract VALUE_UINT64_MAX constant --- src/transaction.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index ca17573..4a5bc0f 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -97,7 +97,7 @@ Transaction.isCoinbaseHash = function (buffer) { }) } -var EMPTY = new Buffer(0) +var EMPTY_SCRIPT = new Buffer(0) Transaction.prototype.addInput = function (hash, index, sequence, script) { typeforce(types.tuple( @@ -111,7 +111,7 @@ Transaction.prototype.addInput = function (hash, index, sequence, script) { sequence = Transaction.DEFAULT_SEQUENCE } - script = script || EMPTY + script = script || EMPTY_SCRIPT // Add the input and return the input's index return (this.ins.push({ @@ -173,6 +173,7 @@ Transaction.prototype.clone = function () { } var ONE = new Buffer('0000000000000000000000000000000000000000000000000000000000000001', 'hex') +var VALUE_UINT64_MAX = new Buffer('ffffffffffffffff', 'hex') /** * Hash transaction for signing a specific input. @@ -198,7 +199,7 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT var i // blank out other inputs' signatures - txTmp.ins.forEach(function (input) { input.script = EMPTY }) + txTmp.ins.forEach(function (input) { input.script = EMPTY_SCRIPT }) txTmp.ins[inIndex].script = hashScript // blank out some of the inputs @@ -224,8 +225,8 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT // blank all other outputs (clear scriptPubKey, value === -1) var stubOut = { - script: EMPTY, - valueBuffer: new Buffer('ffffffffffffffff', 'hex') + script: EMPTY_SCRIPT, + valueBuffer: VALUE_UINT64_MAX } for (i = 0; i < nOut; i++) {