Fixes typos and re-factory throw errors
This commit is contained in:
parent
7cdf559fd7
commit
ac2eda3670
2 changed files with 26 additions and 41 deletions
|
|
@ -186,26 +186,19 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
}, 500);
|
||||
};
|
||||
|
||||
$scope.addressbook = {};
|
||||
|
||||
$scope.verifyAddressbookSignature = function(key) {
|
||||
if (key) {
|
||||
$timeout(function() {
|
||||
var w = $rootScope.wallet;
|
||||
var signature = w.verfifyAddressbookSignature(key);
|
||||
$scope.addressbook[key] = signature;
|
||||
if (!signature) {
|
||||
notification.error('Wrong signature', 'Entry of Addressbooks was deleted');
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
$timeout(function() {
|
||||
var w = $rootScope.wallet;
|
||||
var isValid = w.verfifyAddressbookSignature(key);
|
||||
if (!isValid) {
|
||||
notification.error('Wrong signature', 'Entry of Addressbooks was deleted');
|
||||
}
|
||||
}, 10);
|
||||
};
|
||||
|
||||
$scope.toggleAddressBookEntry = function(key) {
|
||||
if (key) {
|
||||
var w = $rootScope.wallet;
|
||||
w.toggleAddressBookEntry(key);
|
||||
}
|
||||
var w = $rootScope.wallet;
|
||||
w.toggleAddressBookEntry(key);
|
||||
};
|
||||
|
||||
$scope.copyAddress = function(address) {
|
||||
|
|
|
|||
|
|
@ -853,35 +853,27 @@ Wallet.prototype.setAddressBook = function(key, label) {
|
|||
};
|
||||
|
||||
Wallet.prototype.verfifyAddressbookSignature = function(key) {
|
||||
if (key) {
|
||||
var signature = this.addressBook[key].signature;
|
||||
var payload = {
|
||||
address: key,
|
||||
label: this.addressBook[key].label,
|
||||
copayerId: this.addressBook[key].copayerId,
|
||||
createdTs: this.addressBook[key].createdTs
|
||||
};
|
||||
var isVerified = this.verifySignedObject(payload, signature);
|
||||
if (!isVerified) {
|
||||
// remove wrong signed entry
|
||||
delete this.addressBook[key];
|
||||
this.store();
|
||||
}
|
||||
return isVerified;
|
||||
}
|
||||
else {
|
||||
throw new Error('Key is required');
|
||||
if (!key) throw new Error('Key is required');
|
||||
var signature = this.addressBook[key].signature;
|
||||
var payload = {
|
||||
address: key,
|
||||
label: this.addressBook[key].label,
|
||||
copayerId: this.addressBook[key].copayerId,
|
||||
createdTs: this.addressBook[key].createdTs
|
||||
};
|
||||
var isVerified = this.verifySignedObject(payload, signature);
|
||||
if (!isVerified) {
|
||||
// remove wrong signed entry
|
||||
delete this.addressBook[key];
|
||||
this.store();
|
||||
}
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
Wallet.prototype.toggleAddressBookEntry = function(key) {
|
||||
if (key) {
|
||||
this.addressBook[key].hidden = !this.addressBook[key].hidden;
|
||||
this.store();
|
||||
}
|
||||
else {
|
||||
throw new Error('Key is required');
|
||||
}
|
||||
if (!key) throw new Error('Key is required');
|
||||
this.addressBook[key].hidden = !this.addressBook[key].hidden;
|
||||
this.store();
|
||||
};
|
||||
|
||||
Wallet.prototype.isReady = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue