diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 90767048..8543d2f7 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -853,7 +853,12 @@ public class XmrWalletService { UserThread.execute(new Runnable() { // TODO (woodser): don't execute on UserThread @Override public void run() { - balanceListener.onBalanceChanged(balance); + try { + balanceListener.onBalanceChanged(balance); + } catch (Exception e) { + log.warn("Failed to notify balance listener of change"); + e.printStackTrace(); + } } }); } @@ -1116,20 +1121,21 @@ public class XmrWalletService { public BigInteger getAvailableBalanceForSubaddress(int subaddressIndex) { synchronized (walletLock) { + if (wallet == null) throw new IllegalStateException("Cannot get available balance for subaddress because main wallet is null"); return wallet.getUnlockedBalance(0, subaddressIndex); } } public BigInteger getBalance() { - if (wallet == null) return BigInteger.valueOf(0); synchronized (walletLock) { + if (wallet == null) throw new IllegalStateException("Cannot get balance because main wallet is null"); return wallet.getBalance(0); } } public BigInteger getAvailableBalance() { - if (wallet == null) return BigInteger.valueOf(0); synchronized (walletLock) { + if (wallet == null) throw new IllegalStateException("Cannot get available balance because main wallet is null"); return wallet.getUnlockedBalance(0); } } diff --git a/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java b/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java index 07dc3783..b68d7a76 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java @@ -133,11 +133,18 @@ public class DepositView extends ActivatableView { confirmationsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations"))); usageColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.usage"))); - // prefetch all incoming txs to avoid query per subaddress - txsWithIncomingOutputs = xmrWalletService.getTxsWithIncomingOutputs(); + // try to initialize with wallet txs + try { - // trigger creation of at least 1 address - xmrWalletService.getFreshAddressEntry(txsWithIncomingOutputs); + // prefetch all incoming txs to avoid query per subaddress + txsWithIncomingOutputs = xmrWalletService.getTxsWithIncomingOutputs(); + + // trigger creation of at least 1 address + xmrWalletService.getFreshAddressEntry(txsWithIncomingOutputs); + } catch (Exception e) { + log.warn("Failed to get wallet txs to initialize DepositView"); + e.printStackTrace(); + } tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.deposit.noAddresses"))); @@ -237,7 +244,13 @@ public class DepositView extends ActivatableView { tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); - updateList(); + // try to update deposits list + try { + updateList(); + } catch (Exception e) { + log.warn("Could not update deposits list"); + e.printStackTrace(); + } xmrWalletService.addBalanceListener(balanceListener); xmrWalletService.addWalletListener(walletListener); diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java index 7beed5d3..b620c13e 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java @@ -185,7 +185,14 @@ public class TransactionsView extends ActivatableView { protected void activate() { sortedDisplayedTransactions.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedDisplayedTransactions); - displayedTransactions.update(); + + // try to update displayed transactions + try { + displayedTransactions.update(); + } catch (Exception e) { + log.warn("Failed to update displayed transactions"); + e.printStackTrace(); + } xmrWalletService.addWalletListener(transactionsUpdater);