From 467b678ea7a7206e7ad7cecfc488d703cf35a6bc Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 30 Apr 2024 11:17:00 -0400 Subject: [PATCH] check if dispute payout published on submit failure, thread fixes --- .../core/support/dispute/DisputeManager.java | 3 ++- .../arbitration/ArbitrationManager.java | 1 + .../main/java/haveno/core/trade/Trade.java | 20 ++++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java index 9b7e10d5ed..35c7a5408d 100644 --- a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java @@ -758,6 +758,7 @@ public abstract class DisputeManager> extends Sup // create dispute closed message TradePeer receiverPeer = receiver == trade.getBuyer() ? trade.getSeller() : trade.getBuyer(); boolean deferPublishPayout = !exists && receiver.getUnsignedPayoutTxHex() != null && receiverPeer.getUpdatedMultisigHex() != null && trade.getDisputeState().ordinal() >= Trade.DisputeState.ARBITRATOR_SAW_ARRIVED_DISPUTE_CLOSED_MSG.ordinal(); + log.info("deferPublishPayout = {} = {} && {} && {} && {}", deferPublishPayout, !exists, receiver.getUnsignedPayoutTxHex() != null, receiverPeer.getUpdatedMultisigHex() != null, trade.getDisputeState().ordinal() >= Trade.DisputeState.ARBITRATOR_SAW_ARRIVED_DISPUTE_CLOSED_MSG.ordinal()); DisputeClosedMessage disputeClosedMessage = new DisputeClosedMessage(disputeResult, p2PService.getAddress(), UUID.randomUUID().toString(), @@ -856,7 +857,7 @@ public abstract class DisputeManager> extends Sup if (!trade.isPayoutPublished()) { // create unsigned dispute payout tx - log.info("Creating unsigned dispute payout tx for trade {}", trade.getId()); + if (updateState) log.info("Creating unsigned dispute payout tx for trade {}", trade.getId()); try { // trade wallet must be synced diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java index 773a2e64b2..0a046dc6f0 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java @@ -477,6 +477,7 @@ public final class ArbitrationManager extends DisputeManager { if (!isInitialized || isShutDownStarted) return; - ThreadUtils.execute(() -> { + ThreadUtils.submitToPool(() -> { if (newValue == Trade.Phase.DEPOSIT_REQUESTED) startPolling(); if (isDepositsPublished() && !isPayoutUnlocked()) updatePollPeriod(); if (isPaymentReceived()) { @@ -652,13 +652,13 @@ public abstract class Trade implements Tradable, Model { } }); } - }, getId()); + }); }); // handle payout events payoutStateSubscription = EasyBind.subscribe(payoutStateProperty, newValue -> { if (!isInitialized || isShutDownStarted) return; - ThreadUtils.execute(() -> { + ThreadUtils.submitToPool(() -> { if (isPayoutPublished()) updatePollPeriod(); // handle when payout published @@ -666,11 +666,13 @@ public abstract class Trade implements Tradable, Model { log.info("Payout published for {} {}", getClass().getSimpleName(), getId()); // sync main wallet to update pending balance - new Thread(() -> { - HavenoUtils.waitFor(1000); - if (isShutDownStarted) return; - if (xmrConnectionService.isConnected()) xmrWalletService.syncWallet(); - }).start(); + if (!isPayoutConfirmed()) { + new Thread(() -> { + HavenoUtils.waitFor(1000); + if (isShutDownStarted) return; + if (xmrConnectionService.isConnected()) syncAndPollWallet(); + }).start(); + } // complete disputed trade if (getDisputeState().isArbitrated() && !getDisputeState().isClosed()) { @@ -691,7 +693,7 @@ public abstract class Trade implements Tradable, Model { log.info("Payout unlocked for {} {}, deleting multisig wallet", getClass().getSimpleName(), getId()); clearAndShutDown(); } - }, getId()); + }); }); // arbitrator syncs idle wallet when payout unlock expected