diff --git a/public/views/import.html b/public/views/import.html index 4a75fc928..109dcd1cb 100644 --- a/public/views/import.html +++ b/public/views/import.html @@ -33,19 +33,29 @@
-
-
-
-
-
Could not access the wallet at the server. Please check:
-
The password of the recovery phrase (if set)
-
The derivation path
-
The wallet service URL
-
NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the seed there.
-
Error: {{import.error|translate}}
+
+
+
Could not access the wallet at the server. Please check:
+
    +
  • The password of the recovery phrase (if set) +
  • +
  • The derivation path +
  • +
  • The wallet service URL +
+
+ NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the seed there.
+
+
+ +
+
+ {{import.error|translate}}
+
+
diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 0309346ae..968ee8998 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo) { + function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo, bwsError, bwcService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -9,6 +9,7 @@ angular.module('copayApp.controllers').controller('importController', var self = this; var reader = new FileReader(); var defaults = configService.getDefaults(); + var errors = bwcService.getErrors(); $scope.bwsurl = defaults.bws.url; $scope.derivationPath = derivationPathHelper.default; $scope.account = 1; @@ -93,14 +94,17 @@ angular.module('copayApp.controllers').controller('importController', profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) { self.loading = false; if (err) { - self.error = err; - self.importErr = true; - + if (err instanceof errors.NOT_AUTHORIZED) { + self.importErr = true; + } else { + self.error = err; + } $ionicScrollDelegate.scrollTop(); return $timeout(function() { $scope.$apply(); }); } + $rootScope.$emit('Local/WalletImported', walletId); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); go.walletHome(); @@ -114,15 +118,22 @@ angular.module('copayApp.controllers').controller('importController', $timeout(function() { profileService.importMnemonic(words, opts, function(err, walletId) { self.loading = false; - if (err) { - self.error = err; - self.importErr = true; + if (err) { +console.log('[import.js.122:err:]',err); //TODO + if (err instanceof errors.NOT_AUTHORIZED) { + +console.log('[import.js.125]'); //TODO + self.importErr = true; + } else { + self.error = err; + } $ionicScrollDelegate.scrollTop(); return $timeout(function() { $scope.$apply(); }); } + $rootScope.$emit('Local/WalletImported', walletId); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); go.walletHome(); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index f90c36af9..2a6f49fc8 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -543,8 +543,12 @@ angular.module('copayApp.services') $log.debug('Importing Wallet xPrivKey'); walletClient.importFromExtendedPrivateKey(xPrivKey, opts, function(err) { - if (err) + if (err) { + if (err instanceof errors.NOT_AUTHORIZED) + return cb(err); + return bwsError.cb(err, gettext('Could not import'), cb); + } root.addAndBindWalletClient(walletClient, { bwsurl: opts.bwsurl, @@ -571,8 +575,12 @@ angular.module('copayApp.services') passphrase: opts.passphrase, account: opts.account || 0, }, function(err) { - if (err) + if (err) { + if (err instanceof errors.NOT_AUTHORIZED) + return cb(err); + return bwsError.cb(err, gettext('Could not import'), cb); + } root.addAndBindWalletClient(walletClient, { bwsurl: opts.bwsurl,