diff --git a/lib/wallet/account.js b/lib/wallet/account.js index 44facf08..b3ce19e4 100644 --- a/lib/wallet/account.js +++ b/lib/wallet/account.js @@ -179,12 +179,12 @@ Account.prototype.fromOptions = function fromOptions(options) { if (this.n > 1) this.type = Account.types.MULTISIG; - if (this.m < 1 || this.m > this.n) - throw new Error('m ranges between 1 and n'); - if (!this.name) this.name = this.accountIndex + ''; + if (this.m < 1 || this.m > this.n) + throw new Error('m ranges between 1 and n'); + if (options.keys) { assert(Array.isArray(options.keys)); for (i = 0; i < options.keys.length; i++) diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 5b9d6962..cb32ca19 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -95,10 +95,10 @@ Wallet.prototype.fromOptions = function fromOptions(options) { var master = options.master; var id, token; - if (!master) - master = HD.fromMnemonic(null, this.network); - if (!MasterKey.isMasterKey(master)) { + if (!master) + master = HD.fromMnemonic(null, this.network); + if (!HD.isHD(master)) master = HD.from(master, this.network); @@ -132,9 +132,6 @@ Wallet.prototype.fromOptions = function fromOptions(options) { this.accountDepth = options.accountDepth; } - if (!id) - id = this.getID(); - if (options.token) { assert(Buffer.isBuffer(options.token)); assert(options.token.length === 32); @@ -146,6 +143,9 @@ Wallet.prototype.fromOptions = function fromOptions(options) { this.tokenDepth = options.tokenDepth; } + if (!id) + id = this.getID(); + if (!token) token = this.getToken(this.master.key, this.tokenDepth);