more address stuff.

This commit is contained in:
Christopher Jeffrey 2016-06-29 04:59:35 -07:00
parent 5c5ff9e265
commit 718ae3c1aa
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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';