Merge pull request #4558 from gabrielbazan7/fix/EncryptedWalletHandler

fix wallet encrypted handler and rename BwsError service to BwcError
This commit is contained in:
Gustavo Maximiliano Cortez 2016-07-12 10:18:29 -03:00 committed by GitHub
commit eb014927a4
14 changed files with 81 additions and 81 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('backupController',
function($rootScope, $scope, $timeout, $log, go, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, bwsError, walletService, ongoingProcess) {
function($rootScope, $scope, $timeout, $log, go, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) {
var fc = profileService.focusedClient;
var prevState;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('buyCoinbaseController',
function($scope, $log, $ionicModal, $timeout, lodash, profileService, coinbaseService, bwsError, addressService, ongoingProcess) {
function($scope, $log, $ionicModal, $timeout, lodash, profileService, coinbaseService, addressService, ongoingProcess) {
var self = this;
this.init = function(testnet) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $ionicModal, profileService, addressService, glideraService, bwsError, lodash, ongoingProcess) {
function($scope, $timeout, $ionicModal, profileService, addressService, glideraService, bwcError, lodash, ongoingProcess) {
var self = this;
this.show2faCodeInput = null;
@ -90,7 +90,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
addressService.getAddress(self.selectedWalletId, false, function(err, walletAddr) {
if (err) {
ongoingProcess.set('Buying Bitcoin...', false);
self.error = bwsError.cb(err, 'Could not create address');
self.error = bwcError.cb(err, 'Could not create address');
return;
}
var data = {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, $ionicScrollDelegate, $ionicPopup, $ionicSideMenuDelegate, latestReleaseService, feeService, bwcService, pushNotificationsService, lodash, go, profileService, configService, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, addonManager, bwsError, txFormatService, uxLanguage, glideraService, coinbaseService, platformInfo, addressbookService, openURLService, ongoingProcess) {
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, $ionicScrollDelegate, $ionicPopup, $ionicSideMenuDelegate, latestReleaseService, feeService, bwcService, pushNotificationsService, lodash, go, profileService, configService, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, addonManager, bwcError, txFormatService, uxLanguage, glideraService, coinbaseService, platformInfo, addressbookService, openURLService, ongoingProcess) {
var self = this;
var SOFT_CONFIRMATION_LIMIT = 12;
var errors = bwcService.getErrors();
@ -295,7 +295,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
twoStep: true
}, function(err, ret) {
if (err) {
self.updateError = bwsError.msg(err, gettext('Could not update Wallet'));
self.updateError = bwcError.msg(err, gettext('Could not update Wallet'));
} else {
self.isSingleAddress = !!ret.wallet.singleAddress;
if (!opts.quiet)
@ -428,7 +428,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} else {
var msg = ""
$scope.$emit('Local/ClientError', (err.error ? err.error : err));
var msg = bwsError.msg(err, gettext('Error at Wallet Service'));
var msg = bwcError.msg(err, gettext('Error at Wallet Service'));
self.showErrorPopup(msg);
}
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookController', function($rootScope, $scope, $timeout, lodash, profileService, addressService, addressbookService, bwsError) {
angular.module('copayApp.controllers').controller('addressbookController', function($rootScope, $scope, $timeout, lodash, profileService, addressService, addressbookService, bwcError) {
var self = $scope.self;
var fc = profileService.focusedClient;
@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('addressbookController', funct
$scope.errorSelectedWallet = {};
profileService.isReady(client, function(err) {
if (err) $scope.errorSelectedWallet[walletId] = bwsError.msg(err);
if (err) $scope.errorSelectedWallet[walletId] = bwcError.msg(err);
else {
$scope.gettingAddress = true;
$scope.selectedWalletName = walletName;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwsError, gettextCatalog, lodash, profileService, walletService) {
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, profileService, walletService) {
var self = $scope.self;
var tx = $scope.tx;
var copayers = $scope.copayers;
@ -29,14 +29,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
fingerprintService.check(fc, function(err) {
if (err) {
$scope.error = err;
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
handleEncryptedWallet(function(err) {
if (err) {
$scope.error = err;
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
@ -44,7 +44,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
walletService.signTx(fc, txp, function(err, signedTxp) {
walletService.lock(fc);
if (err) {
$scope.error = err;
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
@ -79,7 +79,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
if (err) {
$scope.$emit('UpdateTx');
$scope.error = bwsError.msg(err, gettextCatalog.getString('Could not reject payment'));
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not reject payment'));
$scope.$digest();
} else {
$scope.close(txpr);
@ -99,7 +99,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
// Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) {
$scope.$emit('UpdateTx');
$scope.error = bwsError.msg(err, gettextCatalog.getString('Could not delete payment proposal'));
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not delete payment proposal'));
$scope.$digest();
return;
}
@ -117,7 +117,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.loading = null;
if (err) {
$scope.error = bwsError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
$scope.$digest();
return;
}
@ -211,7 +211,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
if (!walletService.isEncrypted(fc)) return cb();
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
if (err) return cb(err);
return cb(null, walletService.unlock(fc, password));
return cb(walletService.unlock(fc, password));
});
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletsController', function($scope, bwsError, profileService) {
angular.module('copayApp.controllers').controller('walletsController', function($scope, bwcError, profileService) {
$scope.selectWallet = function(walletId) {
@ -8,8 +8,8 @@ angular.module('copayApp.controllers').controller('walletsController', function(
$scope.errorSelectedWallet = {};
profileService.isReady(client, function(err) {
if (err) {
$scope.errorSelectedWallet[walletId] = bwsError.msg(err);
if (err) {
$scope.errorSelectedWallet[walletId] = bwcError.msg(err);
return;
}

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('sellCoinbaseController',
function($rootScope, $scope, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, bwsError, configService, walletService, fingerprintService, ongoingProcess, go) {
function($rootScope, $scope, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, configService, walletService, fingerprintService, ongoingProcess, go) {
var self = this;
var client;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController',
function($rootScope, $scope, $timeout, $ionicModal, $log, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, walletService, fingerprintService, ongoingProcess, go) {
function($rootScope, $scope, $timeout, $ionicModal, $log, configService, profileService, addressService, feeService, glideraService, bwcError, lodash, walletService, fingerprintService, ongoingProcess, go) {
var self = this;
var config = configService.getSync();
@ -111,7 +111,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
if (!refundAddress) {
ongoingProcess.clear();
self.error = bwsError.msg(err, 'Could not create address');
self.error = bwcError.msg(err, 'Could not create address');
return;
}
glideraService.getSellAddress(token, function(error, sellAddress) {
@ -145,20 +145,20 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
walletService.createTx(client, txp, function(err, createdTxp) {
ongoingProcess.clear();
if (err) {
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
return;
}
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) {
fingerprintService.check(client, function(err) {
if (err) {
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
return;
}
handleEncryptedWallet(client, function(err) {
if (err) {
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
return;
}
@ -166,7 +166,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
walletService.publishTx(client, createdTxp, function(err, publishedTxp) {
if (err) {
ongoingProcess.clear();
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
}
walletService.signTx(client, publishedTxp, function(err, signedTxp) {
@ -176,7 +176,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
});
ongoingProcess.clear();
if (err) {
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
return;
}
var rawTx = signedTxp.raw;
@ -191,7 +191,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
glideraService.sell(token, twoFaCode, data, function(err, data) {
ongoingProcess.clear();
if (err) {
self.error = err.message ||  bwsError.msg(err);
self.error = err.message ||  bwcError.msg(err);
$timeout(function() {
$scope.$emit('Local/GlideraError');
}, 100);

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, notification, txStatus, profileService, lodash, configService, rateService, storageService, bitcore, gettext, gettextCatalog, platformInfo, addressService, ledger, bwsError, confirmDialog, txFormatService, addressbookService, go, feeService, walletService, fingerprintService, nodeWebkit, ongoingProcess) {
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, notification, txStatus, profileService, lodash, configService, rateService, storageService, bitcore, gettext, gettextCatalog, platformInfo, addressService, ledger, bwcError, confirmDialog, txFormatService, addressbookService, go, feeService, walletService, fingerprintService, nodeWebkit, ongoingProcess) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -365,7 +365,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var prefix =
fc.credentials.m > 1 ? gettextCatalog.getString('Could not create payment proposal') : gettextCatalog.getString('Could not send payment');
this.error = bwsError.msg(err, prefix);
this.error = bwcError.msg(err, prefix);
$timeout(function() {
$scope.$digest();

View file

@ -1,7 +1,7 @@
'use strict';
'use strict';
angular.module('copayApp.services')
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwsError, gettextCatalog) {
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwcError, gettextCatalog) {
var root = {};
root.expireAddress = function(walletId, cb) {
@ -44,7 +44,7 @@ angular.module('copayApp.services')
return cb(null, addr[0].address);
});
}
return bwsError.cb(err, prefix, cb);
return bwcError.cb(err, prefix, cb);
}
return cb(null, addr.address);
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('bwsError', function bwcErrorService($log, gettextCatalog) {
.factory('bwcError', function bwcErrorService($log, gettextCatalog) {
var root = {};
root.msg = function(err, prefix) {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwsError, uxLanguage, bitcore, platformInfo, walletService) {
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, walletService) {
var isChromeApp = platformInfo.isChromeApp;
@ -357,7 +357,7 @@ angular.module('copayApp.services')
singleAddress: opts.singleAddress,
walletPrivKey: opts.walletPrivKey,
}, function(err, secret) {
if (err) return bwsError.cb(err, gettext('Error creating wallet'), cb);
if (err) return bwcError.cb(err, gettext('Error creating wallet'), cb);
return cb(null, walletClient, secret);
});
});
@ -405,8 +405,8 @@ angular.module('copayApp.services')
// check if exist
if (lodash.find(root.profile.credentials, {
'walletId': walletData.walletId
})) {
'walletId': walletData.walletId
})) {
return cb(gettext('Cannot join the same wallet more that once'));
}
} catch (ex) {
@ -420,7 +420,7 @@ angular.module('copayApp.services')
if (err) return cb(err);
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
if (err) return bwsError.cb(err, gettext('Could not join wallet'), cb);
if (err) return bwcError.cb(err, gettext('Could not join wallet'), cb);
root.addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl
}, cb);
@ -583,7 +583,7 @@ angular.module('copayApp.services')
if (err instanceof errors.NOT_AUTHORIZED)
return cb(err);
return bwsError.cb(err, gettext('Could not import'), cb);
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
@ -614,7 +614,7 @@ angular.module('copayApp.services')
if (err instanceof errors.NOT_AUTHORIZED)
return cb(err);
return bwsError.cb(err, gettext('Could not import'), cb);
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
@ -637,7 +637,7 @@ angular.module('copayApp.services')
if (err instanceof errors.NOT_AUTHORIZED)
err.name = 'WALLET_DOES_NOT_EXIST';
return bwsError.cb(err, gettext('Could not import'), cb);
return bwcError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {