Browse Source

Fixes variable redeclarations

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
87453f1828
  1. 10
      src/eckey.js
  2. 2
      src/opcode.js
  3. 13
      src/transaction.js

10
src/eckey.js

@ -63,7 +63,7 @@ ECKey.prototype.getPub = function(compressed) {
* @deprecated Reserved keyword, factory pattern. Use toHex, toBytes, etc. * @deprecated Reserved keyword, factory pattern. Use toHex, toBytes, etc.
*/ */
ECKey.prototype['export'] = function(format) { ECKey.prototype['export'] = function(format) {
format || (format = 'hex') var format = format || 'hex'
return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]() return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]()
} }
@ -77,7 +77,7 @@ ECKey.version_bytes = {
} }
ECKey.prototype.toWif = function(version) { 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]) return base58.checkEncode(this.toBytes(), ECKey.version_bytes[version])
} }
@ -147,7 +147,7 @@ ECPubKey.prototype.multiply = function(key) {
} }
ECPubKey.prototype['export'] = function(format) { ECPubKey.prototype['export'] = function(format) {
format || (format = 'hex') var format = format || 'hex';
return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]() return this['to' + format.substr(0, 1).toUpperCase() + format.substr(1)]()
} }
@ -165,7 +165,7 @@ ECPubKey.prototype.toBin = function() {
} }
ECPubKey.prototype.toWif = function(version) { ECPubKey.prototype.toWif = function(version) {
var version = version || Network.mainnet.addressVersion; version = version || Network.mainnet.addressVersion;
return base58.checkEncode(this.toBytes(), version) return base58.checkEncode(this.toBytes(), version)
} }
@ -173,7 +173,7 @@ ECPubKey.prototype.toWif = function(version) {
ECPubKey.prototype.toString = ECPubKey.prototype.toHex ECPubKey.prototype.toString = ECPubKey.prototype.toHex
ECPubKey.prototype.getAddress = function(version) { ECPubKey.prototype.getAddress = function(version) {
var version = version || Network.mainnet.addressVersion; version = version || Network.mainnet.addressVersion;
return new Address(util.sha256ripe160(this.toBytes()), version); return new Address(util.sha256ripe160(this.toBytes()), version);
} }

2
src/opcode.js

@ -1,4 +1,4 @@
Opcode = { var Opcode = {
map: { map: {
// push value // push value
OP_0 : 0, OP_0 : 0,

13
src/transaction.js

@ -60,8 +60,9 @@ Transaction.prototype.addInput = function (tx, outIndex) {
return this.addInput(args[0], args[1]); return this.addInput(args[0], args[1]);
} }
else { else {
var hash = typeof tx === "string" ? tx : tx.hash var hash = typeof tx === "string" ? tx : tx.hash;
var hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash;
this.ins.push(new TransactionIn({ this.ins.push(new TransactionIn({
outpoint: { outpoint: {
hash: hash, hash: hash,
@ -269,7 +270,9 @@ Transaction.deserialize = function(buffer) {
} }
obj.version = readAsInt(4); obj.version = readAsInt(4);
var ins = readVarInt(); var ins = readVarInt();
for (var i = 0; i < ins; i++) { var i;
for (i = 0; i < ins; i++) {
obj.ins.push({ obj.ins.push({
outpoint: { outpoint: {
hash: convert.bytesToHex(readBytes(32).reverse()), hash: convert.bytesToHex(readBytes(32).reverse()),
@ -280,12 +283,14 @@ Transaction.deserialize = function(buffer) {
}); });
} }
var outs = readVarInt(); var outs = readVarInt();
for (var i = 0; i < outs; i++) {
for (i = 0; i < outs; i++) {
obj.outs.push({ obj.outs.push({
value: convert.bytesToNum(readBytes(8)), value: convert.bytesToNum(readBytes(8)),
script: new Script(readVarString()) script: new Script(readVarString())
}); });
} }
obj.locktime = readAsInt(4); obj.locktime = readAsInt(4);
return new Transaction(obj); return new Transaction(obj);

Loading…
Cancel
Save