Add check if trade have been dispute to protocol classes

This commit is contained in:
chimp1984 2020-09-06 23:09:45 -05:00
parent 1419f05152
commit 087dde0e9d
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
6 changed files with 27 additions and 1 deletions

View File

@ -212,6 +212,10 @@ public class BuyerAsMakerProtocol extends TradeProtocol implements BuyerProtocol
// User clicked the "bank transfer started" button
@Override
public void onFiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
if (wasDisputed(errorMessageHandler)) {
return;
}
if (trade.isDepositConfirmed() && !trade.isFiatSent()) {
buyerAsMakerTrade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED);
TradeTaskRunner taskRunner = new TradeTaskRunner(buyerAsMakerTrade,

View File

@ -237,6 +237,10 @@ public class BuyerAsTakerProtocol extends TradeProtocol implements BuyerProtocol
// User clicked the "bank transfer started" button
@Override
public void onFiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
if (wasDisputed(errorMessageHandler)) {
return;
}
if (!trade.isFiatSent()) {
buyerAsTakerTrade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED);

View File

@ -204,6 +204,10 @@ public class SellerAsMakerProtocol extends TradeProtocol implements SellerProtoc
// User clicked the "bank transfer received" button, so we release the funds for payout
@Override
public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
if (wasDisputed(errorMessageHandler)) {
return;
}
if (trade.getPayoutTx() == null) {
sellerAsMakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
TradeTaskRunner taskRunner = new TradeTaskRunner(sellerAsMakerTrade,

View File

@ -196,6 +196,10 @@ public class SellerAsTakerProtocol extends TradeProtocol implements SellerProtoc
// User clicked the "bank transfer received" button, so we release the funds for payout
@Override
public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
if (wasDisputed(errorMessageHandler)) {
return;
}
if (trade.getPayoutTx() == null) {
sellerAsTakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
TradeTaskRunner taskRunner = new TradeTaskRunner(sellerAsTakerTrade,

View File

@ -345,6 +345,16 @@ public abstract class TradeProtocol {
cleanup();
}
protected boolean wasDisputed(ErrorMessageHandler errorMessageHandler) {
if (trade.getDisputeState() != Trade.DisputeState.NO_DISPUTE) {
String msg = "Dispute have been opened once. We do not allow anymore to confirm payment by button click.";
log.error(msg);
errorMessageHandler.handleErrorMessage(msg);
return true;
}
return false;
}
private void sendAckMessage(@Nullable TradeMessage tradeMessage, boolean result, @Nullable String errorMessage) {
// We complete at initial protocol setup with the setup listener tasks.
// Other cases are if we start from an UI event the task runner (payment started, confirmed).

View File

@ -185,7 +185,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
}
public void onPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
final Trade trade = getTrade();
Trade trade = getTrade();
checkNotNull(trade, "trade must not be null");
checkArgument(trade instanceof BuyerTrade, "Check failed: trade instanceof BuyerTrade");
((BuyerTrade) trade).onFiatPaymentStarted(resultHandler, errorMessageHandler);