close open dispute on preparing payment received message
This commit is contained in:
parent
26ea53883c
commit
66a152c888
@ -1342,7 +1342,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
for (Dispute dispute : getDisputes()) dispute.setDisputePayoutTxId(payoutTxId);
|
for (Dispute dispute : getDisputes()) dispute.setDisputePayoutTxId(payoutTxId);
|
||||||
|
|
||||||
// set final payout amounts
|
// 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));
|
BigInteger splitTxFee = payoutTx.getFee().divide(BigInteger.valueOf(2));
|
||||||
getBuyer().setPayoutTxFee(splitTxFee);
|
getBuyer().setPayoutTxFee(splitTxFee);
|
||||||
getSeller().setPayoutTxFee(splitTxFee);
|
getSeller().setPayoutTxFee(splitTxFee);
|
||||||
@ -1614,6 +1614,10 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
return getState().getPhase().ordinal() >= Phase.PAYMENT_SENT.ordinal();
|
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() {
|
public boolean isPaymentReceived() {
|
||||||
return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal();
|
return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal();
|
||||||
}
|
}
|
||||||
|
@ -78,17 +78,17 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
|||||||
}
|
}
|
||||||
trade.requestPersistence();
|
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
|
// process payout tx unless already unlocked
|
||||||
if (!trade.isPayoutUnlocked()) processPayoutTx(message);
|
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();
|
SignedWitness signedWitness = message.getBuyerSignedWitness();
|
||||||
if (signedWitness != null && trade instanceof BuyerTrade) {
|
if (signedWitness != null && trade instanceof BuyerTrade) {
|
||||||
// We received the signedWitness from the seller and publish the data to the network.
|
// We received the signedWitness from the seller and publish the data to the network.
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package haveno.core.trade.protocol.tasks;
|
package haveno.core.trade.protocol.tasks;
|
||||||
|
|
||||||
import haveno.common.taskrunner.TaskRunner;
|
import haveno.common.taskrunner.TaskRunner;
|
||||||
|
import haveno.core.support.dispute.Dispute;
|
||||||
import haveno.core.trade.Trade;
|
import haveno.core.trade.Trade;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import monero.wallet.model.MoneroTxWallet;
|
import monero.wallet.model.MoneroTxWallet;
|
||||||
@ -63,6 +64,12 @@ public class SellerPreparePaymentReceivedMessage extends TradeTask {
|
|||||||
trade.processPayoutTx(trade.getArbitrator().getPaymentReceivedMessage().getSignedPayoutTxHex(), false, true);
|
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();
|
processModel.getTradeManager().requestPersistence();
|
||||||
complete();
|
complete();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
Loading…
Reference in New Issue
Block a user