diff --git a/currency.js b/currency.js index deecbd31..f8afcd9c 100644 --- a/currency.js +++ b/currency.js @@ -93,21 +93,10 @@ function satoshiToLocalCurrency(satoshi) { } function BTCToLocalCurrency(bitcoin) { - if (!lang[STRUCT[preferredFiatCurrency.storageKey]]) return bitcoin; + let sat = new BigNumber(bitcoin); + sat = sat.multipliedBy(100000000).toNumber(); - let b = new BigNumber(bitcoin); - b = b - .multipliedBy(1) - .multipliedBy(lang[STRUCT[preferredFiatCurrency.storageKey]]) - .toString(10); - b = parseFloat(b).toFixed(2); - - const formatter = new Intl.NumberFormat('en-US', { - style: 'currency', - currency: preferredFiatCurrency.formatterValue, - minimumFractionDigits: 2, - }); - return formatter.format(b); + return satoshiToLocalCurrency(sat); } function satoshiToBTC(satoshi) { diff --git a/loc/index.js b/loc/index.js index c0e1e7cc..c2122f0f 100644 --- a/loc/index.js +++ b/loc/index.js @@ -78,7 +78,7 @@ function removeTrailingZeros(value) { /** * * @param balance {Number} Float amount of bitcoins - * @param unit {String} Value from models/bitcoinUnits.js + * @param toUnit {String} Value from models/bitcoinUnits.js * @returns {string} */ strings.formatBalance = (balance, toUnit) => { @@ -95,6 +95,12 @@ strings.formatBalance = (balance, toUnit) => { } }; +/** + * + * @param balance {Integer} Satoshis + * @param toUnit {String} Value from models/bitcoinUnits.js + * @returns {string} + */ strings.formatBalanceWithoutSuffix = (balance, toUnit) => { if (toUnit === undefined) { return balance;