diff --git a/js/controllers/paymentIntent.js b/js/controllers/paymentIntent.js new file mode 100644 index 000000000..f1cb486be --- /dev/null +++ b/js/controllers/paymentIntent.js @@ -0,0 +1,25 @@ +'use strict'; + +var bitcore = require('bitcore'); + +angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $routeParams, $timeout, $location, controllerUtils) { + + + $rootScope.title = 'Select the wallet that you will use to spend your bitcoins'; + $scope.wallets = []; + + var wids = _.pluck($rootScope.iden.listWallets(), 'id'); + _.each(wids, function(wid) { + var w = $rootScope.iden.getWalletById(wid); + $scope.wallets.push(w); + controllerUtils.updateBalance(w, function() { + $rootScope.$digest(); + }); + }); + + $scope.switchWallet = function(wid) { + //go to send page + controllerUtils.setPaymentWallet(wid); + }; + +}); diff --git a/js/controllers/send.js b/js/controllers/send.js index d170dbae2..c0318a976 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -4,6 +4,34 @@ var preconditions = require('preconditions').singleton(); angular.module('copayApp.controllers').controller('SendController', function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) { + + controllerUtils.redirIfNotComplete(); + + var w = $rootScope.wallet; + preconditions.checkState(w); + preconditions.checkState(w.settings.unitToSatoshi); + + $rootScope.title = 'Send'; + $scope.loading = false; + var satToUnit = 1 / w.settings.unitToSatoshi; + $scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit; + $scope.unitToBtc = w.settings.unitToSatoshi / bitcore.util.COIN; + $scope.unitToSatoshi = w.settings.unitToSatoshi; + + $scope.alternativeName = w.settings.alternativeName; + $scope.alternativeIsoCode = w.settings.alternativeIsoCode; + + $scope.isRateAvailable = false; + $scope.rateService = rateService; + + + + rateService.whenAvailable(function() { + $scope.isRateAvailable = true; + $scope.$digest(); + }); + + /** * Setting the two related amounts as properties prevents an infinite * recursion for watches while preserving the original angular updates diff --git a/js/controllers/uriPayment.js b/js/controllers/uriPayment.js index 682ded3e0..486a09be7 100644 --- a/js/controllers/uriPayment.js +++ b/js/controllers/uriPayment.js @@ -14,7 +14,8 @@ angular.module('copayApp.controllers').controller('UriPaymentController', functi $rootScope.pendingPayment = new bitcore.BIP21(bitcoinURI); $timeout(function() { - $location.path('/send'); + console.log('Redirecting to /paymentIntent'); + $location.path('/paymentIntent'); }, 1000); diff --git a/js/routes.js b/js/routes.js index a19ef2666..a070b87cb 100644 --- a/js/routes.js +++ b/js/routes.js @@ -22,6 +22,10 @@ angular .when('/uri-payment/:data', { templateUrl: 'views/uri-payment.html' }) + .when('/paymentIntent', { + templateUrl: 'views/paymentIntent.html', + logged: true + }) .when('/join', { templateUrl: 'views/join.html', logged: true diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index a106f8d1f..454fb4892 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -93,7 +93,7 @@ angular.module('copayApp.services') if ($rootScope.initialConnection) { $rootScope.initialConnection = false; if ($rootScope.pendingPayment) { - $location.path('send'); + $location.path('paymentIntent'); } else { root.redirIfLogged(); } @@ -196,6 +196,11 @@ angular.module('copayApp.services') }); }; + root.setPaymentWallet = function(w) { + root.setFocusedWallet(w); + $location.path('/send'); + }; + root.setFocusedWallet = function(w) { if (!_.isObject(w)) w = $rootScope.iden.getWalletById(w); diff --git a/views/paymentIntent.html b/views/paymentIntent.html new file mode 100644 index 000000000..8a682220b --- /dev/null +++ b/views/paymentIntent.html @@ -0,0 +1,32 @@ +
+ + + + + +
+ +