wallet: account options.

This commit is contained in:
Christopher Jeffrey 2016-10-03 14:43:35 -07:00
parent b36491dd53
commit 56e4bace42
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -665,21 +665,21 @@ Wallet.prototype._createAccount = co(function* createAccount(options) {
throw new Error('Cannot add xprivkey to watch-only wallet.'); throw new Error('Cannot add xprivkey to watch-only wallet.');
} else { } else {
key = master.deriveAccount44(this.accountDepth); key = master.deriveAccount44(this.accountDepth);
key = key.hdPublicKey;
} }
options = { options = {
network: this.network,
wid: this.wid, wid: this.wid,
id: this.id, id: this.id,
name: this.accountDepth === 0 ? 'default' : name, name: this.accountDepth === 0 ? 'default' : name,
witness: options.witness, witness: options.witness,
accountKey: key.hdPublicKey, watchOnly: this.watchOnly,
accountKey: key,
accountIndex: this.accountDepth, accountIndex: this.accountDepth,
type: options.type, type: options.type,
keys: options.keys,
m: options.m, m: options.m,
n: options.n, n: options.n,
watchOnly: this.watchOnly keys: options.keys
}; };
this.start(); this.start();
@ -706,16 +706,16 @@ Wallet.prototype._createAccount = co(function* createAccount(options) {
*/ */
Wallet.prototype.ensureAccount = co(function* ensureAccount(options) { Wallet.prototype.ensureAccount = co(function* ensureAccount(options) {
var acct = options.account; var name = options.account;
var exists; var exists;
if (typeof options.name === 'string') if (typeof options.name === 'string')
acct = options.name; name = options.name;
exists = yield this.hasAccount(acct); exists = yield this.hasAccount(name);
if (exists) if (exists)
return yield this.getAccount(acct); return yield this.getAccount(name);
return this.createAccount(options); return this.createAccount(options);
}); });