wallet: options parsing.
This commit is contained in:
parent
baeb786bb8
commit
b45c20b157
@ -179,12 +179,12 @@ Account.prototype.fromOptions = function fromOptions(options) {
|
|||||||
if (this.n > 1)
|
if (this.n > 1)
|
||||||
this.type = Account.types.MULTISIG;
|
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)
|
if (!this.name)
|
||||||
this.name = this.accountIndex + '';
|
this.name = this.accountIndex + '';
|
||||||
|
|
||||||
|
if (this.m < 1 || this.m > this.n)
|
||||||
|
throw new Error('m ranges between 1 and n');
|
||||||
|
|
||||||
if (options.keys) {
|
if (options.keys) {
|
||||||
assert(Array.isArray(options.keys));
|
assert(Array.isArray(options.keys));
|
||||||
for (i = 0; i < options.keys.length; i++)
|
for (i = 0; i < options.keys.length; i++)
|
||||||
|
|||||||
@ -95,10 +95,10 @@ Wallet.prototype.fromOptions = function fromOptions(options) {
|
|||||||
var master = options.master;
|
var master = options.master;
|
||||||
var id, token;
|
var id, token;
|
||||||
|
|
||||||
if (!master)
|
|
||||||
master = HD.fromMnemonic(null, this.network);
|
|
||||||
|
|
||||||
if (!MasterKey.isMasterKey(master)) {
|
if (!MasterKey.isMasterKey(master)) {
|
||||||
|
if (!master)
|
||||||
|
master = HD.fromMnemonic(null, this.network);
|
||||||
|
|
||||||
if (!HD.isHD(master))
|
if (!HD.isHD(master))
|
||||||
master = HD.from(master, this.network);
|
master = HD.from(master, this.network);
|
||||||
|
|
||||||
@ -132,9 +132,6 @@ Wallet.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.accountDepth = options.accountDepth;
|
this.accountDepth = options.accountDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!id)
|
|
||||||
id = this.getID();
|
|
||||||
|
|
||||||
if (options.token) {
|
if (options.token) {
|
||||||
assert(Buffer.isBuffer(options.token));
|
assert(Buffer.isBuffer(options.token));
|
||||||
assert(options.token.length === 32);
|
assert(options.token.length === 32);
|
||||||
@ -146,6 +143,9 @@ Wallet.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.tokenDepth = options.tokenDepth;
|
this.tokenDepth = options.tokenDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!id)
|
||||||
|
id = this.getID();
|
||||||
|
|
||||||
if (!token)
|
if (!token)
|
||||||
token = this.getToken(this.master.key, this.tokenDepth);
|
token = this.getToken(this.master.key, this.tokenDepth);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user