mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
show top error on failure to open main wallet
This commit is contained in:
parent
3b0080dbba
commit
0df4f63d53
2 changed files with 20 additions and 3 deletions
|
@ -502,4 +502,8 @@ public class HavenoUtils {
|
||||||
else if (Config.baseCurrencyNetwork().isStagenet()) return 38081;
|
else if (Config.baseCurrencyNetwork().isStagenet()) return 38081;
|
||||||
else throw new RuntimeException("Base network is not local testnet, stagenet, or mainnet");
|
else throw new RuntimeException("Base network is not local testnet, stagenet, or mainnet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setTopError(String msg) {
|
||||||
|
havenoSetup.getTopErrorMsg().set(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,6 +420,10 @@ public class XmrWalletService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceCloseWallet(MoneroWallet wallet, String path) {
|
public void forceCloseWallet(MoneroWallet wallet, String path) {
|
||||||
|
if (wallet == null) {
|
||||||
|
log.warn("Ignoring force close wallet because wallet is null, path={}", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (wallet instanceof MoneroWalletRpc) {
|
if (wallet instanceof MoneroWalletRpc) {
|
||||||
MONERO_WALLET_RPC_MANAGER.stopInstance((MoneroWalletRpc) wallet, path, true);
|
MONERO_WALLET_RPC_MANAGER.stopInstance((MoneroWalletRpc) wallet, path, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1306,7 +1310,16 @@ public class XmrWalletService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeInitMainWallet(boolean sync, int numAttempts) {
|
private void maybeInitMainWallet(boolean sync, int numAttempts) {
|
||||||
ThreadUtils.execute(() -> doMaybeInitMainWallet(sync, numAttempts), THREAD_ID);
|
ThreadUtils.execute(() -> {
|
||||||
|
try {
|
||||||
|
doMaybeInitMainWallet(sync, MAX_SYNC_ATTEMPTS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error initializing main wallet: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
HavenoUtils.setTopError(e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}, THREAD_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doMaybeInitMainWallet(boolean sync, int numAttempts) {
|
private void doMaybeInitMainWallet(boolean sync, int numAttempts) {
|
||||||
|
@ -1410,7 +1423,7 @@ public class XmrWalletService {
|
||||||
if (baseAddresses.size() > 1 || (baseAddresses.size() == 1 && !baseAddresses.get(0).getAddressString().equals(wallet.getPrimaryAddress()))) {
|
if (baseAddresses.size() > 1 || (baseAddresses.size() == 1 && !baseAddresses.get(0).getAddressString().equals(wallet.getPrimaryAddress()))) {
|
||||||
String warningMsg = "New Monero wallet detected. Resetting internal state.";
|
String warningMsg = "New Monero wallet detected. Resetting internal state.";
|
||||||
if (!tradeManager.getOpenTrades().isEmpty()) warningMsg += "\n\nWARNING: Your open trades will settle to the payout address in the OLD wallet!"; // TODO: allow payout address to be updated in PaymentSentMessage, PaymentReceivedMessage, and DisputeOpenedMessage?
|
if (!tradeManager.getOpenTrades().isEmpty()) warningMsg += "\n\nWARNING: Your open trades will settle to the payout address in the OLD wallet!"; // TODO: allow payout address to be updated in PaymentSentMessage, PaymentReceivedMessage, and DisputeOpenedMessage?
|
||||||
HavenoUtils.havenoSetup.getTopErrorMsg().set(warningMsg);
|
HavenoUtils.setTopError(warningMsg);
|
||||||
|
|
||||||
// reset address entries
|
// reset address entries
|
||||||
xmrAddressEntryList.clear();
|
xmrAddressEntryList.clear();
|
||||||
|
@ -1529,7 +1542,7 @@ public class XmrWalletService {
|
||||||
return walletFull;
|
return walletFull;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (walletFull != null) forceCloseMainWallet();
|
if (walletFull != null) forceCloseWallet(walletFull, config.getPath());
|
||||||
throw new IllegalStateException("Could not create wallet '" + config.getPath() + "'");
|
throw new IllegalStateException("Could not create wallet '" + config.getPath() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue