From 31029bc17ae9ac070295649358dc60d9ea68ade9 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 19 Sep 2017 11:28:03 -0400 Subject: [PATCH] Fix tab-send to send BCH or BTC from address book entry --- src/js/controllers/tab-send.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/controllers/tab-send.js b/src/js/controllers/tab-send.js index 77a664632..229d23c2a 100644 --- a/src/js/controllers/tab-send.js +++ b/src/js/controllers/tab-send.js @@ -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); },