close open dispute on preparing payment received message

This commit is contained in:
woodser 2023-12-14 12:02:44 -05:00
parent 26ea53883c
commit 66a152c888
3 changed files with 19 additions and 8 deletions

View File

@ -1342,7 +1342,7 @@ public abstract class Trade implements Tradable, Model {
for (Dispute dispute : getDisputes()) dispute.setDisputePayoutTxId(payoutTxId);
// set final payout amounts
if (getDisputeState().isNotDisputed()) {
if (hasPaymentReceivedMessage()) { // TODO: replace with isPaymentReceived() but only if correct when trade completes with dispute
BigInteger splitTxFee = payoutTx.getFee().divide(BigInteger.valueOf(2));
getBuyer().setPayoutTxFee(splitTxFee);
getSeller().setPayoutTxFee(splitTxFee);
@ -1614,6 +1614,10 @@ public abstract class Trade implements Tradable, Model {
return getState().getPhase().ordinal() >= Phase.PAYMENT_SENT.ordinal();
}
public boolean hasPaymentReceivedMessage() {
return (isSeller() ? getBuyer() : getSeller()).getPaymentReceivedMessage() != null; // seller stores message to buyer and arbitrator, peers store message from seller
}
public boolean isPaymentReceived() {
return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal();
}

View File

@ -78,17 +78,17 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
}
trade.requestPersistence();
// close open disputes
if (trade.getDisputeState().ordinal() >= Trade.DisputeState.DISPUTE_REQUESTED.ordinal()) {
trade.advanceDisputeState(Trade.DisputeState.DISPUTE_CLOSED);
for (Dispute dispute : trade.getDisputes()) {
dispute.setIsClosed();
}
}
// process payout tx unless already unlocked
if (!trade.isPayoutUnlocked()) processPayoutTx(message);
// close open disputes
if (trade.isPayoutPublished() && trade.getDisputeState().ordinal() >= Trade.DisputeState.DISPUTE_REQUESTED.ordinal()) {
trade.advanceDisputeState(Trade.DisputeState.DISPUTE_CLOSED);
for (Dispute dispute : trade.getDisputes()) dispute.setIsClosed();
}
// publish signed witness
SignedWitness signedWitness = message.getBuyerSignedWitness();
if (signedWitness != null && trade instanceof BuyerTrade) {
// We received the signedWitness from the seller and publish the data to the network.

View File

@ -18,6 +18,7 @@
package haveno.core.trade.protocol.tasks;
import haveno.common.taskrunner.TaskRunner;
import haveno.core.support.dispute.Dispute;
import haveno.core.trade.Trade;
import lombok.extern.slf4j.Slf4j;
import monero.wallet.model.MoneroTxWallet;
@ -63,6 +64,12 @@ public class SellerPreparePaymentReceivedMessage extends TradeTask {
trade.processPayoutTx(trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex(), false, true);
}
// close open disputes
if (trade.isPayoutPublished() && trade.getDisputeState().ordinal() >= Trade.DisputeState.DISPUTE_REQUESTED.ordinal()) {
trade.advanceDisputeState(Trade.DisputeState.DISPUTE_CLOSED);
for (Dispute dispute : trade.getDisputes()) dispute.setIsClosed();
}
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {