added checksum methods to profile
This commit is contained in:
parent
1c6cc3eb20
commit
1021cbc4fa
1 changed files with 20 additions and 0 deletions
|
|
@ -76,6 +76,10 @@ Identity.getKeyForEmail = function(email) {
|
||||||
return Identity.getStoragePrefix() + bitcore.util.sha256ripe160(email).toString('hex');
|
return Identity.getStoragePrefix() + bitcore.util.sha256ripe160(email).toString('hex');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Identity.prototype.getChecksumForStorage = function() {
|
||||||
|
return JSON.stringify(this.walletIds);
|
||||||
|
};
|
||||||
|
|
||||||
Identity.prototype.getId = function() {
|
Identity.prototype.getId = function() {
|
||||||
return Identity.getKeyForEmail(this.email);
|
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
|
* @param {string} walletId
|
||||||
* @returns {Wallet}
|
* @returns {Wallet}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue