|
@ -70,7 +70,7 @@ Block._fromJSON = function _fromJSON(data) { |
|
|
magicnum: data.magicnum, |
|
|
magicnum: data.magicnum, |
|
|
blocksize: data.blocksize, |
|
|
blocksize: data.blocksize, |
|
|
blockheader: BlockHeader.fromJSON(data.blockheader), |
|
|
blockheader: BlockHeader.fromJSON(data.blockheader), |
|
|
txsvi: Varint().fromJSON(data.txsvi), |
|
|
txsvi: Varint().fromString(data.txsvi), |
|
|
txs: txs |
|
|
txs: txs |
|
|
}; |
|
|
}; |
|
|
return info; |
|
|
return info; |
|
@ -144,9 +144,9 @@ Block.fromRawBlock = function fromRawBlock(data) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @returns {Object} - A JSON object with the block properties |
|
|
* @returns {Object} - A plain object with the block properties |
|
|
*/ |
|
|
*/ |
|
|
Block.prototype.toJSON = function toJSON() { |
|
|
Block.prototype.toObject = function toObject() { |
|
|
var txs = []; |
|
|
var txs = []; |
|
|
this.txs.forEach(function(tx) { |
|
|
this.txs.forEach(function(tx) { |
|
|
txs.push(tx.toJSON()); |
|
|
txs.push(tx.toJSON()); |
|
@ -154,12 +154,19 @@ Block.prototype.toJSON = function toJSON() { |
|
|
return { |
|
|
return { |
|
|
magicnum: this.magicnum, |
|
|
magicnum: this.magicnum, |
|
|
blocksize: this.blocksize, |
|
|
blocksize: this.blocksize, |
|
|
blockheader: this.blockheader.toJSON(), |
|
|
blockheader: this.blockheader.toObject(), |
|
|
txsvi: this.txsvi.toJSON(), |
|
|
txsvi: this.txsvi.toString(), |
|
|
txs: txs |
|
|
txs: txs |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @returns {String} - A JSON string |
|
|
|
|
|
*/ |
|
|
|
|
|
Block.prototype.toJSON = function toJSON() { |
|
|
|
|
|
return JSON.stringify(this.toObject()); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @returns {Buffer} - A buffer of the block |
|
|
* @returns {Buffer} - A buffer of the block |
|
|
*/ |
|
|
*/ |
|
|