From 9eea422c9ee959168d55234336a926cc8f491134 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 15 Nov 2023 10:34:10 -0500 Subject: [PATCH] sync main wallet on payout to update pending balance --- core/src/main/java/haveno/core/trade/Trade.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index dfb27511e2..a860894442 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -633,10 +633,17 @@ public abstract class Trade implements Tradable, Model { payoutStateSubscription = EasyBind.subscribe(payoutStateProperty, newValue -> { if (isPayoutPublished()) updateWalletRefreshPeriod(); - // cleanup when payout published + // handle when payout published if (newValue == Trade.PayoutState.PAYOUT_PUBLISHED) { log.info("Payout published for {} {}", getClass().getSimpleName(), getId()); + // sync main wallet to update pending balance + new Thread(() -> { + GenUtils.waitFor(1000); + if (isShutDownStarted) return; + if (Boolean.TRUE.equals(xmrWalletService.getConnectionsService().isConnected())) xmrWalletService.syncWallet(xmrWalletService.getWallet()); + }).start(); + // complete disputed trade if (getDisputeState().isArbitrated() && !getDisputeState().isClosed()) processModel.getTradeManager().closeDisputedTrade(getId(), Trade.DisputeState.DISPUTE_CLOSED); @@ -647,7 +654,7 @@ public abstract class Trade implements Tradable, Model { processModel.getXmrWalletService().resetAddressEntriesForTrade(getId()); } - // cleanup when payout unlocks + // handle when payout unlocks if (newValue == Trade.PayoutState.PAYOUT_UNLOCKED) { if (!isInitialized) return; log.info("Payout unlocked for {} {}, deleting multisig wallet", getClass().getSimpleName(), getId());