mirror of https://github.com/BTCPrivate/copay.git
added checksum methods to profile
This commit is contained in:
parent
1c6cc3eb20
commit
1021cbc4fa
|
@ -76,6 +76,10 @@ Identity.getKeyForEmail = function(email) {
|
|||
return Identity.getStoragePrefix() + bitcore.util.sha256ripe160(email).toString('hex');
|
||||
};
|
||||
|
||||
Identity.prototype.getChecksumForStorage = function() {
|
||||
return JSON.stringify(this.walletIds);
|
||||
};
|
||||
|
||||
Identity.prototype.getId = function() {
|
||||
return Identity.getKeyForEmail(this.email);
|
||||
};
|
||||
|
@ -148,6 +152,22 @@ Identity.open = function(opts, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
Identity.prototype.verifyChecksum = function (cb) {
|
||||
var self = this;
|
||||
|
||||
self.storage.getItem(Identity.getKeyForEmail(self.email), function(err, data, headers) {
|
||||
var iden;
|
||||
if (err) return cb(err);
|
||||
try {
|
||||
iden = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return cb(e);
|
||||
}
|
||||
|
||||
return cb(null, self.getChecksumForStorage() == self.getChecksumForStorage.call(iden));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} walletId
|
||||
* @returns {Wallet}
|
||||
|
|
Loading…
Reference in New Issue