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