add #addWallet to profile

This commit is contained in:
Matias Alejo Garcia 2014-09-28 21:22:53 -03:00
commit 7abdc77611
4 changed files with 91 additions and 42 deletions

View file

@ -12,6 +12,7 @@ function Profile(info, password, storage) {
this.email = info.email;
this.extra = info.extra;
this.walletIds = {};
this.hash = Profile.hash(this.email, password);
this.storage = storage;
};
@ -44,6 +45,17 @@ Profile.open = function(storage, cb) {
});
};
Profile.prototype.addWallet = function(walletId, cb) {
if (this.walletIds[walletId])
return cb(new Error('WEXIST: Wallet already on profile'));
this.walletIds[walletId] = Date.now();
this.store({
overwrite: true
}, cb);
};
Profile.prototype.store = function(opts, cb) {
var self = this;
var val = self.toObj();