parent
2227705453
commit
564d29e923
1 changed files with 25 additions and 23 deletions
|
|
@ -570,48 +570,50 @@ angular.module('copayApp.services')
|
||||||
// Adds and bind a new client to the profile
|
// Adds and bind a new client to the profile
|
||||||
var addAndBindWalletClient = function(client, opts, cb) {
|
var addAndBindWalletClient = function(client, opts, cb) {
|
||||||
if (!client || !client.credentials)
|
if (!client || !client.credentials)
|
||||||
return cb(gettextCatalog.getString('Could not access wallet'));
|
return cb(gettextCatalog.getString('Could not access wallet'));
|
||||||
|
|
||||||
// Encrypt wallet
|
// Encrypt wallet
|
||||||
ongoingProcess.pause();
|
ongoingProcess.pause();
|
||||||
encryptWallet(client, function() {
|
encryptWallet(client, function() {
|
||||||
ongoingProcess.resume();
|
ongoingProcess.resume();
|
||||||
|
|
||||||
var walletId = client.credentials.walletId
|
var walletId = client.credentials.walletId
|
||||||
|
|
||||||
if (!root.profile.addWallet(JSON.parse(client.export())))
|
if (!root.profile.addWallet(JSON.parse(client.export())))
|
||||||
return cb(gettextCatalog.getString("Wallet already in {{appName}}", {
|
return cb(gettextCatalog.getString("Wallet already in {{appName}}", {
|
||||||
appName: appConfigService.nameCase
|
appName: appConfigService.nameCase
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
var skipKeyValidation = shouldSkipValidation(walletId);
|
var skipKeyValidation = shouldSkipValidation(walletId);
|
||||||
if (!skipKeyValidation)
|
if (!skipKeyValidation)
|
||||||
root.runValidation(client);
|
root.runValidation(client);
|
||||||
|
|
||||||
root.bindWalletClient(client);
|
root.bindWalletClient(client);
|
||||||
|
|
||||||
var saveBwsUrl = function(cb) {
|
var saveBwsUrl = function(cb) {
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var bwsFor = {};
|
var bwsFor = {};
|
||||||
bwsFor[walletId] = opts.bwsurl || defaults.bws.url;
|
bwsFor[walletId] = opts.bwsurl || defaults.bws.url;
|
||||||
|
|
||||||
// Dont save the default
|
// Dont save the default
|
||||||
if (bwsFor[walletId] == defaults.bws.url)
|
if (bwsFor[walletId] == defaults.bws.url)
|
||||||
return cb();
|
return cb();
|
||||||
|
|
||||||
configService.set({
|
configService.set({
|
||||||
bwsFor: bwsFor,
|
bwsFor: bwsFor,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) $log.warn(err);
|
if (err) $log.warn(err);
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
saveBwsUrl(function() {
|
saveBwsUrl(function() {
|
||||||
storageService.storeProfile(root.profile, function(err) {
|
storageService.storeProfile(root.profile, function(err) {
|
||||||
|
if (cb) {
|
||||||
return cb(err, client);
|
return cb(err, client);
|
||||||
});
|
}
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue