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.');
} else {
key = master.deriveAccount44(this.accountDepth);
key = key.hdPublicKey;
}
options = {
network: this.network,
wid: this.wid,
id: this.id,
name: this.accountDepth === 0 ? 'default' : name,
witness: options.witness,
accountKey: key.hdPublicKey,
watchOnly: this.watchOnly,
accountKey: key,
accountIndex: this.accountDepth,
type: options.type,
keys: options.keys,
m: options.m,
n: options.n,
watchOnly: this.watchOnly
keys: options.keys
};
this.start();
@ -706,16 +706,16 @@ Wallet.prototype._createAccount = co(function* createAccount(options) {
*/
Wallet.prototype.ensureAccount = co(function* ensureAccount(options) {
var acct = options.account;
var name = options.account;
var exists;
if (typeof options.name === 'string')
acct = options.name;
name = options.name;
exists = yield this.hasAccount(acct);
exists = yield this.hasAccount(name);
if (exists)
return yield this.getAccount(acct);
return yield this.getAccount(name);
return this.createAccount(options);
});