mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-23 12:39:23 +00:00
tolerate errors resuming from standby
This commit is contained in:
parent
7de40e2c33
commit
b3c607152d
3 changed files with 35 additions and 9 deletions
|
@ -853,7 +853,12 @@ public class XmrWalletService {
|
||||||
UserThread.execute(new Runnable() { // TODO (woodser): don't execute on UserThread
|
UserThread.execute(new Runnable() { // TODO (woodser): don't execute on UserThread
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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) {
|
public BigInteger getAvailableBalanceForSubaddress(int subaddressIndex) {
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
|
if (wallet == null) throw new IllegalStateException("Cannot get available balance for subaddress because main wallet is null");
|
||||||
return wallet.getUnlockedBalance(0, subaddressIndex);
|
return wallet.getUnlockedBalance(0, subaddressIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getBalance() {
|
public BigInteger getBalance() {
|
||||||
if (wallet == null) return BigInteger.valueOf(0);
|
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
|
if (wallet == null) throw new IllegalStateException("Cannot get balance because main wallet is null");
|
||||||
return wallet.getBalance(0);
|
return wallet.getBalance(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getAvailableBalance() {
|
public BigInteger getAvailableBalance() {
|
||||||
if (wallet == null) return BigInteger.valueOf(0);
|
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
|
if (wallet == null) throw new IllegalStateException("Cannot get available balance because main wallet is null");
|
||||||
return wallet.getUnlockedBalance(0);
|
return wallet.getUnlockedBalance(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,11 +133,18 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
||||||
confirmationsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations")));
|
confirmationsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations")));
|
||||||
usageColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.usage")));
|
usageColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.usage")));
|
||||||
|
|
||||||
// prefetch all incoming txs to avoid query per subaddress
|
// try to initialize with wallet txs
|
||||||
txsWithIncomingOutputs = xmrWalletService.getTxsWithIncomingOutputs();
|
try {
|
||||||
|
|
||||||
// trigger creation of at least 1 address
|
// prefetch all incoming txs to avoid query per subaddress
|
||||||
xmrWalletService.getFreshAddressEntry(txsWithIncomingOutputs);
|
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.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.deposit.noAddresses")));
|
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.deposit.noAddresses")));
|
||||||
|
@ -237,7 +244,13 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
||||||
tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener);
|
tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener);
|
||||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
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.addBalanceListener(balanceListener);
|
||||||
xmrWalletService.addWalletListener(walletListener);
|
xmrWalletService.addWalletListener(walletListener);
|
||||||
|
|
|
@ -185,7 +185,14 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
sortedDisplayedTransactions.comparatorProperty().bind(tableView.comparatorProperty());
|
sortedDisplayedTransactions.comparatorProperty().bind(tableView.comparatorProperty());
|
||||||
tableView.setItems(sortedDisplayedTransactions);
|
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);
|
xmrWalletService.addWalletListener(transactionsUpdater);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue