mirror of https://github.com/BTCPrivate/copay.git
commit
5f7b68d32f
|
@ -42,7 +42,7 @@
|
||||||
"url": "https://github.com/bitpay/copay/issues"
|
"url": "https://github.com/bitpay/copay/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bitcore-wallet-client": "2.6.0",
|
"bitcore-wallet-client": "2.7.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",
|
||||||
|
|
|
@ -139,7 +139,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted();
|
self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted();
|
||||||
self.externalSource = fc.getPrivKeyExternalSourceName();
|
self.externalSource = fc.getPrivKeyExternalSourceName();
|
||||||
self.account = fc.credentials.account;
|
self.account = fc.credentials.account;
|
||||||
self.incorrectDerivation = fc.incorrectDerivation;
|
self.incorrectDerivation = fc.keyDerivationOk === false;
|
||||||
|
|
||||||
if (self.externalSource == 'trezor')
|
if (self.externalSource == 'trezor')
|
||||||
self.account++;
|
self.account++;
|
||||||
|
@ -290,7 +290,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
} else {
|
} else {
|
||||||
self.isSingleAddress = !!ret.wallet.singleAddress;
|
self.isSingleAddress = !!ret.wallet.singleAddress;
|
||||||
if (!opts.quiet)
|
if (!opts.quiet)
|
||||||
ongoingProcess.set('scanning', ret.wallet.scanStatus == 'running');
|
self.updating = ret.wallet.scanStatus == 'running';
|
||||||
}
|
}
|
||||||
return cb(err, ret);
|
return cb(err, ret);
|
||||||
});
|
});
|
||||||
|
@ -1019,13 +1019,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (!c.isComplete()) return;
|
if (!c.isComplete()) return;
|
||||||
|
|
||||||
if (self.walletId == walletId)
|
if (self.walletId == walletId)
|
||||||
ongoingProcess.set('scanning', true);
|
self.updating = true;
|
||||||
|
|
||||||
c.startScan({
|
c.startScan({
|
||||||
includeCopayerBranches: true,
|
includeCopayerBranches: true,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err && self.walletId == walletId) {
|
if (err && self.walletId == walletId) {
|
||||||
ongoingProcess.set('scanning', false);
|
self.updating = false;
|
||||||
self.handleError(err);
|
self.handleError(err);
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
}
|
}
|
||||||
|
@ -1392,6 +1392,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.isInFocus = function(walletId) {
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
return fc && fc.credentials.walletId == walletId;
|
||||||
|
};
|
||||||
|
|
||||||
self.setAddressbook = function(ab) {
|
self.setAddressbook = function(ab) {
|
||||||
if (ab) {
|
if (ab) {
|
||||||
self.addressbook = ab;
|
self.addressbook = ab;
|
||||||
|
@ -1412,12 +1417,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.tab = 'walletHome';
|
self.tab = 'walletHome';
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/ValidatingWallet', function() {
|
$rootScope.$on('Local/ValidatingWallet', function(ev, walletId) {
|
||||||
|
if (self.isInFocus(walletId)) {
|
||||||
ongoingProcess.set('validatingWallet', true);
|
ongoingProcess.set('validatingWallet', true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/ProfileBound', function() {
|
$rootScope.$on('Local/ValidatingWalletEnded', function(ev, walletId, isOK) {
|
||||||
|
if (self.isInFocus(walletId)) {
|
||||||
ongoingProcess.set('validatingWallet', false);
|
ongoingProcess.set('validatingWallet', false);
|
||||||
|
self.incorrectDerivation = isOK === false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/ClearHistory', function(event) {
|
$rootScope.$on('Local/ClearHistory', function(event) {
|
||||||
|
@ -1479,8 +1489,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/WalletCompleted', function(event, walletId) {
|
$rootScope.$on('Local/WalletCompleted', function(event, walletId) {
|
||||||
var fc = profileService.focusedClient;
|
if (self.isInFocus(walletId)) {
|
||||||
if (fc && fc.credentials.walletId == walletId) {
|
|
||||||
// reset main wallet variables
|
// reset main wallet variables
|
||||||
self.setFocusedWallet();
|
self.setFocusedWallet();
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
|
|
|
@ -57,6 +57,12 @@ Profile.prototype.isChecked = function(ua, walletId) {
|
||||||
return !!(this.checkedUA == ua && this.checked[walletId]);
|
return !!(this.checkedUA == ua && this.checked[walletId]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Profile.prototype.isDeviceChecked = function(ua) {
|
||||||
|
return this.checkedUA == ua;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Profile.prototype.setChecked = function(ua, walletId) {
|
Profile.prototype.setChecked = function(ua, walletId) {
|
||||||
if (this.checkedUA != ua) {
|
if (this.checkedUA != ua) {
|
||||||
this.checkedUA = ua;
|
this.checkedUA = ua;
|
||||||
|
|
|
@ -75,11 +75,6 @@ angular.module('copayApp.services')
|
||||||
root.walletClients[walletId].started = true;
|
root.walletClients[walletId].started = true;
|
||||||
root.walletClients[walletId].doNotVerifyPayPro = isChromeApp;
|
root.walletClients[walletId].doNotVerifyPayPro = isChromeApp;
|
||||||
|
|
||||||
if (client.incorrectDerivation) {
|
|
||||||
$log.warn('Key Derivation failed for wallet:' + walletId);
|
|
||||||
storageService.clearLastAddress(walletId, function() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
client.removeAllListeners();
|
client.removeAllListeners();
|
||||||
client.on('report', function(n) {
|
client.on('report', function(n) {
|
||||||
$log.info('BWC Report:' + n);
|
$log.info('BWC Report:' + n);
|
||||||
|
@ -121,6 +116,30 @@ angular.module('copayApp.services')
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.runValidation = function(client) {
|
||||||
|
var skipDeviceValidation = root.profile.isDeviceChecked(platformInfo.ua);
|
||||||
|
var walletId = client.credentials.walletId;
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
|
|
||||||
|
$log.debug('ValidatingWallet: ' + walletId + ' skip Device:' + skipDeviceValidation);
|
||||||
|
$rootScope.$emit('Local/ValidatingWallet', walletId);
|
||||||
|
|
||||||
|
client.validateKeyDerivation({
|
||||||
|
skipDeviceValidation: skipDeviceValidation,
|
||||||
|
}, function(err, isOK) {
|
||||||
|
$log.debug('ValidatingWallet End: ' + walletId + ' isOK:' + isOK);
|
||||||
|
$rootScope.$emit('Local/ValidatingWalletEnded', walletId, isOK);
|
||||||
|
|
||||||
|
if (isOK) {
|
||||||
|
root.profile.setChecked(platformInfo.ua, walletId);
|
||||||
|
} else {
|
||||||
|
$log.warn('Key Derivation failed for wallet:' + walletId);
|
||||||
|
storageService.clearLastAddress(walletId, function() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
};
|
||||||
|
|
||||||
// Used when reading wallets from the profile
|
// Used when reading wallets from the profile
|
||||||
root.bindWallet = function(credentials, cb) {
|
root.bindWallet = function(credentials, cb) {
|
||||||
|
@ -135,22 +154,17 @@ angular.module('copayApp.services')
|
||||||
return ((config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url);
|
return ((config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
var skipKeyValidation = root.profile.isChecked(platformInfo.ua, credentials.walletId);
|
|
||||||
if (!skipKeyValidation) {
|
|
||||||
$rootScope.$emit('Local/ValidatingWallet');
|
|
||||||
}
|
|
||||||
$timeout(function() {
|
|
||||||
$log.info('Binding wallet:' + credentials.walletId + ' Validating?:' + !skipKeyValidation);
|
|
||||||
var client = bwcService.getClient(JSON.stringify(credentials), {
|
var client = bwcService.getClient(JSON.stringify(credentials), {
|
||||||
bwsurl: getBWSURL(credentials.walletId),
|
bwsurl: getBWSURL(credentials.walletId),
|
||||||
skipKeyValidation: skipKeyValidation,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!skipKeyValidation && !client.incorrectDerivation)
|
var skipKeyValidation = root.profile.isChecked(platformInfo.ua, credentials.walletId);
|
||||||
root.profile.setChecked(platformInfo.ua, credentials.walletId);
|
if (!skipKeyValidation)
|
||||||
|
root.runValidation(client);
|
||||||
|
|
||||||
|
$log.info('Binding wallet:' + credentials.walletId + ' Validating?:' + !skipKeyValidation);
|
||||||
return cb(null, root.bindWalletClient(client));
|
return cb(null, root.bindWalletClient(client));
|
||||||
}, skipKeyValidation ? 50 : 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
root.bindProfile = function(profile, cb) {
|
root.bindProfile = function(profile, cb) {
|
||||||
|
@ -463,6 +477,11 @@ angular.module('copayApp.services')
|
||||||
if (!root.profile.addWallet(JSON.parse(client.export())))
|
if (!root.profile.addWallet(JSON.parse(client.export())))
|
||||||
return cb(gettext('Wallet already in Copay'));
|
return cb(gettext('Wallet already in Copay'));
|
||||||
|
|
||||||
|
|
||||||
|
var skipKeyValidation = root.profile.isChecked(platformInfo.ua, walletId);
|
||||||
|
if (!skipKeyValidation)
|
||||||
|
root.runValidation(client);
|
||||||
|
|
||||||
root.bindWalletClient(client);
|
root.bindWalletClient(client);
|
||||||
$rootScope.$emit('Local/WalletListUpdated', client);
|
$rootScope.$emit('Local/WalletListUpdated', client);
|
||||||
|
|
||||||
|
@ -543,9 +562,6 @@ angular.module('copayApp.services')
|
||||||
var addressBook = str.addressBook || {};
|
var addressBook = str.addressBook || {};
|
||||||
var historyCache = str.historyCache || [];
|
var historyCache = str.historyCache || [];
|
||||||
|
|
||||||
if (!walletClient.incorrectDerivation)
|
|
||||||
root.profile.setChecked(platformInfo.ua, walletClient.credentials.walletId);
|
|
||||||
|
|
||||||
root.addAndBindWalletClient(walletClient, {
|
root.addAndBindWalletClient(walletClient, {
|
||||||
bwsurl: opts.bwsurl,
|
bwsurl: opts.bwsurl,
|
||||||
isImport: true
|
isImport: true
|
||||||
|
|
Loading…
Reference in New Issue