diff --git a/src/eckey.js b/src/eckey.js index 23722d3..dc4cc17 100644 --- a/src/eckey.js +++ b/src/eckey.js @@ -63,7 +63,7 @@ ECKey.prototype.getPub = function(compressed) { * @deprecated Reserved keyword, factory pattern. Use toHex, toBytes, etc. */ ECKey.prototype['export'] = function(format) { - format || (format = 'hex') + var format = format || 'hex' return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]() } @@ -77,7 +77,7 @@ ECKey.version_bytes = { } ECKey.prototype.toWif = function(version) { - var version = version || Network.mainnet.addressVersion; + version = version || Network.mainnet.addressVersion; return base58.checkEncode(this.toBytes(), ECKey.version_bytes[version]) } @@ -147,7 +147,7 @@ ECPubKey.prototype.multiply = function(key) { } ECPubKey.prototype['export'] = function(format) { - format || (format = 'hex') + var format = format || 'hex'; return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]() } @@ -165,7 +165,7 @@ ECPubKey.prototype.toBin = function() { } ECPubKey.prototype.toWif = function(version) { - var version = version || Network.mainnet.addressVersion; + version = version || Network.mainnet.addressVersion; return base58.checkEncode(this.toBytes(), version) } @@ -173,7 +173,7 @@ ECPubKey.prototype.toWif = function(version) { ECPubKey.prototype.toString = ECPubKey.prototype.toHex ECPubKey.prototype.getAddress = function(version) { - var version = version || Network.mainnet.addressVersion; + version = version || Network.mainnet.addressVersion; return new Address(util.sha256ripe160(this.toBytes()), version); } diff --git a/src/opcode.js b/src/opcode.js index 6fc8aad..0db2604 100644 --- a/src/opcode.js +++ b/src/opcode.js @@ -1,4 +1,4 @@ -Opcode = { +var Opcode = { map: { // push value OP_0 : 0, diff --git a/src/transaction.js b/src/transaction.js index d01a920..a0c9760 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -60,8 +60,9 @@ Transaction.prototype.addInput = function (tx, outIndex) { return this.addInput(args[0], args[1]); } else { - var hash = typeof tx === "string" ? tx : tx.hash - var hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash + var hash = typeof tx === "string" ? tx : tx.hash; + hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash; + this.ins.push(new TransactionIn({ outpoint: { hash: hash, @@ -269,7 +270,9 @@ Transaction.deserialize = function(buffer) { } obj.version = readAsInt(4); var ins = readVarInt(); - for (var i = 0; i < ins; i++) { + var i; + + for (i = 0; i < ins; i++) { obj.ins.push({ outpoint: { hash: convert.bytesToHex(readBytes(32).reverse()), @@ -280,12 +283,14 @@ Transaction.deserialize = function(buffer) { }); } var outs = readVarInt(); - for (var i = 0; i < outs; i++) { + + for (i = 0; i < outs; i++) { obj.outs.push({ value: convert.bytesToNum(readBytes(8)), script: new Script(readVarString()) }); } + obj.locktime = readAsInt(4); return new Transaction(obj);