From 847e9e870128af2b6f0eb6509ce0642f701e7c95 Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 19 Jan 2024 19:59:42 -0500 Subject: [PATCH] save trade wallet on shutdown with timeout --- .../main/java/haveno/core/trade/Trade.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index a5aceeca42..7b172957e7 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -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();