|
|
@ -70,7 +70,7 @@ Block._fromJSON = function _fromJSON(data) { |
|
|
|
magicnum: data.magicnum, |
|
|
|
blocksize: data.blocksize, |
|
|
|
blockheader: BlockHeader.fromJSON(data.blockheader), |
|
|
|
txsvi: Varint().fromJSON(data.txsvi), |
|
|
|
txsvi: Varint().fromString(data.txsvi), |
|
|
|
txs: txs |
|
|
|
}; |
|
|
|
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 = []; |
|
|
|
this.txs.forEach(function(tx) { |
|
|
|
txs.push(tx.toJSON()); |
|
|
@ -154,12 +154,19 @@ Block.prototype.toJSON = function toJSON() { |
|
|
|
return { |
|
|
|
magicnum: this.magicnum, |
|
|
|
blocksize: this.blocksize, |
|
|
|
blockheader: this.blockheader.toJSON(), |
|
|
|
txsvi: this.txsvi.toJSON(), |
|
|
|
blockheader: this.blockheader.toObject(), |
|
|
|
txsvi: this.txsvi.toString(), |
|
|
|
txs: txs |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @returns {String} - A JSON string |
|
|
|
*/ |
|
|
|
Block.prototype.toJSON = function toJSON() { |
|
|
|
return JSON.stringify(this.toObject()); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @returns {Buffer} - A buffer of the block |
|
|
|
*/ |
|
|
|