From b473c0a31f5dfc10efbf0aeb4b845fbe5a69e7e9 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 18 Jun 2016 22:32:14 -0700 Subject: [PATCH] coin json --- lib/bcoin/coin.js | 21 ++++++++++++--------- lib/bcoin/input.js | 4 +--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/bcoin/coin.js b/lib/bcoin/coin.js index 30aa98cf..1c9bf938 100644 --- a/lib/bcoin/coin.js +++ b/lib/bcoin/coin.js @@ -164,15 +164,18 @@ Coin.prototype.toJSON = function toJSON() { */ Coin.fromJSON = function fromJSON(json) { - return Coin.fromOptions({ - version: json.version, - height: json.height, - value: utils.satoshi(json.value), - script: bcoin.script.fromRaw(new Buffer(json.script, 'hex')), - coinbase: json.coinbase, - hash: json.hash ? utils.revHex(json.hash) : null, - index: json.index - }); + return new Coin().fromJSON(json); +}; + +Coin.prototype.fromJSON = function fromJSON(json) { + this.version = json.version; + this.height = json.height; + this.value = utils.satoshi(json.value); + this.script = bcoin.script.fromRaw(new Buffer(json.script, 'hex')); + this.coinbase = json.coinbase; + this.hash = json.hash ? utils.revHex(json.hash) : null; + this.index = json.index; + return this; }; /** diff --git a/lib/bcoin/input.js b/lib/bcoin/input.js index 1953186a..3fcb2405 100644 --- a/lib/bcoin/input.js +++ b/lib/bcoin/input.js @@ -108,9 +108,7 @@ Outpoint.prototype.inspect = function inspect() { * @constructor * @param {NakedInput} options * @param {Boolean?} mutable - * @property {Object} prevout - Outpoint. - * @property {Hash} prevout.hash - Previous transaction hash. - * @property {Number} prevout.index - Previous output index. + * @property {Outpoint} prevout - Outpoint. * @property {Script} script - Input script / scriptSig. * @property {Number} sequence - nSequence. * @property {Witness} witness - Witness (empty if not present).