From 718ae3c1aa465276a99329a874505a2685145069 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 29 Jun 2016 04:59:35 -0700 Subject: [PATCH] more address stuff. --- lib/bcoin/address.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/bcoin/address.js b/lib/bcoin/address.js index b40d4ac9..9ece5f43 100644 --- a/lib/bcoin/address.js +++ b/lib/bcoin/address.js @@ -52,23 +52,12 @@ function Address(options) { */ Address.prototype.fromOptions = function fromOptions(options) { - assert(options.hash); - - this.hash = options.hash; - - if (options.type) - this.type = options.type; - - if (options.version != null) - this.version = options.version; - - if (options.network) - this.network = bcoin.network.get(options.network).type; - - if (typeof this.hash === 'string') - this.hash = new Buffer(this.hash, 'hex'); - - return this; + return this.fromHash( + options.hash, + options.type, + options.version, + options.network + ); }; /** @@ -380,6 +369,8 @@ Address.prototype.fromHash = function fromHash(hash, type, version, network) { if (typeof hash === 'string') hash = new Buffer(hash, 'hex'); + assert(Buffer.isBuffer(hash)); + if (!type) type = 'pubkeyhash';