From 3776062e16b1033c235c6c211f7ad8cb5361cc85 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Sun, 12 Jun 2016 16:42:32 -0300 Subject: [PATCH] Removes importLegacy. Enable Coinbase/Glidera for livenet. Fix undefined variable on buyCoinbase/Glidera --- src/js/controllers/buyCoinbase.js | 2 +- src/js/controllers/buyGlidera.js | 2 +- src/js/routes.js | 10 -- src/js/services/configService.js | 4 +- src/js/services/legacyImportService.js | 146 ------------------------- src/js/services/profileService.js | 17 --- 6 files changed, 4 insertions(+), 177 deletions(-) delete mode 100644 src/js/services/legacyImportService.js diff --git a/src/js/controllers/buyCoinbase.js b/src/js/controllers/buyCoinbase.js index edf5903df..4126329d6 100644 --- a/src/js/controllers/buyCoinbase.js +++ b/src/js/controllers/buyCoinbase.js @@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', this.init = function(testnet) { self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) - client = profileService.focusedClient; + var client = profileService.focusedClient; if (client) { $timeout(function() { self.selectedWalletId = client.credentials.walletId; diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 9209ef792..207419a04 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.init = function(testnet) { self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1) - client = profileService.focusedClient; + var client = profileService.focusedClient; if (client) { $timeout(function() { self.selectedWalletId = client.credentials.walletId; diff --git a/src/js/routes.js b/src/js/routes.js index 26386c4aa..0da8607e8 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -149,16 +149,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }, } }) - .state('importLegacy', { - url: '/importLegacy', - needProfile: true, - views: { - 'main': { - templateUrl: 'views/importLegacy.html', - }, - } - - }) .state('create', { url: '/create', templateUrl: 'views/create.html', diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 9a18c9894..9af77287d 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -111,11 +111,11 @@ angular.module('copayApp.services').factory('configService', function(storageSer // Glidera // Disabled for testnet - configCache.glidera.testnet = true; + configCache.glidera.testnet = false; // Coinbase // Disabled for testnet - configCache.coinbase.testnet = true; + configCache.coinbase.testnet = false; $log.debug('Preferences read:', configCache) return cb(err, configCache); diff --git a/src/js/services/legacyImportService.js b/src/js/services/legacyImportService.js deleted file mode 100644 index a4103a1d4..000000000 --- a/src/js/services/legacyImportService.js +++ /dev/null @@ -1,146 +0,0 @@ -'use strict'; -angular.module('copayApp.services') - .factory('legacyImportService', function($rootScope, $log, $timeout, $http, lodash, bitcore, bwcService, sjcl, profileService, platformInfo) { - - var root = {}; - var wc = bwcService.getClient(); - - root.getKeyForEmail = function(email) { - var hash = bitcore.crypto.Hash.sha256ripemd160(new bitcore.deps.Buffer(email)).toString('hex'); - $log.debug('Storage key:' + hash); - return 'profile::' + hash; - }; - - root.getKeyForWallet = function(id) { - return 'wallet::' + id; - }; - - root._importOne = function(user, pass, walletId, get, cb) { - get(root.getKeyForWallet(walletId), function(err, blob) { - if (err) { - $log.warn('Could not fetch wallet: ' + walletId + ":" + err); - return cb('Could not fetch ' + walletId); - } - profileService.importLegacyWallet(user, pass, blob, cb); - }); - }; - - - root._doImport = function(user, pass, get, cb) { - var self = this; - get(root.getKeyForEmail(user), function(err, p) { - if (err || !p) - return cb(err || ('Could not find profile for ' + user)); - - - var ids = wc.getWalletIdsFromOldCopay(user, pass, p); - if (!ids) - return cb('Could not find wallets on the profile'); - - $rootScope.$emit('Local/ImportStatusUpdate', - 'Found ' + ids.length + ' wallets to import:' + ids.join()); - - $log.info('Importing Wallet Ids:', ids); - - var i = 0; - var okIds = []; - var toScanIds = []; - lodash.each(ids, function(walletId) { - $timeout(function() { - $rootScope.$emit('Local/ImportStatusUpdate', - 'Importing wallet ' + walletId + ' ... '); - - self._importOne(user, pass, walletId, get, function(err, id, name, existed) { - if (err) { - $rootScope.$emit('Local/ImportStatusUpdate', - 'Failed to import wallet ' + (name || walletId)); - } else { - okIds.push(walletId); - $rootScope.$emit('Local/ImportStatusUpdate', - 'Wallet ' + id + '[' + name + '] imported successfully'); - - if (!existed) { - $log.info('Wallet ' + walletId + ' was created. need to be scanned'); - toScanIds.push(id); - } - } - - if (++i == ids.length) { - return cb(null, okIds, toScanIds); - } - }); - }, 100); - }); - }); - }; - - root.import = function(user, pass, serverURL, fromCloud, cb) { - - var insightGet = function(key, cb) { - - - var kdfbinary = function(password, salt, iterations, length) { - iterations = iterations || defaultIterations; - length = length || 512; - salt = sjcl.codec.base64.toBits(salt || defaultSalt); - - var hash = sjcl.hash.sha256.hash(sjcl.hash.sha256.hash(password)); - var prff = function(key) { - return new sjcl.misc.hmac(hash, sjcl.hash.sha1); - }; - - return sjcl.misc.pbkdf2(hash, salt, iterations, length, prff); - }; - - var salt = 'jBbYTj8zTrOt6V'; - var iter = 1000; - var SEPARATOR = '|'; - - var kdfb = kdfbinary(pass + SEPARATOR + user, salt, iter); - var kdfb64 = sjcl.codec.base64.fromBits(kdfb); - - - var keyBuf = new bitcore.deps.Buffer(kdfb64); - var passphrase = bitcore.crypto.Hash.sha256sha256(keyBuf).toString('base64'); - var authHeader = new bitcore.deps.Buffer(user + ':' + passphrase).toString('base64'); - var retrieveUrl = serverURL + '/retrieve'; - var getParams = { - method: 'GET', - url: retrieveUrl + '?key=' + encodeURIComponent(key) + '&rand=' + Math.random(), - headers: { - 'Authorization': authHeader, - }, - }; - $log.debug('Insight GET', getParams); - - $http(getParams) - .success(function(data) { - data = JSON.stringify(data); - $log.info('Fetch from insight OK:' + getParams.url); - return cb(null, data); - }) - .error(function() { - $log.warn('Failed to fetch from insight'); - return cb('PNOTFOUND: Profile not found'); - }); - }; - - var localStorageGet = function(key, cb) { - if (platformInfo.isChromeApp) { - chrome.storage.local.get(key, - function(data) { - return cb(null, data[key]); - }); - } else { - var v = localStorage.getItem(key); - return cb(null, v); - } - }; - - var get = fromCloud ? insightGet : localStorageGet; - - root._doImport(user, pass, get, cb); - }; - - return root; - }); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 37b92f425..769cc1d1c 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -650,23 +650,6 @@ angular.module('copayApp.services') }); }; - root.importLegacyWallet = function(username, password, blob, cb) { - var walletClient = bwcService.getClient(); - - walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) { - if (err) return cb(gettext('Error importing wallet: ') + err); - - if (root.profile.hasWallet(walletClient.credentials.walletId)) { - $log.debug('Wallet:' + walletClient.credentials.walletName + ' already imported'); - return cb(gettext('Wallet Already Imported: ') + walletClient.credentials.walletName); - }; - - root.addAndBindWalletClient(walletClient, { - isImport: true - }, cb); - }); - }; - root.updateCredentials = function(credentials, cb) { root.profile.updateWallet(credentials); storageService.storeProfileThrottled(root.profile, cb);