set bws url for each wallet
This commit is contained in:
parent
a75bbe6e45
commit
24609c6b15
6 changed files with 68 additions and 77 deletions
|
|
@ -118,7 +118,6 @@ angular.module('copayApp.controllers').controller('createController',
|
||||||
configService.set(opts_, function(err) {
|
configService.set(opts_, function(err) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
$scope.$emit('Local/BWSUpdated');
|
$scope.$emit('Local/BWSUpdated');
|
||||||
applicationService.restart();
|
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
configService.set(opts, function(err) {
|
configService.set(opts, function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
$scope.$emit('Local/BWSUpdated');
|
$scope.$emit('Local/BWSUpdated');
|
||||||
applicationService.restart();
|
|
||||||
return cb(null);
|
return cb(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -840,9 +840,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
self.initGlidera = function(accessToken) {
|
self.initGlidera = function(accessToken) {
|
||||||
self.glideraEnabled = configService.getSync().glidera.enabled;
|
self.glideraEnabled = configService.getSync().glidera.enabled;
|
||||||
// self.glideraTestnet = configService.getSync().glidera.testnet;
|
// self.glideraTestnet = configService.getSync().glidera.testnet;
|
||||||
// var network = self.glideraTestnet ? 'testnet' : 'livenet';
|
// var network = self.glideraTestnet ? 'testnet' : 'livenet';
|
||||||
// Disabled for testnet
|
// Disabled for testnet
|
||||||
self.glideraTestnet = false;
|
self.glideraTestnet = false;
|
||||||
var network = 'livenet';
|
var network = 'livenet';
|
||||||
|
|
||||||
|
|
@ -1005,11 +1005,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}, cb);
|
}, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/BWSUpdated', function(event) {
|
|
||||||
profileService.applyConfig();
|
|
||||||
storageService.setCleanAndScanAddresses(function() {});
|
|
||||||
});
|
|
||||||
|
|
||||||
$rootScope.$on('Local/WalletCompleted', function(event) {
|
$rootScope.$on('Local/WalletCompleted', function(event) {
|
||||||
self.setFocusedWallet();
|
self.setFocusedWallet();
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,6 @@ angular.module('copayApp.controllers').controller('joinController',
|
||||||
configService.set(opts_, function(err) {
|
configService.set(opts_, function(err) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
$scope.$emit('Local/BWSUpdated');
|
$scope.$emit('Local/BWSUpdated');
|
||||||
applicationService.restart();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey)) {
|
if (fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey)) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
|
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
|
||||||
function($scope, $log, configService, go, applicationService, profileService) {
|
function($scope, $log, configService, go, applicationService, profileService, storageService) {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.success = null;
|
this.success = null;
|
||||||
|
|
||||||
|
|
@ -35,15 +35,16 @@ angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
|
||||||
this.bwsurl = bws;
|
this.bwsurl = bws;
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
bws: {}
|
bws: {}
|
||||||
};
|
};
|
||||||
opts.bws[walletId] = this.bwsurl;
|
opts.bws[walletId] = this.bwsurl;
|
||||||
|
|
||||||
configService.set(opts, function(err) {
|
configService.set(opts, function(err) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
$scope.$emit('Local/BWSUpdated');
|
storageService.setCleanAndScanAddresses(function() {
|
||||||
applicationService.restart();
|
applicationService.restart();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -48,81 +48,80 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.setWalletClients = function() {
|
root.setWalletClient = function(credentials) {
|
||||||
lodash.each(root.profile.credentials, function(credentials) {
|
if (root.walletClients[credentials.walletId] &&
|
||||||
|
root.walletClients[credentials.walletId].started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (root.walletClients[credentials.walletId] &&
|
var config = configService.getSync();
|
||||||
root.walletClients[credentials.walletId].started) {
|
var defaults = configService.getDefaults();
|
||||||
|
|
||||||
|
bwcService.setBaseUrl(config.bws[credentials.walletId] || defaults.bws.url);
|
||||||
|
bwcService.setTransports(['polling']);
|
||||||
|
|
||||||
|
var client = bwcService.getClient(JSON.stringify(credentials));
|
||||||
|
root.walletClients[credentials.walletId] = client;
|
||||||
|
client.removeAllListeners();
|
||||||
|
|
||||||
|
client.on('reconnect', function() {
|
||||||
|
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
||||||
|
$log.debug('### Online');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('reconnecting', function() {
|
||||||
|
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
||||||
|
$log.debug('### Offline');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('notification', function(n) {
|
||||||
|
$log.debug('BWC Notification:', n);
|
||||||
|
notificationService.newBWCNotification(n,
|
||||||
|
client.credentials.walletId, client.credentials.walletName);
|
||||||
|
|
||||||
|
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
||||||
|
$rootScope.$emit(n.type);
|
||||||
|
} else {
|
||||||
|
$rootScope.$apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('walletCompleted', function() {
|
||||||
|
$log.debug('Wallet completed');
|
||||||
|
|
||||||
|
root.updateCredentialsFC(function() {
|
||||||
|
$rootScope.$emit('Local/WalletCompleted')
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
root.walletClients[credentials.walletId].started = true;
|
||||||
|
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
||||||
|
|
||||||
|
client.initNotifications(function(err) {
|
||||||
|
if (err) {
|
||||||
|
$log.error('Could not init notifications err:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var client = bwcService.getClient(JSON.stringify(credentials));
|
root.setWalletClients = function(walletId) {
|
||||||
root.walletClients[credentials.walletId] = client;
|
var credentials = root.profile.credentials;
|
||||||
client.removeAllListeners();
|
lodash.each(credentials, function(credentials) {
|
||||||
|
root.setWalletClient(credentials);
|
||||||
|
|
||||||
client.on('reconnect', function() {
|
|
||||||
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
|
||||||
$log.debug('### Online');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
client.on('reconnecting', function() {
|
|
||||||
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
|
||||||
$log.debug('### Offline');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('notification', function(n) {
|
|
||||||
$log.debug('BWC Notification:', n);
|
|
||||||
notificationService.newBWCNotification(n,
|
|
||||||
client.credentials.walletId, client.credentials.walletName);
|
|
||||||
|
|
||||||
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
|
||||||
$rootScope.$emit(n.type);
|
|
||||||
} else {
|
|
||||||
$rootScope.$apply();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('walletCompleted', function() {
|
|
||||||
$log.debug('Wallet completed');
|
|
||||||
|
|
||||||
root.updateCredentialsFC(function() {
|
|
||||||
$rootScope.$emit('Local/WalletCompleted')
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
root.walletClients[credentials.walletId].started = true;
|
|
||||||
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
|
||||||
|
|
||||||
client.initNotifications(function(err) {
|
|
||||||
if (err) {
|
|
||||||
$log.error('Could not init notifications err:', err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
$rootScope.$emit('Local/WalletListUpdated');
|
$rootScope.$emit('Local/WalletListUpdated');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
root.applyConfig = function() {
|
|
||||||
var config = configService.getSync();
|
|
||||||
$log.debug('Applying preferences');
|
|
||||||
bwcService.setBaseUrl(config.bws.url);
|
|
||||||
bwcService.setTransports(['polling']);
|
|
||||||
};
|
|
||||||
|
|
||||||
root.bindProfile = function(profile, cb) {
|
root.bindProfile = function(profile, cb) {
|
||||||
root.profile = profile;
|
root.profile = profile;
|
||||||
|
|
||||||
configService.get(function(err) {
|
configService.get(function(err) {
|
||||||
$log.debug('Preferences read');
|
$log.debug('Preferences read');
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
root.applyConfig();
|
|
||||||
root.setWalletClients();
|
root.setWalletClients();
|
||||||
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
@ -327,7 +326,7 @@ angular.module('copayApp.services')
|
||||||
'walletId': walletId
|
'walletId': walletId
|
||||||
});
|
});
|
||||||
if (w) {
|
if (w) {
|
||||||
return cb(gettext('Wallet already in Copay' + ": ") + w.walletName );
|
return cb(gettext('Wallet already in Copay' + ": ") + w.walletName);
|
||||||
}
|
}
|
||||||
|
|
||||||
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
||||||
|
|
@ -369,7 +368,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
|
|
||||||
root._normalizeMnemonic = function(words) {
|
root._normalizeMnemonic = function(words) {
|
||||||
var isJA = words.indexOf('\u3000') > -1;
|
var isJA = words.indexOf('\u3000') > -1;
|
||||||
var wordList = words.split(/[\u3000\s]+/);
|
var wordList = words.split(/[\u3000\s]+/);
|
||||||
|
|
||||||
return wordList.join(isJA ? '\u3000' : ' ');
|
return wordList.join(isJA ? '\u3000' : ' ');
|
||||||
|
|
@ -415,7 +414,6 @@ angular.module('copayApp.services')
|
||||||
root.create = function(opts, cb) {
|
root.create = function(opts, cb) {
|
||||||
$log.info('Creating profile');
|
$log.info('Creating profile');
|
||||||
configService.get(function(err) {
|
configService.get(function(err) {
|
||||||
root.applyConfig();
|
|
||||||
root._createNewProfile(opts, function(err, p) {
|
root._createNewProfile(opts, function(err, p) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
|
@ -552,7 +550,7 @@ angular.module('copayApp.services')
|
||||||
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
||||||
|
|
||||||
ledger.signTx(txp, 0, function(result) {
|
ledger.signTx(txp, 0, function(result) {
|
||||||
$log.debug('Ledger response',result);
|
$log.debug('Ledger response', result);
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return cb(result.message || result.error);
|
return cb(result.message || result.error);
|
||||||
|
|
||||||
|
|
@ -568,11 +566,11 @@ angular.module('copayApp.services')
|
||||||
var fc = root.focusedClient;
|
var fc = root.focusedClient;
|
||||||
$log.info('Requesting Trezor to sign the transaction');
|
$log.info('Requesting Trezor to sign the transaction');
|
||||||
|
|
||||||
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing,'xPubKey');
|
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing, 'xPubKey');
|
||||||
trezor.signTx(xPubKeys, txp, 0, function(err, result) {
|
trezor.signTx(xPubKeys, txp, 0, function(err, result) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
$log.debug('Trezor response',result);
|
$log.debug('Trezor response', result);
|
||||||
txp.signatures = result.signatures;
|
txp.signatures = result.signatures;
|
||||||
return fc.signTxProposal(txp, cb);
|
return fc.signTxProposal(txp, cb);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue