diff --git a/js/controllers/paymentUri.js b/js/controllers/paymentUri.js index 9e8ba6da6..dd855cc8c 100644 --- a/js/controllers/paymentUri.js +++ b/js/controllers/paymentUri.js @@ -7,11 +7,12 @@ angular.module('copayApp.controllers').controller('paymentUriController', functi angular.forEach($location.search(), function(value, key) { query.push(key + "=" + value); }); - var queryString = query ? "?" + query.join("&") : ""; - var bitcoinURI = $routeParams.data + queryString; + var queryString = query ? query.join("&") : null; + var bitcoinURI = $routeParams.data + ( queryString ? '?' + queryString : ''); var uri = new bitcore.BIP21(bitcoinURI); - if (uri.isValid()) { + if (uri && uri.address && (_.isString(uri.address) || uri.address.isValid()) ) { + copay.logger.debug('Payment Intent:', bitcoinURI); $rootScope.pendingPayment = bitcoinURI; } diff --git a/js/controllers/send.js b/js/controllers/send.js index 74a2e91bb..8bf5c57fe 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -29,8 +29,10 @@ angular.module('copayApp.controllers').controller('SendController', $scope.isMobile = isMobile.any(); if ($rootScope.pendingPayment) { - $scope.setFromUri($rootScope.pendingPayment) - $rootScope.pendingPayment = null; + $timeout(function() { + $scope.setFromUri($rootScope.pendingPayment) + $rootScope.pendingPayment = null; + },100); } $scope.setInputs(); @@ -154,11 +156,8 @@ angular.module('copayApp.controllers').controller('SendController', amountSat: amount, comment: comment, }, function(err, txid, status) { - console.log('[send.js.156:txid:]', txid); //TODO - console.log('[send.js.156:status:]', status); //TODO $scope.loading = false; - console.log('[send.js.158]'); //TODO if (err) return $scope.setError(err); diff --git a/js/controllers/walletForPayment.js b/js/controllers/walletForPayment.js index 12a8fa9e7..958f82946 100644 --- a/js/controllers/walletForPayment.js +++ b/js/controllers/walletForPayment.js @@ -1,27 +1,9 @@ var bitcore = require('bitcore'); -angular.module('copayApp.controllers').controller('walletForPaymentController', function($rootScope, $scope, $modal, go) { - -console.log('[walletForPayment.js.4]'); //TODO - if (!$rootScope.pendingPayment) { - go.walletHome(); - } else { - -console.log('[walletForPayment.js.9]'); //TODO - $scope.selectWallet(function(w) { - if (w) { - identityService.setFocusedWallet(w); - go.send(); - } else { - go.walletHome(); - } - }); - } +angular.module('copayApp.controllers').controller('walletForPaymentController', function($rootScope, $scope, $modal, identityService, go) { $scope.selectWallet = function(cb) { - -console.log('[walletForPayment.js.22]'); //TODO - var ModalInstanceCtrl = function($scope, $modalInstance, $identityService) { + var ModalInstanceCtrl = function($scope, $modalInstance, identityService) { $scope.loading = true; preconditions.checkState($rootScope.iden); @@ -31,9 +13,7 @@ console.log('[walletForPayment.js.22]'); //TODO }); $scope.setWallets = function() { - $scope.wallets = _.filter($rootScope.iden.listWallets(), function(w) { - return w.balanceInfo && w.balanceInfo.totalBalanceBTC; - }); + $scope.wallets = $rootScope.iden.listWallets(); }; $scope.ok = function(w) { @@ -47,11 +27,25 @@ console.log('[walletForPayment.js.22]'); //TODO }; }; -console.log('[walletForPayment.js.49]'); //TODO $modal.open({ - templateUrl: 'views/modals/walletSelect.html', + templateUrl: 'views/modals/walletSelection.html', windowClass: 'tiny', controller: ModalInstanceCtrl, }); }; + + + // INIT: (not it a function, since there is no associated html) + if (!$rootScope.pendingPayment) { + go.walletHome(); + } else { + $scope.selectWallet(function(w) { + if (w) { + identityService.setFocusedWallet(w); + go.send(); + } else { + go.walletHome(); + } + }); + }; }); diff --git a/js/services/go.js b/js/services/go.js index ffd2b951e..4801fb111 100644 --- a/js/services/go.js +++ b/js/services/go.js @@ -73,7 +73,6 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, }; root.home = function() { -console.log('[go.js.48:home:]'); //TODO if ($rootScope.iden) root.walletHome(); else @@ -82,8 +81,6 @@ console.log('[go.js.48:home:]'); //TODO root.send = function() { - -console.log('[go.js.58]'); //TODO $location.path('send'); }; diff --git a/views/modals/walletSelection.html b/views/modals/walletSelection.html index 092bc9d87..06c02f3ad 100644 --- a/views/modals/walletSelection.html +++ b/views/modals/walletSelection.html @@ -1,9 +1,9 @@ × -

Select a wallet to make the payment

+

Select a wallet to make the payment

Loading...