diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index 6cfcba50..41635262 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -711,7 +711,7 @@ Block.prototype.fromRaw = function fromRaw(data) { for (i = 0; i < this.totalTX; i++) { tx = bcoin.tx.fromRaw(p); this._witnessSize += tx._witnessSize; - this.txs.push(tx); + this.addTX(tx); } this._raw = p.endData(); diff --git a/lib/bcoin/chaindb.js b/lib/bcoin/chaindb.js index a80163ca..a2107c1e 100644 --- a/lib/bcoin/chaindb.js +++ b/lib/bcoin/chaindb.js @@ -1192,8 +1192,6 @@ ChainDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, call if (!Array.isArray(addresses)) addresses = [addresses]; - addresses = utils.uniq(addresses); - utils.forEachSerial(addresses, function(address, next) { address = bcoin.address.getHash(address); @@ -1242,8 +1240,6 @@ ChainDB.prototype.getTXByAddress = function getTXByAddress(addresses, callback) if (!Array.isArray(addresses)) addresses = [addresses]; - addresses = utils.uniq(addresses); - utils.forEachSerial(addresses, function(address, next) { address = bcoin.address.getHash(address); diff --git a/lib/bcoin/input.js b/lib/bcoin/input.js index 9732855d..3cc9fcf9 100644 --- a/lib/bcoin/input.js +++ b/lib/bcoin/input.js @@ -471,13 +471,10 @@ Input.prototype.toExtended = function toExtended(writer) { */ Input.prototype.fromExtended = function fromExtended(data) { - var input, p; - - p = bcoin.reader(data); + var p = bcoin.reader(data); this.fromRaw(p); this.witness = bcoin.witness.fromRaw(p); - - return input; + return this; }; /** diff --git a/lib/bcoin/mempool.js b/lib/bcoin/mempool.js index be55b251..90433a48 100644 --- a/lib/bcoin/mempool.js +++ b/lib/bcoin/mempool.js @@ -471,8 +471,6 @@ Mempool.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, call if (!Array.isArray(addresses)) addresses = [addresses]; - addresses = utils.uniq(addresses); - utils.forEachSerial(addresses, function(address, next) { address = bcoin.address.getHash(address, 'hex'); @@ -515,8 +513,6 @@ Mempool.prototype.getTXByAddress = function getTXByAddress(addresses, callback) if (!Array.isArray(addresses)) addresses = [addresses]; - addresses = utils.uniq(addresses); - utils.forEachSerial(addresses, function(address, next) { address = bcoin.address.getHash(address, 'hex'); diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 123fda52..9ca15cf2 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -1880,6 +1880,8 @@ TX.prototype.toJSON = function toJSON() { */ TX.prototype.fromJSON = function fromJSON(json) { + var i, input, output; + assert.equal(json.type, 'tx'); this.block = json.block ? utils.revHex(json.block) : null; @@ -1887,19 +1889,21 @@ TX.prototype.fromJSON = function fromJSON(json) { this.ts = json.ts; this.ps = json.ps; this.index = json.index; - this.changeIndex = json.changeIndex || -1; + this.changeIndex = json.changeIndex != null ? json.changeIndex : -1; this.version = json.version; this.flag = json.flag; - this.inputs = json.inputs.map(function(input) { - return bcoin.input.fromJSON(input); - }), + for (i = 0; i < json.inputs.length; i++) { + input = json.inputs[i]; + this.inputs.push(bcoin.input.fromJSON(input)); + } - this.outputs = json.outputs.map(function(output) { - return bcoin.output.fromJSON(output); - }), + for (i = 0; i < json.outputs.length; i++) { + output = json.outputs[i]; + this.outputs.push(bcoin.output.fromJSON(output)); + } this.locktime = json.locktime; @@ -2092,7 +2096,7 @@ TX.prototype.frameWitness = function frameWitness(writer) { p.write32(this.version); p.writeU8(0); - p.writeU8(this.flag || 1); + p.writeU8(this.flag); p.writeVarint(this.inputs.length);