From 6aa075326ec26734eecceb927aa94881c37705dd Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 28 Jun 2016 15:34:10 -0300 Subject: [PATCH] process code - parse information to import wallet --- cordova/build.sh | 3 - public/views/export.html | 2 +- public/views/import.html | 202 +++++++++++++++++------------------ src/js/controllers/export.js | 6 +- src/js/controllers/import.js | 39 ++++++- 5 files changed, 138 insertions(+), 114 deletions(-) diff --git a/cordova/build.sh b/cordova/build.sh index 6a99d667b..c0fb9ed30 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -155,9 +155,6 @@ if [ ! -d $PROJECT ]; then cordova plugin add cordova-plugin-disable-bitcode checkOK - cordova plugin add cordova-plugin-android-fingerprint-auth - checkOK - cordova plugin add cordova-plugin-screen-orientation checkOK diff --git a/public/views/export.html b/public/views/export.html index 32dbaa08b..26fa7e069 100644 --- a/public/views/export.html +++ b/public/views/export.html @@ -96,7 +96,7 @@
- +
diff --git a/public/views/import.html b/public/views/import.html index 5ce29400c..c79c0086b 100644 --- a/public/views/import.html +++ b/public/views/import.html @@ -24,83 +24,76 @@
-
-
Could not access the wallet at the server. Please check:
-
    -
  • The password of the recovery phrase (if set) -
  • -
  • The derivation path -
  • -
  • The wallet service URL -
-
- NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there.
-
+
+
Could not access the wallet at the server. Please check:
+
    +
  • The password of the recovery phrase (if set)
  • +
  • The derivation path
  • +
  • The wallet service URL +
+
+ NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there.
+
-
- {{import.error|translate}} -
+
{{import.error|translate}}
-
+ + +
+ +
+ -
- - -
+ - -
-
- -
@@ -175,58 +168,55 @@
-
-
- No hardware wallets supported on this device -
-
-
- -
- -
- - -
- -
- - Shared Wallet - -
- - -
-
- - -
-
- - - -
+
+ No hardware wallets supported on this device
+
+
+ +
+ +
+ + +
+ +
+ + Shared Wallet + +
+ + +
+
+ + +
+
+ + +
diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index cb7561458..62244fae3 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('exportController', $scope.isCordova = platformInfo.isCordova; $scope.isSafari = platformInfo.isSafari; $scope.error = null; + console.log(fc.credentials); $scope.init = function(state) { $scope.QROpts = false; @@ -64,7 +65,7 @@ angular.module('copayApp.controllers').controller('exportController', if (c.mnemonic) { info = { type: encodingType.mnemonic, - data: c.mnemonic + data: c.mnemonic, } } else { info = { @@ -79,7 +80,8 @@ angular.module('copayApp.controllers').controller('exportController', } } - var code = info.type + c.network.charAt(0).toLowerCase() + info.data; + var code = info.type + '|' + c.network.charAt(0).toLowerCase() + '|' + info.data + '|' + c.account + '|' + c.derivationStrategy + + '|' + (c.mnemonicHasPassphrase || null); return code; }; diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index af5a44cd9..a9afd7d97 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -13,6 +13,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.bwsurl = defaults.bws.url; $scope.derivationPath = derivationPathHelper.default; $scope.account = 1; + $scope.processingCode = null; self.importErr = false; var updateSeedSourceSelect = function() { @@ -34,12 +35,46 @@ angular.module('copayApp.controllers').controller('importController', } }; + $scope.processCode = function(code) { + var parsedCode = code.split('|'); + var derivationStrategy = "44'"; + var networkVal; + + var info = { + type: parsedCode[0], + network: parsedCode[1], + data: parsedCode[2], + account: parsedCode[3], + derivationStrategy: parsedCode[4], + hasPassphrase: parsedCode[5] + }; + + $scope.words = info.data; + + if (info.network == 't') { + networkVal = "1'"; + $scope.testnetEnabled = true; + } else { + networkVal = "0'"; + $scope.testnetEnabled = false; + } + + if (info.derivationStrategy == 'BIP45' || info.derivationStrategy == 'BIP48') + derivationStrategy = info.derivationStrategy.substring(3, 5) + "'"; + + $scope.derivationPath = "m/" + derivationStrategy + '/' + networkVal + '/' + info.account + "'"; + + $timeout(function() { + $rootScope.$apply(); + }, 1); + }; + this.setType = function(type) { $scope.type = type; this.error = null; $timeout(function() { $rootScope.$apply(); - }); + }, 1); }; var _importBlob = function(str, opts) { @@ -130,7 +165,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.derivationPath = derivationPathHelper.defaultTestnet; else $scope.derivationPath = derivationPathHelper.default; - } + }; $scope.getFile = function() { // If we use onloadend, we need to check the readyState.