Fix tab-send to send BCH or BTC from address book entry

This commit is contained in:
Gustavo Maximiliano Cortez 2017-09-19 11:28:03 -04:00
commit 31029bc17a
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, bwcError, gettextCatalog, scannerService) {
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, bwcError, gettextCatalog, scannerService, bitcoreCash) {
var originalList;
var CONTACTS_SHOW_LIMIT;
@ -86,6 +86,14 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}
}
var getCoin = function(address) {
var cashAddress = bitcoreCash.Address.isValid(address, 'livenet');
if (cashAddress) {
return 'bch';
}
return 'btc';
};
var updateContactsList = function(cb) {
addressbookService.list(function(err, ab) {
if (err) $log.error(err);
@ -100,6 +108,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
address: k,
email: lodash.isObject(v) ? v.email : null,
recipientType: 'contact',
coin: getCoin(k),
getAddress: function(cb) {
return cb(null, k);
},