be able to add contacts with a chosen currency and display it properly in the send tab

This commit is contained in:
Kadir Sekha 2017-11-02 15:40:21 +09:00
commit f4b90ae2dd
3 changed files with 21 additions and 14 deletions

View file

@ -1,13 +1,20 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookAddController', function($scope, $state, $stateParams, $timeout, $ionicHistory, gettextCatalog, addressbookService, popupService) {
angular.module('copayApp.controllers').controller('addressbookAddController', function($scope, $state, $stateParams, $timeout, $ionicHistory, gettextCatalog, addressbookService, popupService, configService) {
var config = configService.getSync();
var defaults = configService.getDefaults();
$scope.bitcoinAlias = (config.bitcoinAlias || defaults.bitcoinAlias).toUpperCase();
$scope.bitcoinCashAlias = (config.bitcoinCashAlias || defaults.bitcoinCashAlias).toUpperCase();
$scope.fromSendTab = $stateParams.fromSendTab;
$scope.addressbookEntry = {
'address': $stateParams.addressbookEntry || '',
'name': '',
'email': ''
'email': '',
'coin': 'btc'
};
$scope.onQrCodeScannedAddressBook = function(data, addressbookForm) {

View file

@ -87,15 +87,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
originalList = originalList.concat(walletList);
}
}
var getCoin = function(address) {
var cashAddress = bitcoreCash.Address.isValid(address, 'livenet');
if (cashAddress) {
return 'bch';
}
return 'btc';
};
var updateContactsList = function(cb) {
var config = configService.getSync();
var defaults = configService.getDefaults();
@ -107,14 +99,13 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var completeContacts = [];
lodash.each(ab, function(v, k) {
var c = getCoin(k);
completeContacts.push({
name: lodash.isObject(v) ? v.name : v,
address: k,
email: lodash.isObject(v) ? v.email : null,
recipientType: 'contact',
coin: c,
displayCoin: (c == 'bch'
coin: v.coin,
displayCoin: (v.coin == 'bch'
? (config.bitcoinCashAlias || defaults.bitcoinCashAlias)
: (config.bitcoinAlias || defaults.bitcoinAlias)).toUpperCase(),
getAddress: function(cb) {