fixed request specific amount

This commit is contained in:
Kadir Sekha 2018-01-15 17:45:06 +09:00
commit 404a694c55
3 changed files with 50 additions and 8 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $ionicHistory, txFormatService, platformInfo, configService, profileService, walletService, popupService) {
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $ionicHistory, txFormatService, platformInfo, configService, profileService, walletService, popupService, bitcoinCashJsService) {
var showErrorAndBack = function(title, msg) {
popupService.showAlert(title, msg, function() {
@ -32,7 +32,20 @@ angular.module('copayApp.controllers').controller('customAmountController', func
return;
}
$scope.address = addr;
$scope.bchAddressType = 'cashaddr';
var bchAddresses = {};
if ($scope.wallet.coin == 'bch') {
bchAddresses = bitcoinCashJsService.translateAddresses(addr);
$scope.address = bchAddresses[$scope.bchAddressType];
} else {
$scope.address = addr;
}
$scope.displayAddress = function(type) {
$scope.bchAddressType = type;
$scope.address = bchAddresses[$scope.bchAddressType];
}
$scope.coin = data.stateParams.coin;
var parsedAmount = txFormatService.parseAmount(
@ -76,9 +89,11 @@ angular.module('copayApp.controllers').controller('customAmountController', func
}
$scope.copyToClipboard = function() {
var protocol = 'bitcoin';
if ($scope.wallet.coin == 'bch') protocol += 'cash';
return protocol + ':' + $scope.address + '?amount=' + $scope.amountBtc;
var protocol = '';
if ($scope.wallet.coin == 'bch' && $scope.bchAddressType == 'cashaddr') {
protocol = 'bitcoincash:';
}
return protocol + $scope.address + '?amount=' + $scope.amountBtc;
};
});

View file

@ -13,10 +13,17 @@
font-size: 26px;
}
}
.button-address {
margin-top: 10px;
background: transparent;
border: none;
font-size: 12px;
color: $v-text-accent-color;
}
.address {
background: #fff;
overflow: auto;
height: 100%;
height: 100%;
.qr-code {
text-align: center;
margin-top: 24vh;
@ -31,7 +38,7 @@
margin-top: 8vh;
}
}
.info {
.info {
position: absolute;
width: 100%;
bottom: 0;
@ -81,5 +88,8 @@
}
}
}
.address-types {
text-align: center;
}
}
}

View file

@ -23,8 +23,25 @@
<div class="qr-code" copy-to-clipboard="copyToClipboard()">
<qrcode size="220" data="{{ protocolHandler }}:{{address + '?amount=' + amountBtc}}" color="#334"></qrcode>
</div>
<div ng-show="address && coin == 'bch'" class="address-types">
<div>
<button ng-show="address && coin == 'bch' && bchAddressType != 'cashaddr'" class="button-address" ng-click="displayAddress('cashaddr')">
<span translate>Display new style address</span>
</button>
</div>
<div>
<button ng-show="address && coin == 'bch' && bchAddressType != 'legacy'" class="button-address" ng-click="displayAddress('legacy')">
<span translate>Display legacy address</span>
</button>
</div>
<div>
<button ng-show="address && coin == 'bch' && bchAddressType != 'bitpay'" class="button-address" ng-click="displayAddress('bitpay')">
<span translate>Display BitPay address</span>
</button>
</div>
</div>
<div class="info">
<div class="item single-line" copy-to-clipboard="address">
<div class="item single-line" copy-to-clipboard="(coin == 'bch' && bchAddressType == 'cashaddr' ? 'bitcoincash:' : '') + address">
<span class="label" translate>Address</span>
<span class="item-note ellipsis">
{{address}}