diff --git a/loc/index.js b/loc/index.js index db1fa914..b07733b9 100644 --- a/loc/index.js +++ b/loc/index.js @@ -70,23 +70,30 @@ strings.transactionTimeToReadable = function(time) { * @returns {string} */ strings.formatBalance = (balance, fromUnit, toUnit) => { - if (toUnit === undefined || fromUnit === toUnit) { + if (toUnit === undefined) { return balance + ' ' + BitcoinUnit.BTC; } if (balance !== 0) { + if (fromUnit === BitcoinUnit.LOCAL_CURRENCY) { + return currency.satoshiToLocalCurrency( + BTCUnits(balance, BitcoinUnit.BTC) + .to(BitcoinUnit.SATS) + .value(), + ); + } if (toUnit === BitcoinUnit.BTC) { return BTCUnits(balance, fromUnit) .to(BitcoinUnit.BTC) .format(); } else if (toUnit === BitcoinUnit.SATS) { - return BTCUnits(balance, fromUnit) + return BTCUnits(balance, BitcoinUnit.BTC) .to(BitcoinUnit.SATS) .format(); } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { return currency.satoshiToLocalCurrency( BTCUnits(balance, BitcoinUnit.BTC) .to(BitcoinUnit.SATS) - .toString(), + .value(), ); } } @@ -98,8 +105,10 @@ strings.formatBalanceWithoutSuffix = (balance, fromUnit, toUnit) => { return balance; } if (balance !== 0) { - if (fromUnit === BitcoinUnit.LOCAL_CURRENCY || toUnit === BitcoinUnit.LOCAL_CURRENCY) { - BTCUnits.setFiat(BitcoinUnit.LOCAL_CURRENCY, 3600); + if (fromUnit === BitcoinUnit.LOCAL_CURRENCY) { + return BTCUnits(balance, BitcoinUnit.SATS) + .to(BitcoinUnit.SATS) + .toString(); } if (toUnit === BitcoinUnit.BTC || toUnit === undefined) { return BTCUnits(balance, fromUnit) diff --git a/screen/wallets/scanQrWif.js b/screen/wallets/scanQrWif.js index f1359566..dc506abe 100644 --- a/screen/wallets/scanQrWif.js +++ b/screen/wallets/scanQrWif.js @@ -4,7 +4,7 @@ import { ActivityIndicator, Image, View, TouchableOpacity } from 'react-native'; import { BlueText, SafeBlueArea, BlueButton } from '../../BlueComponents'; import Camera from 'react-native-camera'; import Permissions from 'react-native-permissions'; -import {SegwitP2SHWallet, LegacyWallet, WatchOnlyWallet, HDLegacyP2PKHWallet} from '../../class'; +import { SegwitP2SHWallet, LegacyWallet, WatchOnlyWallet, HDLegacyP2PKHWallet } from '../../class'; import PropTypes from 'prop-types'; import { HDSegwitP2SHWallet } from '../../class/hd-segwit-p2sh-wallet'; import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet'; diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index a5190206..c5ac7a4b 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -183,13 +183,13 @@ export default class WalletTransactions extends Component { walletPreviousPreferredUnit = BitcoinUnit.SATS; } else if (walletPreviousPreferredUnit === BitcoinUnit.LOCAL_CURRENCY) { wallet.preferredBalanceUnit = BitcoinUnit.BTC; - walletPreviousPreferredUnit = BitcoinUnit.LOCAL_CURRENCY; + walletPreviousPreferredUnit = BitcoinUnit.BTC; } else { wallet.preferredBalanceUnit = BitcoinUnit.BTC; walletPreviousPreferredUnit = BitcoinUnit.BTC; } - this.setState({ wallet: wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit }); + this.setState({ wallet: wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit }, () => BlueApp.saveToDisk()); } renderWalletHeader = () => {