diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 77511821f4..9fd0f28aa3 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -2775,6 +2775,12 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model { return getState().getPhase().ordinal() >= Phase.PAYMENT_SENT.ordinal() && getState() != State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG; } + public boolean isPaymentSentMessageProcessed() { + if (isPaymentReceived()) return true; + if (isBuyer()) return getState() == State.SELLER_RECEIVED_PAYMENT_SENT_MSG; + return getState() == Trade.State.BUYER_SENT_PAYMENT_SENT_MSG; + } + public boolean isPaymentMarkedReceived() { return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal(); } @@ -2783,6 +2789,11 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model { return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal() && getState() != State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG; } + public boolean isPaymentReceivedMessageProcessed() { + if (isSeller()) return getState() == State.BUYER_RECEIVED_PAYMENT_RECEIVED_MSG; + return getState() == Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG; + } + public boolean isPayoutPublished() { return getPayoutState().ordinal() >= PayoutState.PAYOUT_PUBLISHED.ordinal(); } diff --git a/core/src/main/java/haveno/core/trade/protocol/SellerProtocol.java b/core/src/main/java/haveno/core/trade/protocol/SellerProtocol.java index 32371933b2..90facf7ce7 100644 --- a/core/src/main/java/haveno/core/trade/protocol/SellerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/SellerProtocol.java @@ -122,7 +122,7 @@ public class SellerProtocol extends DisputeProtocol { log.info(TradeProtocol.LOG_HIGHLIGHT + "SellerProtocol.onPaymentReceived() for {} {}", trade.getClass().getSimpleName(), trade.getShortId()); // advance trade state - if (trade.getState() == Trade.State.BUYER_SENT_PAYMENT_SENT_MSG || trade.isPaymentReceived()) { + if (trade.isPaymentSentMessageProcessed()) { trade.setStateIfValidTransitionTo(Trade.State.SELLER_CONFIRMED_PAYMENT_RECEIPT); } else { errorMessageHandler.handleErrorMessage("Cannot confirm payment received for " + trade.getClass().getSimpleName() + " " + trade.getShortId() + " in state " + trade.getState()); diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index 2abdfc6c94..b54ff28d30 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -620,7 +620,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D // the mailbox msg once wallet is ready and trade state set. synchronized (trade.getLock()) { if (!trade.isInitialized() || trade.isShutDownStarted()) return; - if (trade.getState().ordinal() >= Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal()) { + if (trade.isPaymentSentMessageProcessed()) { log.warn("Received another PaymentSentMessage which was already processed for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId()); handleTaskRunnerSuccess(trade.getBuyer().getNodeAddress(), message); return; @@ -720,8 +720,8 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D log.warn("Skipping processing PaymentReceivedMessage because the trade is not initialized or it's shutting down for {} {}", trade.getClass().getSimpleName(), trade.getId()); return; } - if (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished()) { - log.warn("Received another PaymentReceivedMessage after payout is published for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId()); + if (trade.isPaymentReceivedMessageProcessed() && trade.isPayoutPublished()) { + log.warn("Received another PaymentReceivedMessage after processed and payout is published for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId()); handleTaskRunnerSuccess(trade.getSeller().getNodeAddress(), message); return; } diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java index 7fe7271f48..a98b6fa8f2 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java @@ -73,7 +73,7 @@ public class ProcessPaymentReceivedMessage extends TradeTask { trade.requestPersistence(); // ack and complete if already processed - if (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished()) { + if (trade.isPaymentReceivedMessageProcessed() && trade.isPayoutPublished()) { log.warn("Received another PaymentReceivedMessage which was already processed, ACKing"); complete(); return;