Tidied up third party data from BIP70 Payment Protocol.

This commit is contained in:
Brendon Duncan 2018-08-06 20:31:06 +12:00
commit f1f8f6e0f5
5 changed files with 22 additions and 17 deletions

View file

@ -4,7 +4,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
var fromWalletId = '';
var priceDisplayAsFiat = false;
var requestedSatoshis = 0;
var unitDecimals = 0;
var unitsFromSatoshis = 0;
@ -39,8 +38,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
if ($scope.params.amount) { // There is an amount, so presume that it is a payment request
$scope.sendFlowTitle = gettextCatalog.getString('Payment Request');
$scope.specificAmount = $scope.specificAlternativeAmount = '';
//requestedAmountCrypto = (($state.params.amount) * (1 / config.unitToSatoshi)).toFixed(config.unitDecimals);
requestedSatoshis = $state.params.amount;
$scope.isPaymentRequest = true;
}
if ($scope.params.thirdParty) {
@ -64,11 +61,11 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
});
function formatRequestedAmount() {
if (requestedSatoshis) {
var cryptoAmount = (unitsFromSatoshis * requestedSatoshis).toFixed(unitDecimals);
if ($scope.params.amount) {
var cryptoAmount = (unitsFromSatoshis * $scope.params.amount).toFixed(unitDecimals);
var cryptoCoin = $scope.coin.toUpperCase();
txFormatService.formatAlternativeStr($scope.coin, requestedSatoshis, function onFormatAlternativeStr(formatted){
txFormatService.formatAlternativeStr($scope.coin, $scope.params.amount, function onFormatAlternativeStr(formatted){
if (formatted) {
var fiatParts = formatted.split(' ');
var fiatAmount = fiatParts[0];
@ -107,12 +104,9 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
function handleThirdPartyIfBip70PaymentProtocol() {
if ($scope.thirdParty.id === 'bip70PaymentProtocol') {
requestedSatoshis = $scope.thirdParty.details.amount;
$scope.coin = $scope.thirdParty.coin;
$scope.requestAmount = unitsFromSatoshis * requestedSatoshis;
$scope.params.amount = requestedSatoshis;
$scope.params.toAddr = $scope.thirdParty.details.toAddress;
console.log('paypro details:', $scope.thirdParty.details);
$scope.requestAmount = unitsFromSatoshis * $scope.params.amount;
console.log('paypro details:', $scope.thirdParty);
}
}