diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/TransactionsDialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/TransactionsDialog.java index 6966de08..5f4d08f8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/TransactionsDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/TransactionsDialog.java @@ -95,8 +95,8 @@ public class TransactionsDialog extends WalletDialog { mempoolBalance.setText(formatBitcoinValue(walletTransactionsEntry.getMempoolBalance(), true)); if(AppServices.getFiatCurrencyExchangeRate() != null) { - fiatBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getBalance(), AppServices.getFiatCurrencyExchangeRate().getBtcRate()))); - fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getMempoolBalance(), AppServices.getFiatCurrencyExchangeRate().getBtcRate()))); + fiatBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getBalance(), AppServices.getFiatCurrencyExchangeRate()))); + fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getMempoolBalance(), AppServices.getFiatCurrencyExchangeRate()))); } else { fiatBalance.setText(""); fiatMempoolBalance.setText(""); @@ -149,8 +149,8 @@ public class TransactionsDialog extends WalletDialog { public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) { SparrowTerminal.get().getGuiThread().invokeLater(() -> { WalletTransactionsEntry walletTransactionsEntry = getWalletForm().getWalletTransactionsEntry(); - fiatBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getBalance(), event.getBtcRate()))); - fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getMempoolBalance(), event.getBtcRate()))); + fiatBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getBalance(), event.getCurrencyRate()))); + fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getMempoolBalance(), event.getCurrencyRate()))); }); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java index 2fa4f9cb..039821aa 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java @@ -191,8 +191,8 @@ public class UtxosDialog extends WalletDialog { mempoolBalance.setText(formatBitcoinValue(walletUtxosEntry.getMempoolBalance(), true)); if(AppServices.getFiatCurrencyExchangeRate() != null) { - fiatBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getBalance(), AppServices.getFiatCurrencyExchangeRate().getBtcRate()))); - fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getMempoolBalance(), AppServices.getFiatCurrencyExchangeRate().getBtcRate()))); + fiatBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getBalance(), AppServices.getFiatCurrencyExchangeRate()))); + fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getMempoolBalance(), AppServices.getFiatCurrencyExchangeRate()))); } else { fiatBalance.setText(""); fiatMempoolBalance.setText(""); @@ -405,8 +405,8 @@ public class UtxosDialog extends WalletDialog { public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) { SparrowTerminal.get().getGuiThread().invokeLater(() -> { WalletUtxosEntry walletUtxosEntry = getWalletForm().getWalletUtxosEntry(); - fiatBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getBalance(), event.getBtcRate()))); - fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getMempoolBalance(), event.getBtcRate()))); + fiatBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getBalance(), event.getCurrencyRate()))); + fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getMempoolBalance(), event.getCurrencyRate()))); }); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/WalletDialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/WalletDialog.java index 906e5df7..a7d2feee 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/WalletDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/WalletDialog.java @@ -81,8 +81,12 @@ public class WalletDialog extends DialogWindow { } } - protected double getFiatValue(long satsValue, Double btcRate) { - return satsValue * btcRate / Transaction.SATOSHIS_PER_BITCOIN; + protected double getFiatValue(long satsValue, CurrencyRate currencyRate) { + if(currencyRate != null && currencyRate.isAvailable()) { + return satsValue * currencyRate.getBtcRate() / Transaction.SATOSHIS_PER_BITCOIN; + } + + return 0d; } protected static String centerPad(String text, int length) {