rely on trade state to delete wallet

This commit is contained in:
woodser 2023-12-29 15:28:46 -05:00
parent 3aab3f57b1
commit c55fb927f2

View file

@ -891,25 +891,13 @@ public abstract class Trade implements Tradable, Model {
if (walletExists()) { if (walletExists()) {
try { try {
// check if synced // check if deposits published and payout not unlocked
if (!isSyncedWithinTolerance()) {
log.warn("Refusing to delete wallet for {} {} because it is not synced within tolerance", getClass().getSimpleName(), getId());
return;
}
// check if balance > 0
if (wallet.getBalance().compareTo(BigInteger.ZERO) > 0) {
log.warn("Refusing to delete wallet for {} {} because it contains a balance", getClass().getSimpleName(), getId());
return;
}
// check if funds deposited but payout not unlocked
if (isDepositsPublished() && !isPayoutUnlocked()) { if (isDepositsPublished() && !isPayoutUnlocked()) {
throw new RuntimeException("Refusing to delete wallet for " + getClass().getSimpleName() + " " + getId() + " because the deposit txs have been published but payout tx has not unlocked"); throw new RuntimeException("Refusing to delete wallet for " + getClass().getSimpleName() + " " + getId() + " because the deposit txs have been published but payout tx has not unlocked");
} }
// force stop the wallet // force stop the wallet
stopWallet(); if (wallet != null) stopWallet();
// delete wallet // delete wallet
log.info("Deleting wallet for {} {}", getClass().getSimpleName(), getId()); log.info("Deleting wallet for {} {}", getClass().getSimpleName(), getId());
@ -918,9 +906,9 @@ public abstract class Trade implements Tradable, Model {
// delete trade wallet backups unless deposits requested and payouts not unlocked // delete trade wallet backups unless deposits requested and payouts not unlocked
if (isDepositRequested() && !isDepositFailed() && !isPayoutUnlocked()) { if (isDepositRequested() && !isDepositFailed() && !isPayoutUnlocked()) {
log.warn("Refusing to delete backup wallet for " + getClass().getSimpleName() + " " + getId() + " in the small chance it becomes funded"); log.warn("Refusing to delete backup wallet for " + getClass().getSimpleName() + " " + getId() + " in the small chance it becomes funded");
return; } else {
}
xmrWalletService.deleteWalletBackups(getWalletName()); xmrWalletService.deleteWalletBackups(getWalletName());
}
} catch (Exception e) { } catch (Exception e) {
log.warn(e.getMessage()); log.warn(e.getMessage());
e.printStackTrace(); e.printStackTrace();