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);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.addressbook = {};
|
|
||||||
|
|
||||||
$scope.verifyAddressbookSignature = function(key) {
|
$scope.verifyAddressbookSignature = function(key) {
|
||||||
if (key) {
|
$timeout(function() {
|
||||||
$timeout(function() {
|
var w = $rootScope.wallet;
|
||||||
var w = $rootScope.wallet;
|
var isValid = w.verfifyAddressbookSignature(key);
|
||||||
var signature = w.verfifyAddressbookSignature(key);
|
if (!isValid) {
|
||||||
$scope.addressbook[key] = signature;
|
notification.error('Wrong signature', 'Entry of Addressbooks was deleted');
|
||||||
if (!signature) {
|
}
|
||||||
notification.error('Wrong signature', 'Entry of Addressbooks was deleted');
|
}, 10);
|
||||||
}
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleAddressBookEntry = function(key) {
|
$scope.toggleAddressBookEntry = function(key) {
|
||||||
if (key) {
|
var w = $rootScope.wallet;
|
||||||
var w = $rootScope.wallet;
|
w.toggleAddressBookEntry(key);
|
||||||
w.toggleAddressBookEntry(key);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.copyAddress = function(address) {
|
$scope.copyAddress = function(address) {
|
||||||
|
|
|
||||||
|
|
@ -853,35 +853,27 @@ Wallet.prototype.setAddressBook = function(key, label) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.verfifyAddressbookSignature = function(key) {
|
Wallet.prototype.verfifyAddressbookSignature = function(key) {
|
||||||
if (key) {
|
if (!key) throw new Error('Key is required');
|
||||||
var signature = this.addressBook[key].signature;
|
var signature = this.addressBook[key].signature;
|
||||||
var payload = {
|
var payload = {
|
||||||
address: key,
|
address: key,
|
||||||
label: this.addressBook[key].label,
|
label: this.addressBook[key].label,
|
||||||
copayerId: this.addressBook[key].copayerId,
|
copayerId: this.addressBook[key].copayerId,
|
||||||
createdTs: this.addressBook[key].createdTs
|
createdTs: this.addressBook[key].createdTs
|
||||||
};
|
};
|
||||||
var isVerified = this.verifySignedObject(payload, signature);
|
var isVerified = this.verifySignedObject(payload, signature);
|
||||||
if (!isVerified) {
|
if (!isVerified) {
|
||||||
// remove wrong signed entry
|
// remove wrong signed entry
|
||||||
delete this.addressBook[key];
|
delete this.addressBook[key];
|
||||||
this.store();
|
this.store();
|
||||||
}
|
|
||||||
return isVerified;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('Key is required');
|
|
||||||
}
|
}
|
||||||
|
return isVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet.prototype.toggleAddressBookEntry = function(key) {
|
Wallet.prototype.toggleAddressBookEntry = function(key) {
|
||||||
if (key) {
|
if (!key) throw new Error('Key is required');
|
||||||
this.addressBook[key].hidden = !this.addressBook[key].hidden;
|
this.addressBook[key].hidden = !this.addressBook[key].hidden;
|
||||||
this.store();
|
this.store();
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('Key is required');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.isReady = function() {
|
Wallet.prototype.isReady = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue