more json improvements.
This commit is contained in:
parent
ac9dfca3d3
commit
003330e678
@ -736,6 +736,7 @@ BlockDB.prototype._getTXByAddress = function _getTXByAddress(address, callback)
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
tx.network = true;
|
||||
tx.height = record.height;
|
||||
|
||||
if (entry) {
|
||||
@ -810,6 +811,7 @@ BlockDB.prototype.getTX = function getTX(hash, callback) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
tx.network = true;
|
||||
tx.height = record.height;
|
||||
|
||||
if (entry) {
|
||||
@ -861,8 +863,10 @@ BlockDB.prototype.getBlock = function getBlock(hash, callback) {
|
||||
return callback(e);
|
||||
}
|
||||
block._fileOffset = record.offset;
|
||||
block.network = true;
|
||||
block.height = record.height;
|
||||
block.txs.forEach(function(tx) {
|
||||
tx.network = true;
|
||||
tx.height = block.height;
|
||||
});
|
||||
if (self.options.paranoid) {
|
||||
|
||||
@ -75,7 +75,7 @@ function TX(data, block) {
|
||||
}
|
||||
|
||||
TX.prototype.setBlock = function setBlock(block) {
|
||||
this.network = true;
|
||||
this.network = block.network;
|
||||
this.relayedBy = block.relayedBy;
|
||||
this.ts = block.ts;
|
||||
this.block = block.hash('hex');
|
||||
@ -1802,10 +1802,10 @@ TX.prototype.inspect = function inspect() {
|
||||
TX.prototype.toJSON = function toJSON(coins) {
|
||||
return {
|
||||
type: 'tx',
|
||||
ts: this.ts,
|
||||
ps: this.ps,
|
||||
block: this.block,
|
||||
height: this.height,
|
||||
ts: this.ts,
|
||||
ps: this.ps,
|
||||
network: this.network,
|
||||
relayedBy: this.relayedBy,
|
||||
changeIndex: this.changeIndex,
|
||||
@ -1824,19 +1824,15 @@ TX.fromJSON = function fromJSON(json) {
|
||||
raw = new Buffer(json.tx, 'hex');
|
||||
data = new bcoin.protocol.parser().parseTX(raw);
|
||||
|
||||
data.height = json.height;
|
||||
data.block = json.block;
|
||||
data.ts = json.ts;
|
||||
data.ps = json.ps;
|
||||
data.network = json.network;
|
||||
data.relayedBy = json.relayedBy;
|
||||
|
||||
data.changeIndex = json.changeIndex;
|
||||
|
||||
data._raw = raw;
|
||||
data._size = raw.length;
|
||||
|
||||
tx = new TX(data);
|
||||
tx.height = json.height;
|
||||
tx.ts = json.ts;
|
||||
tx.block = json.block || null;
|
||||
tx.ps = json.ps;
|
||||
|
||||
if (json.coins) {
|
||||
json.coins.forEach(function(output, i) {
|
||||
@ -1853,14 +1849,14 @@ TX.fromJSON = function fromJSON(json) {
|
||||
TX.prototype.toFullJSON = function toFullJSON() {
|
||||
return {
|
||||
type: 'tx',
|
||||
hash: utils.revHex(this.hash('hex')),
|
||||
height: this.height,
|
||||
block: this.block ? utils.revHex(this.block) : null,
|
||||
ts: this.ts,
|
||||
ps: this.ps,
|
||||
block: this.block ? utils.revHex(this.block) : null,
|
||||
height: this.height,
|
||||
network: this.network,
|
||||
relayedBy: this.relayedBy,
|
||||
changeIndex: this.changeIndex,
|
||||
hash: utils.revHex(this.hash('hex')),
|
||||
version: this.version,
|
||||
inputs: this.inputs.map(function(input) {
|
||||
return input.toFullJSON();
|
||||
@ -1874,10 +1870,10 @@ TX.prototype.toFullJSON = function toFullJSON() {
|
||||
|
||||
TX.fromFullJSON = function fromFullJSON(json) {
|
||||
return new TX({
|
||||
ts: json.ts,
|
||||
ps: json.ps,
|
||||
block: json.block ? utils.revHex(json.block) : null,
|
||||
height: json.height,
|
||||
ts: json.ts,
|
||||
ps: json.ps,
|
||||
network: json.network,
|
||||
relayedBy: json.relayedBy,
|
||||
changeIndex: json.changeIndex,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user