display new bitcoin cash address type in payment proposal window

This commit is contained in:
Kadir Sekha 2018-02-07 15:46:21 -04:00
commit f496383ecb
2 changed files with 26 additions and 3 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $log, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, bwcError, gettextCatalog, lodash, walletService, popupService, $ionicHistory, feeService) {
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $log, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, bwcError, gettextCatalog, lodash, walletService, popupService, $ionicHistory, feeService, bitcoinCashJsService) {
var isGlidera = $scope.isGlidera;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var now = Math.floor(Date.now() / 1000);
@ -20,8 +20,20 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
initActionList();
checkPaypro();
applyButtonText();
$scope.addressDisplayType = 'legacy';
$scope.toAddresses = { 'legacy': $scope.tx.toAddress }
if ($scope.tx.coin == 'bch') {
var cashAddr = bitcoinCashJsService.translateAddresses($scope.tx.toAddress).cashaddr;
$scope.toAddresses['cashAddr'] = cashAddr;
$scope.addressDisplayType = 'cashAddr';
}
};
$scope.changeAddressDisplayType = function(type) {
$scope.addressDisplayType = type;
}
function displayFeeValues() {
txFormatService.formatAlternativeStr($scope.wallet.coin, $scope.tx.fee, function(v) {
$scope.tx.feeFiatStr = v;

View file

@ -51,11 +51,22 @@
<div class="info">
<div class="item">
<span class="label" translate>To</span>
<span class="payment-proposal-to" copy-to-clipboard="tx.toAddress">
<span class="payment-proposal-to" ng-if="addressDisplayType == 'cashAddr'" copy-to-clipboard="'bitcoincash:' + toAddresses['cashAddr']">
<img src="img/icon-bitcoin-small.svg">
<contact ng-if="!tx.hasMultiplesOutputs" class="ellipsis" address="{{tx.toAddress}}"></contact>
<contact ng-if="!tx.hasMultiplesOutputs" class="ellipsis" address="{{toAddresses['cashAddr']}}"></contact>
<span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span>
</span>
<span class="payment-proposal-to" ng-if="addressDisplayType == 'legacy'" copy-to-clipboard="toAddresses['legacy']">
<img src="img/icon-bitcoin-small.svg">
<contact ng-if="!tx.hasMultiplesOutputs" class="ellipsis" address="{{toAddresses['legacy']}}"></contact>
<span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span>
</span>
<button class="address-info button-address" ng-if="addressDisplayType === 'cashAddr'" ng-click="changeAddressDisplayType('legacy')">
<span translate>Display legacy address</span>
</button>
<button class="address-info button-address" ng-if="addressDisplayType === 'legacy'" ng-click="changeAddressDisplayType('cashAddr')">
<span translate>Display new style address</span>
</button>
</div>
<div ng-show="tx.hasMultiplesOutputs" class="item" ng-click="showMultiplesOutputs = !showMultiplesOutputs">