save trade wallet on shutdown with timeout

This commit is contained in:
woodser 2024-01-19 19:59:42 -05:00
parent b88bec580e
commit 847e9e8701

View File

@ -1275,6 +1275,17 @@ public abstract class Trade implements Tradable, Model {
shutDownThreads.add(() -> ThreadUtils.shutDown(getConnectionChangedThreadId()));
ThreadUtils.awaitTasks(shutDownThreads);
}
// save wallet
if (wallet != null) {
try {
xmrWalletService.saveWallet(wallet, false); // skip backup
stopWallet();
} catch (Exception e) {
// warning will be logged for main wallet, so skip logging here
//log.warn("Error closing monero-wallet-rpc subprocess for {} {}: {}. Was Haveno stopped manually with ctrl+c?", getClass().getSimpleName(), getId(), e.getMessage());
}
}
};
// shut down trade with timeout
@ -1299,15 +1310,6 @@ public abstract class Trade implements Tradable, Model {
xmrWalletService.removeWalletListener(idlePayoutSyncer);
idlePayoutSyncer = null;
}
if (wallet != null) {
try {
xmrWalletService.saveWallet(wallet, false); // skip backup
stopWallet();
} catch (Exception e) {
// warning will be logged for main wallet, so skip logging here
//log.warn("Error closing monero-wallet-rpc subprocess for {} {}: {}. Was Haveno stopped manually with ctrl+c?", getClass().getSimpleName(), getId(), e.getMessage());
}
}
UserThread.execute(() -> {
if (tradeStateSubscription != null) tradeStateSubscription.unsubscribe();
if (tradePhaseSubscription != null) tradePhaseSubscription.unsubscribe();