fixes checking for missing wallet data

This commit is contained in:
woodser 2024-07-19 08:47:04 -04:00
parent 09fd8710b1
commit 9b26682646

View file

@ -2578,7 +2578,7 @@ public abstract class Trade implements Tradable, Model {
if (isConnectionRefused) forceRestartTradeWallet(); if (isConnectionRefused) forceRestartTradeWallet();
else { else {
boolean isWalletConnected = isWalletConnectedToDaemon(); boolean isWalletConnected = isWalletConnectedToDaemon();
if (!isShutDownStarted && wallet != null && isWalletConnected) { if (wallet != null && !isShutDownStarted && isWalletConnected) {
log.warn("Error polling trade wallet for {} {}, errorMessage={}. Monerod={}", getClass().getSimpleName(), getShortId(), e.getMessage(), getXmrWalletService().getConnectionService().getConnection()); log.warn("Error polling trade wallet for {} {}, errorMessage={}. Monerod={}", getClass().getSimpleName(), getShortId(), e.getMessage(), getXmrWalletService().getConnectionService().getConnection());
requestSwitchToNextBestConnection(); requestSwitchToNextBestConnection();
//e.printStackTrace(); //e.printStackTrace();
@ -2622,6 +2622,9 @@ public abstract class Trade implements Tradable, Model {
// force restart wallet // force restart wallet
forceRestartTradeWallet(); forceRestartTradeWallet();
// skip if payout published in the meantime
if (isPayoutPublished()) return;
// rescan blockchain with global daemon lock // rescan blockchain with global daemon lock
synchronized (HavenoUtils.getDaemonLock()) { synchronized (HavenoUtils.getDaemonLock()) {
Long timeout = null; Long timeout = null;
@ -2651,12 +2654,15 @@ public abstract class Trade implements Tradable, Model {
// import multisig hex // import multisig hex
log.warn("Importing multisig hex to recover wallet data for {} {}", getClass().getSimpleName(), getShortId()); log.warn("Importing multisig hex to recover wallet data for {} {}", getClass().getSimpleName(), getShortId());
importMultisigHex(); importMultisigHex();
}
}
// check again after releasing lock // poll wallet
doPollWallet();
// check again if missing data
if (isWalletMissingData()) throw new IllegalStateException("Wallet is still missing data after attempting recovery for " + getClass().getSimpleName() + " " + getShortId()); if (isWalletMissingData()) throw new IllegalStateException("Wallet is still missing data after attempting recovery for " + getClass().getSimpleName() + " " + getShortId());
} }
}
}
private boolean isWalletMissingData() { private boolean isWalletMissingData() {
synchronized (walletLock) { synchronized (walletLock) {
@ -2670,6 +2676,8 @@ public abstract class Trade implements Tradable, Model {
return true; return true;
} }
if (wallet.getBalance().equals(BigInteger.ZERO)) { if (wallet.getBalance().equals(BigInteger.ZERO)) {
doPollWallet(); // poll once more to be sure
if (isPayoutPublished()) return false; // payout can become published while checking balance
log.warn("Wallet balance is zero for {} {}", getClass().getSimpleName(), getId()); log.warn("Wallet balance is zero for {} {}", getClass().getSimpleName(), getId());
return true; return true;
} }