diff --git a/public/views/paymentUri.html b/public/views/paymentUri.html
index 8c201128f..528000cb9 100644
--- a/public/views/paymentUri.html
+++ b/public/views/paymentUri.html
@@ -9,15 +9,18 @@
Address: {{uri.address.toString()}}
Amount: {{uri.amount}}
Message: {{uri.message}}
+ Network: {{uri.network}}
Select a wallet
-
+
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js
index e870fdac3..b53b798c5 100644
--- a/src/js/controllers/index.js
+++ b/src/js/controllers/index.js
@@ -104,11 +104,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
self.setTab = function(tab) {
- if (self.tab && document.getElementById(self.tab)) {
+
+ if (self.tab === tab)
+ return;
+
+ if (!self.tab)
+ self.tab = 'walletHome';
+
+ if (document.getElementById(self.tab)) {
document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab;
var old = document.getElementById('menu-' + self.tab);
- old.className = '';
- old.style.borderTopColor = '';
+ if (old) {
+ old.className = '';
+ old.style.borderTopColor = '';
+ }
}
if (document.getElementById(tab)) {
diff --git a/src/js/controllers/paymentUri.js b/src/js/controllers/paymentUri.js
index 974e966ca..2dac95c32 100644
--- a/src/js/controllers/paymentUri.js
+++ b/src/js/controllers/paymentUri.js
@@ -1,63 +1,68 @@
'use strict';
-angular.module('copayApp.controllers').controller('paymentUriController',
- function($rootScope, $stateParams, $location, $timeout, profileService, configService, lodash, bitcore, go) {
+angular.module('copayApp.controllers').controller('paymentUriController',
+ function($rootScope, $stateParams, $location, $timeout, profileService, configService, lodash, bitcore, go) {
- function strip(number) {
- return (parseFloat(number.toPrecision(12)));
- };
+ function strip(number) {
+ return (parseFloat(number.toPrecision(12)));
+ };
- // Build bitcoinURI with querystring
- this.checkBitcoinUri = function() {
- var query = [];
- angular.forEach($location.search(), function(value, key) {
- query.push(key + "=" + value);
- });
- var queryString = query ? query.join("&") : null;
- this.bitcoinURI = $stateParams.data + ( queryString ? '?' + queryString : '');
+ // Build bitcoinURI with querystring
+ this.checkBitcoinUri = function() {
+ var query = [];
+ angular.forEach($location.search(), function(value, key) {
+ query.push(key + "=" + value);
+ });
+ var queryString = query ? query.join("&") : null;
+ this.bitcoinURI = $stateParams.data + (queryString ? '?' + queryString : '');
- var URI = bitcore.URI;
- var isUriValid = URI.isValid(this.bitcoinURI);
- if (!URI.isValid(this.bitcoinURI)) {
- this.error = true;
- return;
- }
- var uri = new URI(this.bitcoinURI);
+ var URI = bitcore.URI;
+ var isUriValid = URI.isValid(this.bitcoinURI);
+ if (!URI.isValid(this.bitcoinURI)) {
+ this.error = true;
+ return;
+ }
+ var uri = new URI(this.bitcoinURI);
- if (uri && uri.address) {
- var config = configService.getSync().wallet.settings;
- var unitToSatoshi = config.unitToSatoshi;
- var satToUnit = 1 / unitToSatoshi;
- var unitName = config.unitName;
+ if (uri && uri.address) {
+ var config = configService.getSync().wallet.settings;
+ var unitToSatoshi = config.unitToSatoshi;
+ var satToUnit = 1 / unitToSatoshi;
+ var unitName = config.unitName;
- uri.amount = strip(uri.amount * satToUnit) + ' ' + unitName;
- return uri;
- }
- };
+ uri.amount = strip(uri.amount * satToUnit) + ' ' + unitName;
+ uri.network = uri.address.network.name;
+ return uri;
+ }
+ };
- this.getWallets = function() {
- if (!profileService.profile) return;
- var config = configService.getSync();
- config.colorFor = config.colorFor || {};
- var ret = lodash.map(profileService.profile.credentials, function(c) {
- return {
- m: c.m,
- n: c.n,
- name: c.walletName,
- id: c.walletId,
- color: config.colorFor[c.walletId] || '#2C3E50'
- };
- });
- return lodash.sortBy(ret, 'walletName');
- };
+ this.getWallets = function(network) {
+ if (!profileService.profile) return;
+ var config = configService.getSync();
+ config.colorFor = config.colorFor || {};
+ var ret = lodash.map(profileService.profile.credentials, function(c) {
+ return {
+ m: c.m,
+ n: c.n,
+ name: c.walletName,
+ id: c.walletId,
+ network: c.network,
+ color: config.colorFor[c.walletId] || '#2C3E50'
+ };
+ });
+ ret = lodash.filter(ret, function(w) {
+ return (w.network == network);
+ });
+ return lodash.sortBy(ret, 'walletName');
+ };
- this.selectWallet = function(wid) {
- var self = this;
- if (wid != profileService.focusedClient.credentials.walletId) {
- profileService.setAndStoreFocus(wid, function() {});
- }
- go.send();
- $timeout(function() {
- $rootScope.$emit('paymentUri', self.bitcoinURI);
- }, 100);
- };
- });
+ this.selectWallet = function(wid) {
+ var self = this;
+ if (wid != profileService.focusedClient.credentials.walletId) {
+ profileService.setAndStoreFocus(wid, function() {});
+ }
+ go.send();
+ $timeout(function() {
+ $rootScope.$emit('paymentUri', self.bitcoinURI);
+ }, 100);
+ };
+ });
diff --git a/src/js/services/go.js b/src/js/services/go.js
index 931f9fe74..71482e8c9 100644
--- a/src/js/services/go.js
+++ b/src/js/services/go.js
@@ -36,8 +36,11 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
var ref = window.open(url, '_blank', 'location=no');
};
- root.path = function(path) {
- $state.transitionTo(path);
+ root.path = function(path, cb) {
+ $state.transitionTo(path)
+ .then(function() {
+ if (cb) return cb();
+ });
hideSidebars();
};
@@ -51,15 +54,17 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
if (fc && !fc.isComplete()) {
root.path('copayers');
} else {
- root.path('walletHome');
- $rootScope.$emit('Local/SetTab', 'walletHome');
+ root.path('walletHome', function() {
+ $rootScope.$emit('Local/SetTab', 'walletHome');
+ });
}
};
root.send = function() {
- root.path('walletHome');
- $rootScope.$emit('Local/SetTab', 'walletHome');
+ root.path('walletHome', function() {
+ $rootScope.$emit('Local/SetTab', 'send');
+ });
};
root.home = function() {