only show matching network wallet in payment intents
This commit is contained in:
parent
c769f69c4e
commit
cd901f5b3e
4 changed files with 88 additions and 66 deletions
|
|
@ -9,15 +9,18 @@
|
|||
<div class="ellipsis"><b translate>Address</b>: {{uri.address.toString()}}</div>
|
||||
<div ng-show="uri.amount"><b translate>Amount</b>: {{uri.amount}}</div>
|
||||
<div ng-show="uri.message"><b translate>Message</b>: {{uri.message}}</div>
|
||||
<div ng-show="uri.network == 'testnet'"><b translate>Network</b>: {{uri.network}}</div>
|
||||
</div>
|
||||
<h2 translate>Select a wallet</h2>
|
||||
<ul class="no-bullet" ng-init="wallets = payment.getWallets()">
|
||||
<ul class="no-bullet" ng-init="wallets = payment.getWallets(uri.network)">
|
||||
<li class="panel" ng-repeat="w in wallets">
|
||||
<a ng-click="payment.selectWallet(w.id)">
|
||||
<div class="avatar-wallet"
|
||||
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
||||
<div class="ellipsis">{{w.name || w.id}}</div>
|
||||
<div class="size-12">{{w.m}} of {{w.n}}</div>
|
||||
<div class="size-12">{{w.m}} of {{w.n}}
|
||||
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue