Fix rateService. Add usd rates
This commit is contained in:
parent
09d1d5d3ff
commit
a5a80684eb
19 changed files with 87 additions and 80 deletions
|
|
@ -83,9 +83,9 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
$scope.lowWarning = resp.warning;
|
||||
$scope.lowUtxosNb = resp.lowUtxos.length;
|
||||
$scope.allUtxosNb = resp.allUtxos.length;
|
||||
$scope.lowUtxosSum = txFormatService.formatAmountStr($scope.wallet, lodash.sum(resp.lowUtxos || 0, 'satoshis'));
|
||||
$scope.allUtxosSum = txFormatService.formatAmountStr($scope.wallet, allSum);
|
||||
$scope.minFee = txFormatService.formatAmountStr($scope.wallet, resp.minFee || 0);
|
||||
$scope.lowUtxosSum = txFormatService.formatAmountStr($scope.wallet.coin, lodash.sum(resp.lowUtxos || 0, 'satoshis'));
|
||||
$scope.allUtxosSum = txFormatService.formatAmountStr($scope.wallet.coin, allSum);
|
||||
$scope.minFee = txFormatService.formatAmountStr($scope.wallet.coin, resp.minFee || 0);
|
||||
$scope.minFeePer = per.toFixed(2) + '%';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -200,11 +200,11 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
};
|
||||
|
||||
function fromFiat(val) {
|
||||
return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals));
|
||||
return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode, $scope.coin) * satToUnit).toFixed(unitDecimals));
|
||||
};
|
||||
|
||||
function toFiat(val) {
|
||||
return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2));
|
||||
return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode, $scope.coin)).toFixed(2));
|
||||
};
|
||||
|
||||
function evaluate(val) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('buyAmazonController', function($scope, $log, $state, $timeout, $filter, $ionicHistory, $ionicConfig, lodash, amazonService, popupService, profileService, ongoingProcess, configService, walletService, payproService, bwcError, externalLinkService, platformInfo, gettextCatalog, txFormatService) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
var createdTx;
|
||||
|
|
@ -64,7 +65,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
|||
};
|
||||
|
||||
var satToFiat = function(sat, cb) {
|
||||
txFormatService.toFiat(sat, $scope.currencyIsoCode, function(value) {
|
||||
txFormatService.toFiat(coin, sat, $scope.currencyIsoCode, function(value) {
|
||||
return cb(value);
|
||||
});
|
||||
};
|
||||
|
|
@ -216,7 +217,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
|||
});
|
||||
|
||||
var initialize = function(wallet) {
|
||||
var parsedAmount = txFormatService.parseAmount(wallet, amount, currency);
|
||||
var parsedAmount = txFormatService.parseAmount(coin, amount, currency);
|
||||
$scope.currencyIsoCode = parsedAmount.currency;
|
||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||
var dataSrc = {
|
||||
|
|
@ -260,7 +261,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
|||
invoiceUrl: invoice.url,
|
||||
invoiceTime: invoice.invoiceTime
|
||||
};
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(wallet, ctxp.amount);
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(coin, ctxp.amount);
|
||||
setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
|
||||
});
|
||||
});
|
||||
|
|
@ -293,7 +294,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
|||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
hasFunds: true,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack(null, gettextCatalog.getString('No wallets available'));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('buyCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicConfig, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, txFormatService) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
|||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
|
|
@ -236,7 +237,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
|||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
wallet,
|
||||
coin,
|
||||
amount,
|
||||
currency);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, platformInfo, txFormatService) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
|||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
|
|
@ -161,7 +162,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
|||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
wallet,
|
||||
coin,
|
||||
amount,
|
||||
currency);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('buyMercadoLibreController', function($scope, $log, $state, $timeout, $filter, $ionicHistory, $ionicConfig, lodash, mercadoLibreService, popupService, profileService, ongoingProcess, configService, walletService, payproService, bwcError, externalLinkService, platformInfo, txFormatService, gettextCatalog) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
var createdTx;
|
||||
|
|
@ -64,7 +65,7 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
|
|||
};
|
||||
|
||||
var satToFiat = function(sat, cb) {
|
||||
txFormatService.toFiat(sat, $scope.currencyIsoCode, function(value) {
|
||||
txFormatService.toFiat(coin, sat, $scope.currencyIsoCode, function(value) {
|
||||
return cb(value);
|
||||
});
|
||||
};
|
||||
|
|
@ -214,7 +215,7 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
|
|||
});
|
||||
|
||||
var initialize = function(wallet) {
|
||||
var parsedAmount = txFormatService.parseAmount(wallet, amount, currency);
|
||||
var parsedAmount = txFormatService.parseAmount(coin, amount, currency);
|
||||
$scope.currencyIsoCode = parsedAmount.currency;
|
||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||
var dataSrc = {
|
||||
|
|
@ -258,7 +259,7 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
|
|||
invoiceUrl: invoice.url,
|
||||
invoiceTime: invoice.invoiceTime
|
||||
};
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(wallet, ctxp.amount);
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(coin, ctxp.amount);
|
||||
setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
|
||||
});
|
||||
});
|
||||
|
|
@ -285,7 +286,7 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
|
|||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack(null, gettextCatalog.getString('No wallets available'));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification) {
|
||||
|
||||
var countDown = null;
|
||||
var CONFIRM_LIMIT_USD = 20;
|
||||
|
|
@ -238,10 +238,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
if (!tx.toAmount) return;
|
||||
|
||||
// Amount
|
||||
tx.amountStr = txFormatService.formatAmountStr(wallet, tx.toAmount);
|
||||
tx.amountStr = txFormatService.formatAmountStr(wallet.coin, tx.toAmount);
|
||||
tx.amountValueStr = tx.amountStr.split(' ')[0];
|
||||
tx.amountUnitStr = tx.amountStr.split(' ')[1];
|
||||
txFormatService.formatAlternativeStr(tx.toAmount, function(v) {
|
||||
txFormatService.formatAlternativeStr(wallet.coin, tx.toAmount, function(v) {
|
||||
tx.alternativeAmountStr = v;
|
||||
});
|
||||
}
|
||||
|
|
@ -292,8 +292,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) {
|
||||
if (err) return cb(err);
|
||||
|
||||
txp.feeStr = txFormatService.formatAmountStr(wallet, txp.fee);
|
||||
txFormatService.formatAlternativeStr(txp.fee, function(v) {
|
||||
txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee);
|
||||
txFormatService.formatAlternativeStr(wallet.coin, txp.fee, function(v) {
|
||||
txp.alternativeFeeStr = v;
|
||||
});
|
||||
|
||||
|
|
@ -343,20 +343,20 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var warningMsg = [];
|
||||
if (sendMaxInfo.utxosBelowFee > 0) {
|
||||
warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
|
||||
amountBelowFeeStr: txFormatService.formatAmountStr(wallet, sendMaxInfo.amountBelowFee)
|
||||
amountBelowFeeStr: txFormatService.formatAmountStr(wallet.coin, sendMaxInfo.amountBelowFee)
|
||||
}));
|
||||
}
|
||||
|
||||
if (sendMaxInfo.utxosAboveMaxSize > 0) {
|
||||
warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded.", {
|
||||
amountAboveMaxSizeStr: txFormatService.formatAmountStr(wallet, sendMaxInfo.amountAboveMaxSize)
|
||||
amountAboveMaxSizeStr: txFormatService.formatAmountStr(wallet.coin, sendMaxInfo.amountAboveMaxSize)
|
||||
}));
|
||||
}
|
||||
return warningMsg.join('\n');
|
||||
};
|
||||
|
||||
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees.", {
|
||||
fee: txFormatService.formatAmountStr(wallet, sendMaxInfo.fee)
|
||||
fee: txFormatService.formatAmountStr(wallet.coin, sendMaxInfo.fee)
|
||||
});
|
||||
var warningMsg = verifyExcludedUtxos();
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
if (walletService.isEncrypted(wallet))
|
||||
return cb();
|
||||
|
||||
var amountUsd = parseFloat(txFormatService.formatToUSD(txp.amount));
|
||||
var amountUsd = parseFloat(txFormatService.formatToUSD(wallet.coin, txp.amount));
|
||||
if (amountUsd <= CONFIRM_LIMIT_USD)
|
||||
return cb();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ angular.module('copayApp.controllers').controller('customAmountController', func
|
|||
|
||||
$scope.address = addr;
|
||||
|
||||
$scope.coin = (data.stateParams.coin).toLowerCase();
|
||||
$scope.coin = data.stateParams.coin;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
$scope.wallet,
|
||||
$scope.wallet.coin,
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
|
|
@ -43,13 +43,13 @@ angular.module('copayApp.controllers').controller('customAmountController', func
|
|||
// Convert to BTC or BCH
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var amountUnit = txFormatService.satToUnit(parsedAmount.amountSat);
|
||||
var btcParsedAmount = txFormatService.parseAmount($scope.wallet, amountUnit, $scope.wallet.coin);
|
||||
var btcParsedAmount = txFormatService.parseAmount($scope.wallet.coin, amountUnit, $scope.wallet.coin);
|
||||
|
||||
$scope.amountBtc = btcParsedAmount.amount;
|
||||
$scope.altAmountStr = btcParsedAmount.amountUnitStr;
|
||||
} else {
|
||||
$scope.amountBtc = amount; // BTC or BCH
|
||||
$scope.altAmountStr = txFormatService.formatAlternativeStr(parsedAmount.amountSat);
|
||||
$scope.altAmountStr = txFormatService.formatAlternativeStr($scope.wallet.coin, parsedAmount.amountSat);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -63,12 +63,12 @@ angular.module('copayApp.controllers').controller('customAmountController', func
|
|||
|
||||
$scope.shareAddress = function() {
|
||||
if (!platformInfo.isCordova) return;
|
||||
var data = 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc;
|
||||
var data = 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc + '&coin=' + $scope.wallet.coin;
|
||||
window.plugins.socialsharing.share(data, null, null, null);
|
||||
}
|
||||
|
||||
$scope.copyToClipboard = function() {
|
||||
return 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc + '&coin=' + $scope.coin;
|
||||
return 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc + '&coin=' + $scope.wallet.coin;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
};
|
||||
|
||||
function displayFeeValues() {
|
||||
txFormatService.formatAlternativeStr($scope.tx.fee, function(v) {
|
||||
txFormatService.formatAlternativeStr($scope.wallet.coin, $scope.tx.fee, function(v) {
|
||||
$scope.tx.feeFiatStr = v;
|
||||
});
|
||||
$scope.tx.feeRateStr = ($scope.tx.fee / ($scope.tx.amount + $scope.tx.fee) * 100).toFixed(2) + '%';
|
||||
|
|
@ -219,7 +219,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
copayerId: $scope.wallet.credentials.copayerId
|
||||
});
|
||||
|
||||
$scope.tx = txFormatService.processTx($scope.wallet, tx);
|
||||
$scope.tx = txFormatService.processTx($scope.wallet.coin, tx);
|
||||
|
||||
if (!action && tx.status == 'pending')
|
||||
$scope.tx.pendingForUs = true;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ angular.module('copayApp.controllers').controller('tourController',
|
|||
rateService.whenAvailable(function() {
|
||||
var localCurrency = 'USD';
|
||||
var btcAmount = 1;
|
||||
var rate = rateService.toFiat(btcAmount * 1e8, localCurrency);
|
||||
var rate = rateService.toFiat(btcAmount * 1e8, localCurrency, 'btc');
|
||||
$scope.localCurrencySymbol = '$';
|
||||
$scope.localCurrencyPerBtc = $filter('formatFiatAmount')(parseFloat(rate.toFixed(2), 10));
|
||||
$timeout(function() {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
|
|||
$scope.balanceSat = balance;
|
||||
if ($scope.balanceSat <= 0)
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not funds found'));
|
||||
var config = configService.getSync().wallet.settings;
|
||||
$scope.balance = txFormatService.formatAmount(balance) + ' ' + config.unitName;
|
||||
$scope.balance = txFormatService.formatAmountStr($scope.wallet.coin, balance);
|
||||
}
|
||||
$scope.$apply();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('sellCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicConfig, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, appConfigService, configService, txFormatService) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
|||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
hasFunds: true,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
|
|
@ -304,7 +305,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
|||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
wallet,
|
||||
coin,
|
||||
amount,
|
||||
currency);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, txFormatService) {
|
||||
|
||||
var coin = 'btc';
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
|||
onlyComplete: true,
|
||||
network: $scope.network,
|
||||
hasFunds: true,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
|
|
@ -229,7 +230,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
|||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
wallet,
|
||||
coin,
|
||||
amount,
|
||||
currency);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService, sendMaxService, gettextCatalog) {
|
||||
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
var coin = 'btc';
|
||||
var cardId;
|
||||
var useSendMax;
|
||||
var amount;
|
||||
|
|
@ -36,7 +37,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
};
|
||||
|
||||
var satToFiat = function(sat, cb) {
|
||||
txFormatService.toFiat(sat, $scope.currencyIsoCode, function(value) {
|
||||
txFormatService.toFiat(coin, sat, $scope.currencyIsoCode, function(value) {
|
||||
return cb(value);
|
||||
});
|
||||
};
|
||||
|
|
@ -218,7 +219,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
// Save TX in memory
|
||||
createdTx = ctxp;
|
||||
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(wallet, ctxp.amount);
|
||||
$scope.totalAmountStr = txFormatService.formatAmountStr(coin, ctxp.amount);
|
||||
|
||||
setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
|
||||
|
||||
|
|
@ -257,7 +258,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
onlyComplete: true,
|
||||
network: bitpayService.getEnvironment().network,
|
||||
hasFunds: true,
|
||||
coin: 'btc'
|
||||
coin: coin
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
|
|
@ -320,7 +321,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
});
|
||||
return;
|
||||
}
|
||||
var parsedAmount = txFormatService.parseAmount(wallet, a, c);
|
||||
var parsedAmount = txFormatService.parseAmount(coin, a, c);
|
||||
initializeTopUp(wallet, parsedAmount);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
|||
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not available at this time'));
|
||||
}
|
||||
|
||||
$scope.btx = txFormatService.processTx($scope.wallet, tx);
|
||||
txFormatService.formatAlternativeStr(tx.fees, function(v) {
|
||||
$scope.btx = txFormatService.processTx($scope.wallet.coin, tx);
|
||||
txFormatService.formatAlternativeStr($scope.wallet.coin, tx.fees, function(v) {
|
||||
$scope.btx.feeFiatStr = v;
|
||||
$scope.btx.feeRateStr = ($scope.btx.fees / ($scope.btx.amount + $scope.btx.fees) * 100).toFixed(2) + '%';
|
||||
});
|
||||
|
|
|
|||
|
|
@ -667,7 +667,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
abstract: true,
|
||||
params: {
|
||||
id: null,
|
||||
nextStep: 'tabs.paymentRequest.confirm'
|
||||
nextStep: 'tabs.paymentRequest.confirm',
|
||||
forceCoin: true
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ console.log('[rateService.js.84:retry:] BCH'); //TODO
|
|||
};
|
||||
|
||||
RateService.prototype.getRate = function(code, chain) {
|
||||
if (chain = 'bch')
|
||||
if (chain == 'bch')
|
||||
return this._ratesBCH[code];
|
||||
else
|
||||
return this._rates[code];
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
return this.Utils.formatAmount(satoshis, config.unitCode, opts);
|
||||
};
|
||||
|
||||
root.formatAmountStr = function(wallet, satoshis) {
|
||||
root.formatAmountStr = function(coin, satoshis) {
|
||||
if (isNaN(satoshis)) return;
|
||||
return root.formatAmount(satoshis) + ' ' + wallet.coin;
|
||||
return root.formatAmount(satoshis) + ' ' + coin;
|
||||
};
|
||||
|
||||
root.toFiat = function(satoshis, code, cb) {
|
||||
root.toFiat = function(coin, satoshis, code, cb) {
|
||||
if (isNaN(satoshis)) return;
|
||||
var val = function() {
|
||||
var v1 = rateService.toFiat(satoshis, code);
|
||||
var v1 = rateService.toFiat(satoshis, code, coin);
|
||||
if (!v1) return null;
|
||||
|
||||
return v1.toFixed(2);
|
||||
|
|
@ -42,10 +42,10 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
};
|
||||
};
|
||||
|
||||
root.formatToUSD = function(satoshis, cb) {
|
||||
root.formatToUSD = function(coin, satoshis, cb) {
|
||||
if (isNaN(satoshis)) return;
|
||||
var val = function() {
|
||||
var v1 = rateService.toFiat(satoshis, 'USD');
|
||||
var v1 = rateService.toFiat(satoshis, 'USD', coin);
|
||||
if (!v1) return null;
|
||||
|
||||
return v1.toFixed(2);
|
||||
|
|
@ -62,12 +62,12 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
};
|
||||
};
|
||||
|
||||
root.formatAlternativeStr = function(satoshis, cb) {
|
||||
root.formatAlternativeStr = function(coin, satoshis, cb) {
|
||||
if (isNaN(satoshis)) return;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
||||
var val = function() {
|
||||
var v1 = parseFloat((rateService.toFiat(satoshis, config.alternativeIsoCode)).toFixed(2));
|
||||
var v1 = parseFloat((rateService.toFiat(satoshis, config.alternativeIsoCode, coin)).toFixed(2));
|
||||
v1 = $filter('formatFiatAmount')(v1);
|
||||
if (!v1) return null;
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
};
|
||||
};
|
||||
|
||||
root.processTx = function(wallet, tx) {
|
||||
root.processTx = function(coin, tx) {
|
||||
if (!tx || tx.action == 'invalid')
|
||||
return tx;
|
||||
|
||||
|
|
@ -100,17 +100,17 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
tx.hasMultiplesOutputs = true;
|
||||
}
|
||||
tx.amount = lodash.reduce(tx.outputs, function(total, o) {
|
||||
o.amountStr = root.formatAmountStr(wallet, o.amount);
|
||||
o.alternativeAmountStr = root.formatAlternativeStr(o.amount);
|
||||
o.amountStr = root.formatAmountStr(coin, o.amount);
|
||||
o.alternativeAmountStr = root.formatAlternativeStr(coin, o.amount);
|
||||
return total + o.amount;
|
||||
}, 0);
|
||||
}
|
||||
tx.toAddress = tx.outputs[0].toAddress;
|
||||
}
|
||||
|
||||
tx.amountStr = root.formatAmountStr(wallet, tx.amount);
|
||||
tx.alternativeAmountStr = root.formatAlternativeStr(tx.amount);
|
||||
tx.feeStr = root.formatAmountStr(wallet, tx.fee || tx.fees);
|
||||
tx.amountStr = root.formatAmountStr(coin, tx.amount);
|
||||
tx.alternativeAmountStr = root.formatAlternativeStr(coin, tx.amount);
|
||||
tx.feeStr = root.formatAmountStr(coin, tx.fee || tx.fees);
|
||||
|
||||
if (tx.amountStr) {
|
||||
tx.amountValueStr = tx.amountStr.split(' ')[0];
|
||||
|
|
@ -154,7 +154,7 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
return;
|
||||
}
|
||||
|
||||
tx = txFormatService.processTx(tx.wallet, tx);
|
||||
tx = txFormatService.processTx(tx.wallet.coin, tx);
|
||||
|
||||
var action = lodash.find(tx.actions, {
|
||||
copayerId: tx.wallet.copayerId
|
||||
|
|
@ -179,7 +179,7 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
return txps;
|
||||
};
|
||||
|
||||
root.parseAmount = function(wallet, amount, currency) {
|
||||
root.parseAmount = function(coin, amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
|
|
@ -190,19 +190,19 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
// If fiat currency
|
||||
if (currency != 'BCH' && currency != 'BTC' && currency != 'sat') {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
amountSat = rateService.fromFiat(amount, currency).toFixed(0);
|
||||
amountSat = rateService.fromFiat(amount, currency, coin).toFixed(0);
|
||||
} else if (currency == 'sat') {
|
||||
amountSat = amount;
|
||||
amountUnitStr = root.formatAmountStr(wallet, amountSat);
|
||||
amountUnitStr = root.formatAmountStr(coin, amountSat);
|
||||
// convert sat to BTC or BCH
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = (wallet.coin).toUpperCase();
|
||||
currency = (coin).toUpperCase();
|
||||
} else {
|
||||
amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = root.formatAmountStr(wallet, amountSat);
|
||||
amountUnitStr = root.formatAmountStr(coin, amountSat);
|
||||
// convert unit to BTC or BCH
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = (wallet.coin).toUpperCase();
|
||||
currency = (coin).toUpperCase();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
lodash.each(txps, function(tx) {
|
||||
|
||||
tx = txFormatService.processTx(wallet, tx);
|
||||
tx = txFormatService.processTx(wallet.coin, tx);
|
||||
|
||||
// no future transactions...
|
||||
if (tx.createdOn > now)
|
||||
|
|
@ -237,11 +237,11 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
rateService.whenAvailable(function() {
|
||||
|
||||
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode);
|
||||
var pendingBalanceAlternative = rateService.toFiat(cache.pendingAmount, cache.alternativeIsoCode);
|
||||
var lockedBalanceAlternative = rateService.toFiat(cache.lockedBalanceSat, cache.alternativeIsoCode);
|
||||
var spendableBalanceAlternative = rateService.toFiat(cache.spendableAmount, cache.alternativeIsoCode);
|
||||
var alternativeConversionRate = rateService.toFiat(100000000, cache.alternativeIsoCode);
|
||||
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode, wallet.coin);
|
||||
var pendingBalanceAlternative = rateService.toFiat(cache.pendingAmount, cache.alternativeIsoCode, wallet.coin);
|
||||
var lockedBalanceAlternative = rateService.toFiat(cache.lockedBalanceSat, cache.alternativeIsoCode, wallet.coin);
|
||||
var spendableBalanceAlternative = rateService.toFiat(cache.spendableAmount, cache.alternativeIsoCode, wallet.coin);
|
||||
var alternativeConversionRate = rateService.toFiat(100000000, cache.alternativeIsoCode, wallet.coin);
|
||||
|
||||
cache.totalBalanceAlternative = $filter('formatFiatAmount')(totalBalanceAlternative);
|
||||
cache.pendingBalanceAlternative = $filter('formatFiatAmount')(pendingBalanceAlternative);
|
||||
|
|
@ -365,7 +365,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
wallet.hasUnsafeConfirmed = false;
|
||||
|
||||
lodash.each(txs, function(tx) {
|
||||
tx = txFormatService.processTx(wallet, tx);
|
||||
tx = txFormatService.processTx(wallet.coin, tx);
|
||||
|
||||
// no future transactions...
|
||||
if (tx.time > now)
|
||||
|
|
@ -419,8 +419,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
$log.debug('Fixing Tx Cache Unit to: ' + wallet.coin)
|
||||
lodash.each(txs, function(tx) {
|
||||
tx.amountStr = txFormatService.formatAmountStr(wallet, tx.amount);
|
||||
tx.feeStr = txFormatService.formatAmountStr(wallet, tx.fees);
|
||||
tx.amountStr = txFormatService.formatAmountStr(wallet.coin, tx.amount);
|
||||
tx.feeStr = txFormatService.formatAmountStr(wallet.coin, tx.fees);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue