can now display new style address and bitpay address

This commit is contained in:
Kadir Sekha 2018-01-08 16:16:12 +09:00
commit 14fecbf1ac
3 changed files with 32 additions and 3 deletions

View file

@ -17,7 +17,7 @@ bitcoinCashJsModule.provider('bitcoinCashJsService', function() {
return { return {
'legacy': result.toString(), 'legacy': result.toString(),
'bitpay': result.toString(BitpayFormat), 'bitpay': result.toString(BitpayFormat),
'cashaddr': result.toString(CashAddrFormat) 'cashaddr': result.toString(CashAddrFormat).replace('bitcoincash:', '')
}; };
} }

View file

@ -1,8 +1,11 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError) { angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError, bitcoinCashJsService) {
var listeners = []; var listeners = [];
$scope.bchAddressType = 'cashaddr';
var bchAddresses = {};
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW; $scope.isNW = platformInfo.isNW;
@ -25,13 +28,24 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
popupService.showAlert(err); popupService.showAlert(err);
} }
$scope.addr = addr; if ($scope.wallet.coin == 'bch') {
bchAddresses = bitcoinCashJsService.translateAddresses(addr);
$scope.addr = bchAddresses[$scope.bchAddressType];
} else {
$scope.addr = addr;
}
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}, 10); }, 10);
}); });
}; };
$scope.displayAddress = function(type) {
$scope.bchAddressType = type;
$scope.addr = bchAddresses[$scope.bchAddressType];
}
$scope.goCopayers = function() { $scope.goCopayers = function() {
$ionicHistory.removeBackView(); $ionicHistory.removeBackView();
$ionicHistory.nextViewOptions({ $ionicHistory.nextViewOptions({

View file

@ -40,6 +40,21 @@
<ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner> <ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner>
</div> </div>
</div> </div>
<div>
<button ng-show="addr && wallet.coin == 'bch' && bchAddressType != 'cashaddr'" class="button-address" ng-click="displayAddress('cashaddr')">
<span translate>Display new style address</span>
</button>
</div>
<div>
<button ng-show="addr && wallet.coin == 'bch' && bchAddressType != 'legacy'" class="button-address" ng-click="displayAddress('legacy')">
<span translate>Display legacy address</span>
</button>
</div>
<div>
<button ng-show="addr && wallet.coin == 'bch' && bchAddressType != 'bitpay'" class="button-address" ng-click="displayAddress('bitpay')">
<span translate>Display BitPay address</span>
</button>
</div>
<div> <div>
<button ng-show="addr" class="button-request" ng-click="requestSpecificAmount()"> <button ng-show="addr" class="button-request" ng-click="requestSpecificAmount()">
<span translate>Request Specific amount</span> <span translate>Request Specific amount</span>