Merge pull request #120 from Bitcoin-com/wallet/task/321

Improvement - 321 - "Search transactions" doesn't work with BCH prefix
This commit is contained in:
Jean-Baptiste Dominguez 2018-05-17 22:52:58 +09:00 committed by GitHub
commit 323c3c2219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) {
angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, bitcoinCashJsService) {
var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage = 0;
@ -29,6 +29,19 @@ angular.module('copayApp.controllers').controller('searchController', function($
var message = tx.message ? tx.message : '';
var comment = tx.note ? tx.note.body : '';
var addressTo = tx.addressTo ? tx.addressTo : '';
if ($scope.wallet.coin === 'bch') {
/**
* For each address
* I translate the legacy address and add in the searchable string the 3 kind of addresses
*/
lodash.each(tx.outputs, function(output) {
var addr = bitcoinCashJsService.translateAddresses(output.address);
addressTo += addr.legacy + addr.bitpay + 'bitcoincash:' + addr.cashaddr
});
}
var txid = tx.txid ? tx.txid : '';
return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment + txid).toString()).toLowerCase();
}