From b65da992c7c289ae3f4f02b2a9c1bcbaf4ea56eb Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 15 May 2018 09:58:05 +0200 Subject: [PATCH 1/5] Improvement - 321 - "Search transactions" doesn't work with BCH prefix --- src/js/controllers/modals/search.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 3d5ae366e..375e69aec 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -29,6 +29,7 @@ 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 (tx.amountUnitStr === 'BCH' && addressTo) addressTo = 'bitcoincash:'+addressTo; var txid = tx.txid ? tx.txid : ''; return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment + txid).toString()).toLowerCase(); } From 31f50ad0cb594c3239c78d2c12b6fb0ff174c073 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 16 May 2018 13:50:25 +0200 Subject: [PATCH 2/5] Fixes for CashAddr, includes validation of address, adds cashaddr to search string next to legacy address --- src/js/controllers/modals/search.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 375e69aec..58ef3fa24 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -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,7 +29,16 @@ 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 (tx.amountUnitStr === 'BCH' && addressTo) addressTo = 'bitcoincash:'+addressTo; + + if ($scope.wallet.coin === 'bch' && addressTo) { + try { + var addr = bitcoinCashJsService.readAddress(addressTo); + if (addr !== null) addressTo = addressTo + ' bitcoincash:'+addr.cashaddr; + } catch (e) { + $log.debug(addressTo+' not a valid address.. continuing..'); + } + } + var txid = tx.txid ? tx.txid : ''; return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment + txid).toString()).toLowerCase(); } From cdb9b54b5884057e194636bf1150ccedb4e527f3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Thu, 17 May 2018 19:30:06 +0900 Subject: [PATCH 3/5] Fix - 321 - Add the three addresses (legacy+bitpay+bch) in the searchable string --- src/js/controllers/modals/search.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 58ef3fa24..2187b4353 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -30,13 +30,25 @@ angular.module('copayApp.controllers').controller('searchController', function($ var comment = tx.note ? tx.note.body : ''; var addressTo = tx.addressTo ? tx.addressTo : ''; - if ($scope.wallet.coin === 'bch' && addressTo) { - try { - var addr = bitcoinCashJsService.readAddress(addressTo); - if (addr !== null) addressTo = addressTo + ' bitcoincash:'+addr.cashaddr; - } catch (e) { - $log.debug(addressTo+' not a valid address.. continuing..'); - } + if ($scope.wallet.coin === 'bch') { + + /** + * One tx in JSON + * {"txid":"97ed105ea5042a328b68da43439b4..","action":"received","amount":730216,"fees":392,"time":1525661853,"confirmations":1459,"feePerKb":1074,"outputs":[{"amount":730216,"address":"19zA4aP1sAavtHF2wJcMpi..","message":null}],"message":null,"creatorName":"","hasUnconfirmedInputs":false,"amountStr":"0.00730216 BCH","alternativeAmountStr":"7.95 EUR","feeStr":"0.00000392 BCH","amountValueStr":"0.00730216","amountUnitStr":"BCH","safeConfirmed":"6+","lowAmount":false} + * These two lines should be removed.. because tx.addressTo does not exist. + * The address is in tx.outputs[..].address, cf. the JSON + */ + var addr = bitcoinCashJsService.translateAddresses(addressTo); + addressTo = addr.legacy + addr.bitpay + 'bitcoincash:' + addr.cashaddr + + /** + * For each address (normally only one) + * 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 : ''; From f7e090cd20cedec77b76de020960fb08b206478e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Thu, 17 May 2018 19:37:18 +0900 Subject: [PATCH 4/5] Fix - 321 - Forgot a condition to check the translation --- src/js/controllers/modals/search.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 2187b4353..b6b0c3163 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -38,8 +38,10 @@ angular.module('copayApp.controllers').controller('searchController', function($ * These two lines should be removed.. because tx.addressTo does not exist. * The address is in tx.outputs[..].address, cf. the JSON */ - var addr = bitcoinCashJsService.translateAddresses(addressTo); - addressTo = addr.legacy + addr.bitpay + 'bitcoincash:' + addr.cashaddr + if (addressTo) { + var addr = bitcoinCashJsService.translateAddresses(addressTo); + addressTo = addr.legacy + addr.bitpay + 'bitcoincash:' + addr.cashaddr + } /** * For each address (normally only one) From 01b1c6753fc17b2412bc110a8a29150ff2cc21a6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Thu, 17 May 2018 20:16:41 +0900 Subject: [PATCH 5/5] Fix - 321 - Keep only the fetching in the outputs --- src/js/controllers/modals/search.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index b6b0c3163..cd5399a02 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -33,18 +33,7 @@ angular.module('copayApp.controllers').controller('searchController', function($ if ($scope.wallet.coin === 'bch') { /** - * One tx in JSON - * {"txid":"97ed105ea5042a328b68da43439b4..","action":"received","amount":730216,"fees":392,"time":1525661853,"confirmations":1459,"feePerKb":1074,"outputs":[{"amount":730216,"address":"19zA4aP1sAavtHF2wJcMpi..","message":null}],"message":null,"creatorName":"","hasUnconfirmedInputs":false,"amountStr":"0.00730216 BCH","alternativeAmountStr":"7.95 EUR","feeStr":"0.00000392 BCH","amountValueStr":"0.00730216","amountUnitStr":"BCH","safeConfirmed":"6+","lowAmount":false} - * These two lines should be removed.. because tx.addressTo does not exist. - * The address is in tx.outputs[..].address, cf. the JSON - */ - if (addressTo) { - var addr = bitcoinCashJsService.translateAddresses(addressTo); - addressTo = addr.legacy + addr.bitpay + 'bitcoincash:' + addr.cashaddr - } - - /** - * For each address (normally only one) + * 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) {