This commit is contained in:
Christopher Jeffrey 2016-06-17 20:10:35 -07:00
parent d5529996ef
commit 48b3b0b506
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 15 additions and 22 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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;
};
/**

View File

@ -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');

View File

@ -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);