commit
7c85752822
8 changed files with 99 additions and 65 deletions
4
angular-bitcore-wallet-client/index.js
vendored
4
angular-bitcore-wallet-client/index.js
vendored
|
|
@ -35,6 +35,10 @@ bwcModule.provider("bwcService", function() {
|
|||
return Client.Bitcore;
|
||||
};
|
||||
|
||||
service.getErrors = function() {
|
||||
return Client.errors;
|
||||
};
|
||||
|
||||
service.getSJCL = function() {
|
||||
return Client.sjcl;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
"url": "https://github.com/bitpay/copay/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bitcore-wallet-client": "1.3.0",
|
||||
"bitcore-wallet-client": "1.5.0",
|
||||
"express": "^4.11.2",
|
||||
"fs": "0.0.2",
|
||||
"grunt": "^0.4.5",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, bwcService, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
||||
var self = this;
|
||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||
var errors = bwcService.getErrors();
|
||||
self.isCordova = isCordova;
|
||||
self.isChromeApp = isChromeApp;
|
||||
self.isSafari = isMobile.Safari();
|
||||
|
|
@ -470,10 +471,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
// Debounce function avoids multiple popups
|
||||
var _handleError = function(err) {
|
||||
$log.warn('Client ERROR: ', err);
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
if (err instanceof errors.NOT_AUTHORIZED) {
|
||||
self.notAuthorized = true;
|
||||
go.walletHome();
|
||||
} else if (err.code === 'NOT_FOUND') {
|
||||
} else if (err instanceof errors.NOT_FOUND) {
|
||||
self.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
||||
} else {
|
||||
var msg = ""
|
||||
|
|
|
|||
|
|
@ -286,8 +286,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$rootScope.$on(eventName, function() {
|
||||
fc.getTx($scope.tx.id, function(err, tx) {
|
||||
if (err) {
|
||||
|
||||
if (err.code && err.code == 'TX_NOT_FOUND' &&
|
||||
if (err.message && err.message == 'TX_NOT_FOUND' &&
|
||||
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) {
|
||||
$scope.tx.removed = true;
|
||||
$scope.tx.canBeRemoved = false;
|
||||
|
|
@ -1100,15 +1099,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.settings = walletSettings;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.isShared = fc.credentials.n > 1;
|
||||
$scope.isShared = fc.credentials.n > 1;
|
||||
|
||||
$scope.getAlternativeAmount = function() {
|
||||
var satToBtc = 1 / 100000000;
|
||||
fc.getFiatRate({
|
||||
code : self.alternativeIsoCode,
|
||||
ts : btx.time * 1000
|
||||
fc.getFiatRate({
|
||||
code: self.alternativeIsoCode,
|
||||
ts: btx.time * 1000
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
if (err) {
|
||||
$log.debug('Could not get historic rate');
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ angular.module('copayApp.services')
|
|||
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwsError, gettextCatalog) {
|
||||
var root = {};
|
||||
|
||||
|
||||
root.expireAddress = function(walletId,cb) {
|
||||
$log.debug('Cleaning Address ' + walletId );
|
||||
root.expireAddress = function(walletId, cb) {
|
||||
$log.debug('Cleaning Address ' + walletId);
|
||||
storageService.clearLastAddress(walletId, function(err) {
|
||||
return cb(err);
|
||||
});
|
||||
|
|
@ -34,10 +33,13 @@ angular.module('copayApp.services')
|
|||
return $timeout(function() {
|
||||
root._createAddress(walletId, cb);
|
||||
}, 5000);
|
||||
} else if (err.code && err.code == 'MAIN_ADDRESS_GAP_REACHED') {
|
||||
} else if (err.message && err.message == 'MAIN_ADDRESS_GAP_REACHED') {
|
||||
$log.warn(err.message);
|
||||
prefix = null;
|
||||
client.getMainAddresses({reverse: true, limit : 1}, function(err, addr) {
|
||||
client.getMainAddresses({
|
||||
reverse: true,
|
||||
limit: 1
|
||||
}, function(err, addr) {
|
||||
if (err) return cb(err);
|
||||
return cb(null, addr[0].address);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,50 +4,78 @@ angular.module('copayApp.services')
|
|||
var root = {};
|
||||
|
||||
root.msg = function(err, prefix) {
|
||||
if (!err)
|
||||
return 'Unknown error';
|
||||
|
||||
var name;
|
||||
|
||||
if (err.name) {
|
||||
if (err.name == 'Error')
|
||||
name = err.message
|
||||
else
|
||||
name = err.name.replace(/^bwc.Error/g, '');
|
||||
} else
|
||||
name = err;
|
||||
|
||||
var body = '';
|
||||
prefix = prefix || '';
|
||||
|
||||
if (err && err.code) {
|
||||
switch (err.code) {
|
||||
if (name) {
|
||||
switch (name) {
|
||||
case 'INVALID_BACKUP':
|
||||
body = gettextCatalog.getString('Wallet seed is invalid');
|
||||
break;
|
||||
case 'WALLET_DOES_NOT_EXIST':
|
||||
body = gettextCatalog.getString('Wallet not registered at the wallet service. Recreate it from "Create Wallet" using "Advanced Options" to set your seed');
|
||||
break;
|
||||
case 'MISSING_PRIVATE_KEY':
|
||||
body = gettextCatalog.getString('Missing private keys to sign');
|
||||
break;
|
||||
case 'ENCRYPTED_PRIVATE_KEY':
|
||||
body = gettextCatalog.getString('Private key is encrypted, cannot sign');
|
||||
break;
|
||||
case 'SERVER_COMPROMISED':
|
||||
body = gettextCatalog.getString('Server response could not be verified');
|
||||
break;
|
||||
case 'COULD_NOT_BUILD_TRANSACTION':
|
||||
body = gettextCatalog.getString('Could not build transaction');
|
||||
break;
|
||||
case 'INSUFFICIENT_FUNDS':
|
||||
body = gettextCatalog.getString('Insufficient funds');
|
||||
break;
|
||||
case 'CONNECTION_ERROR':
|
||||
body = gettextCatalog.getString('Network connection error');
|
||||
break;
|
||||
case 'NOT_FOUND':
|
||||
body = gettextCatalog.getString('Wallet service not found');
|
||||
break;
|
||||
case 'BAD_SIGNATURES':
|
||||
body = gettextCatalog.getString('Signatures rejected by server');
|
||||
case 'ECONNRESET_ERROR':
|
||||
body = gettextCatalog.getString('Connection reset by peer');
|
||||
break;
|
||||
case 'COPAYER_DATA_MISMATCH':
|
||||
body = gettextCatalog.getString('Copayer data mismatch');
|
||||
case 'BAD_RESPONSE_CODE':
|
||||
body = gettextCatalog.getString('The request could not be understood by the server');
|
||||
break;
|
||||
case 'WALLET_ALREADY_EXISTS':
|
||||
body = gettextCatalog.getString('Wallet already exists');
|
||||
break;
|
||||
case 'COPAYER_IN_WALLET':
|
||||
body = gettextCatalog.getString('Copayer already in this wallet');
|
||||
break;
|
||||
case 'COPAYER_REGISTERED':
|
||||
body = gettextCatalog.getString('Key already associated with an existing wallet');
|
||||
case 'WALLET_FULL':
|
||||
body = gettextCatalog.getString('Wallet is full');
|
||||
break;
|
||||
case 'COPAYER_VOTED':
|
||||
body = gettextCatalog.getString('Copayer already voted on this spend proposal');
|
||||
break;
|
||||
case 'DUST_AMOUNT':
|
||||
body = gettextCatalog.getString('Amount below dust threshold');
|
||||
break;
|
||||
case 'INCORRECT_ADDRESS_NETWORK':
|
||||
body = gettextCatalog.getString('Incorrect address network');
|
||||
break;
|
||||
case 'INSUFFICIENT_FUNDS':
|
||||
body = gettextCatalog.getString('Insufficient funds');
|
||||
case 'WALLET_NOT_FOUND':
|
||||
body = gettextCatalog.getString('Wallet not found');
|
||||
break;
|
||||
case 'INSUFFICIENT_FUNDS_FOR_FEE':
|
||||
body = gettextCatalog.getString('Insufficient funds for fee');
|
||||
break;
|
||||
case 'INVALID_ADDRESS':
|
||||
body = gettextCatalog.getString('Invalid address');
|
||||
break;
|
||||
case 'LOCKED_FUNDS':
|
||||
body = gettextCatalog.getString('Funds are locked by pending spend proposals');
|
||||
break;
|
||||
case 'COPAYER_VOTED':
|
||||
body = gettextCatalog.getString('Copayer already voted on this spend proposal');
|
||||
break;
|
||||
case 'NOT_AUTHORIZED':
|
||||
body = gettextCatalog.getString('Not authorized');
|
||||
break;
|
||||
|
|
@ -72,26 +100,23 @@ angular.module('copayApp.services')
|
|||
case 'UPGRADE_NEEDED':
|
||||
body = gettextCatalog.getString('Please upgrade Copay to perform this action');
|
||||
break;
|
||||
case 'WALLET_ALREADY_EXISTS':
|
||||
body = gettextCatalog.getString('Wallet already exists');
|
||||
case 'BAD_SIGNATURES':
|
||||
body = gettextCatalog.getString('Signatures rejected by server');
|
||||
break;
|
||||
case 'WALLET_FULL':
|
||||
body = gettextCatalog.getString('Wallet is full');
|
||||
case 'COPAYER_DATA_MISMATCH':
|
||||
body = gettextCatalog.getString('Copayer data mismatch');
|
||||
break;
|
||||
case 'WALLET_NOT_COMPLETE':
|
||||
body = gettextCatalog.getString('Wallet is not complete');
|
||||
case 'DUST_AMOUNT':
|
||||
body = gettextCatalog.getString('Amount below dust threshold');
|
||||
break;
|
||||
case 'WALLET_NOT_FOUND':
|
||||
body = gettextCatalog.getString('Wallet not found');
|
||||
case 'INCORRECT_ADDRESS_NETWORK':
|
||||
body = gettextCatalog.getString('Incorrect address network');
|
||||
break;
|
||||
case 'SERVER_COMPROMISED':
|
||||
body = gettextCatalog.getString('Server response could not be verified');
|
||||
case 'COPAYER_REGISTERED':
|
||||
body = gettextCatalog.getString('Key already associated with an existing wallet');
|
||||
break;
|
||||
case 'WALLET_DOES_NOT_EXIST':
|
||||
body = gettextCatalog.getString('Wallet not registered at the wallet service. Recreate it from "Create Wallet" using "Advanced Options" to set your seed');
|
||||
break;
|
||||
case 'INVALID_BACKUP':
|
||||
body = gettextCatalog.getString('Wallet seed is invalid');
|
||||
case 'INVALID_ADDRESS':
|
||||
body = gettextCatalog.getString('Invalid address');
|
||||
break;
|
||||
case 'MAIN_ADDRESS_GAP_REACHED':
|
||||
body = gettextCatalog.getString('Empty addresses limit reached. New addresses cannot be generated.');
|
||||
|
|
@ -99,20 +124,22 @@ angular.module('copayApp.services')
|
|||
case 'WALLET_LOCKED':
|
||||
body = gettextCatalog.getString('Wallet is locked');
|
||||
break;
|
||||
|
||||
case 'WALLET_NOT_COMPLETE':
|
||||
body = gettextCatalog.getString('Wallet is not complete');
|
||||
break;
|
||||
case 'ERROR':
|
||||
body = (err.message || err.error);
|
||||
break;
|
||||
|
||||
default:
|
||||
$log.warn('Unknown error type:', err.code);
|
||||
body = err.message || err.code;
|
||||
$log.warn('Unknown error type:', name);
|
||||
body = err.message || name;
|
||||
break;
|
||||
}
|
||||
} else if (err.message) {
|
||||
body = gettextCatalog.getString(err.message);
|
||||
body = err.message;
|
||||
} else {
|
||||
body = gettextCatalog.getString(err);
|
||||
body = err;
|
||||
}
|
||||
|
||||
var msg = prefix + (body ? (prefix ? ': ' : '') + body : '');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ angular.module('copayApp.services')
|
|||
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, isChromeApp, isCordova, gettext, gettextCatalog, nodeWebkit, bwsError, uxLanguage, bitcore) {
|
||||
|
||||
var root = {};
|
||||
var errors = bwcService.getErrors();
|
||||
|
||||
var FOREGROUND_UPDATE_PERIOD = 5;
|
||||
var BACKGROUND_UPDATE_PERIOD = 30;
|
||||
|
|
@ -284,8 +285,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) {
|
||||
|
|
@ -314,7 +315,7 @@ angular.module('copayApp.services')
|
|||
var walletId = fc.credentials.walletId;
|
||||
|
||||
pushNotificationsService.unsubscribe(root.getClient(walletId), function(err) {
|
||||
if (err) $log.warn('Subscription error: ' + err.code);
|
||||
if (err) $log.warn('Unsubscription error: ' + err.message);
|
||||
else $log.debug('Unsubscribed from push notifications service');
|
||||
|
||||
$log.debug('Deleting Wallet:', fc.credentials.walletName);
|
||||
|
|
@ -509,8 +510,8 @@ angular.module('copayApp.services')
|
|||
if (err) {
|
||||
|
||||
// in HW wallets, req key is always the same. They can't addAccess.
|
||||
if (err.code == 'NOT_AUTHORIZED')
|
||||
err.code = 'WALLET_DOES_NOT_EXIST';
|
||||
if (err instanceof errors.NOT_AUTHORIZED)
|
||||
err.name = 'WALLET_DOES_NOT_EXIST';
|
||||
|
||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ angular.module('copayApp.services')
|
|||
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
|
||||
opts.token = token;
|
||||
root.subscribe(opts, walletClient, function(err, response) {
|
||||
if (err) $log.warn('Subscription error: ' + err.code);
|
||||
if (err) $log.warn('Subscription error: ' + err.message);
|
||||
else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response));
|
||||
});
|
||||
});
|
||||
|
|
@ -60,7 +60,7 @@ angular.module('copayApp.services')
|
|||
|
||||
lodash.forEach(walletsClients, function(walletClient) {
|
||||
root.unsubscribe(walletClient, function(err) {
|
||||
if (err) $log.warn('Subscription error: ' + err.code);
|
||||
if (err) $log.warn('Unsubscription error: ' + err.message);
|
||||
else $log.debug('Unsubscribed from push notifications service');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue