diff --git a/bower.json b/bower.json index 703866c7a..74dd674a8 100644 --- a/bower.json +++ b/bower.json @@ -8,7 +8,7 @@ ], "dependencies": { "angular": "1.4.6", - "angular-bitcore-wallet-client": "0.4.4", + "angular-bitcore-wallet-client": "0.6.4", "angular-foundation": "0.7.0", "angular-gettext": "2.1.0", "angular-moment": "0.10.1", @@ -23,4 +23,4 @@ "ng-lodash": "0.2.3", "qrcode-decoder-js": "*" } -} +} \ No newline at end of file diff --git a/public/views/modals/paperWallet.html b/public/views/modals/paperWallet.html new file mode 100644 index 000000000..19a3fdf90 --- /dev/null +++ b/public/views/modals/paperWallet.html @@ -0,0 +1,73 @@ + + + +
+
+
+
+ + + Not valid + + + + +
+
+ +
+ + + {{unitName}} +
+
+
+ + +
+ +
+
+
+ +
+ \ No newline at end of file diff --git a/public/views/paperWallet.html b/public/views/paperWallet.html new file mode 100644 index 000000000..9a0c8b178 --- /dev/null +++ b/public/views/paperWallet.html @@ -0,0 +1,41 @@ +
+
+ +
+
+
+
+ + {{paperWallet.error}} +
+
+ + +
+ +
+ + +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
diff --git a/public/views/preferencesAdvanced.html b/public/views/preferencesAdvanced.html index da39f5c3d..974df100a 100644 --- a/public/views/preferencesAdvanced.html +++ b/public/views/preferencesAdvanced.html @@ -16,6 +16,11 @@
  • Scan addresses for funds
  • + +
  • + + Scan Paper Wallet +
  • diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js new file mode 100644 index 000000000..42f18e365 --- /dev/null +++ b/src/js/controllers/paperWallet.js @@ -0,0 +1,82 @@ +angular.module('copayApp.controllers').controller('paperWalletController', + function($scope, $http, profileService, addressService) { + + self = this; + var fc = profileService.focusedClient; + var rawTx; + + self.onQrCodeScanned = function(data) { + $scope.privateKey = data; + console.log(data); + } + + self.createTx = function(privateKey, passphrase) { + console.log("entro"); + console.log(privateKey); + console.log(passphrase); + if (!privateKey) self.error = "Enter privateKey or scann for one"; + this.getRawTx(privateKey, passphrase, function(err, rawTx, utxos) { + console.log(utxos); + console.log("creada"); + if (err) self.error = err.toString(); + else { + self.balance = (utxos / 1e8).toFixed(8); + rawTx = rawTx; + } + }); + }; + + self.getRawTx = function(privateKey, passphrase, cb) { + if (privateKey.charAt(0) == 6) { + fc.decryptBIP38PrivateKey(privateKey, passphrase, null, function(err, privateKey) { + if (err) return cb(err); + + fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) { + if (err) return cb(err); + + addressService.getAddress(fc.credentials.walletId, true, function(err, destinationAddress) { + if (err) return cb(err); + + fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) { + if (err) return cb(err); + console.log(tx.serialize()); + return cb(null, tx.serialize(), utxos); + }); + }); + }); + }); + } else { + fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) { + if (err) return cb(err) + + addressService.getAddress(fc.credentials.walletId, true, function(err, destinationAddress) { + if (err) return cb(err); + + fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) { + if (err) return cb(err); + console.log(tx.serialize()); + return cb(null, tx.serialize(), utxos); + }); + }); + }); + } + }; + + self.transaction = function() { + + self.doTransaction(rawTx).then(function(response) { + console.log(response); //mostrar pantalla de sent successfully + }, + function(err) { + self.error = err; + console.log(err); //mostrar mensaje de error en la pantalla + }); + }; + + self.doTransaction = function(rawTx) { + return $http.post('https://insight.bitpay.com/api/tx/send', { + rawtx: rawTx + }); + }; + + }); \ No newline at end of file diff --git a/src/js/controllers/preferencesAdvanced.js b/src/js/controllers/preferencesAdvanced.js index 5cd7dca3c..30616e803 100644 --- a/src/js/controllers/preferencesAdvanced.js +++ b/src/js/controllers/preferencesAdvanced.js @@ -2,4 +2,5 @@ angular.module('copayApp.controllers').controller('preferencesAdvancedController', function($scope) { - }); + + }); \ No newline at end of file diff --git a/src/js/routes.js b/src/js/routes.js index b5542771c..f6d58c84e 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -44,7 +44,7 @@ angular v = JSON.stringify(v); } // Trim output in mobile - if ( window.cordova ) { + if (window.cordova) { v = v.toString(); if (v.length > 1000) { v = v.substr(0, 997) + '...'; @@ -85,7 +85,7 @@ angular } }); - $stateProvider + $stateProvider .state('translators', { url: '/translators', walletShouldBeComplete: true, @@ -275,27 +275,27 @@ angular }) .state('preferencesGlidera', { - url: '/preferencesGlidera', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/preferencesGlidera.html' - }, - } - }) + url: '/preferencesGlidera', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/preferencesGlidera.html' + }, + } + }) .state('preferencesAdvanced', { - url: '/preferencesAdvanced', - templateUrl: 'views/preferencesAdvanced.html', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/preferencesAdvanced.html' - }, - } - }) + url: '/preferencesAdvanced', + templateUrl: 'views/preferencesAdvanced.html', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/preferencesAdvanced.html' + }, + } + }) .state('preferencesColor', { url: '/preferencesColor', templateUrl: 'views/preferencesColor.html', @@ -309,16 +309,16 @@ angular }) .state('preferencesAltCurrency', { - url: '/preferencesAltCurrency', - templateUrl: 'views/preferencesAltCurrency.html', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/preferencesAltCurrency.html' - }, - } - }) + url: '/preferencesAltCurrency', + templateUrl: 'views/preferencesAltCurrency.html', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/preferencesAltCurrency.html' + }, + } + }) .state('preferencesAlias', { url: '/preferencesAlias', templateUrl: 'views/preferencesAlias.html', @@ -376,18 +376,18 @@ angular }, } }) - - .state('about', { - url: '/about', - templateUrl: 'views/preferencesAbout.html', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/preferencesAbout.html' - }, - } - }) + + .state('about', { + url: '/about', + templateUrl: 'views/preferencesAbout.html', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/preferencesAbout.html' + }, + } + }) .state('logs', { url: '/logs', templateUrl: 'views/preferencesLogs.html', @@ -410,6 +410,17 @@ angular }, } }) + .state('paperWallet', { + url: '/paperWallet', + templateUrl: 'views/paperWallet.html', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/paperWallet.html' + }, + } + }) .state('backup', { url: '/backup', templateUrl: 'views/backup.html', @@ -435,14 +446,14 @@ angular }) .state('add', { - url: '/add', - needProfile: true, - views: { - 'main': { - templateUrl: 'views/add.html' - }, - } - }) + url: '/add', + needProfile: true, + views: { + 'main': { + templateUrl: 'views/add.html' + }, + } + }) .state('cordova', { url: '/cordova/:status/:isHome', views: { @@ -450,7 +461,7 @@ angular controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova) { switch ($stateParams.status) { case 'resume': - $rootScope.$emit('Local/Resume'); + $rootScope.$emit('Local/Resume'); break; case 'backbutton': if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) { @@ -534,4 +545,4 @@ angular }, 50); } }); - }); + }); \ No newline at end of file