mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Use a checkArgument to ensure that the methods are not called once a
dispute has been opened. This will cause a Runtime exception but that is justified as the caller need to ensure to do the check and do not allow to get to that point.
This commit is contained in:
parent
35cd7ac56b
commit
f566e0975e
@ -55,6 +55,8 @@ import bisq.common.handlers.ResultHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@Slf4j
|
||||
public class BuyerAsMakerProtocol extends TradeProtocol implements BuyerProtocol, MakerProtocol {
|
||||
private final BuyerAsMakerTrade buyerAsMakerTrade;
|
||||
@ -212,9 +214,8 @@ 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;
|
||||
}
|
||||
checkArgument(!wasDisputed(), "A call to onFiatPaymentStarted is not permitted once a " +
|
||||
"dispute has been opened.");
|
||||
|
||||
if (trade.isDepositConfirmed() && !trade.isFiatSent()) {
|
||||
buyerAsMakerTrade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED);
|
||||
|
@ -59,6 +59,7 @@ import bisq.common.handlers.ResultHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
@ -237,9 +238,8 @@ 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;
|
||||
}
|
||||
checkArgument(!wasDisputed(), "A call to onFiatPaymentStarted is not permitted once a " +
|
||||
"dispute has been opened.");
|
||||
|
||||
if (!trade.isFiatSent()) {
|
||||
buyerAsTakerTrade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED);
|
||||
|
@ -57,6 +57,8 @@ import bisq.common.handlers.ResultHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@Slf4j
|
||||
public class SellerAsMakerProtocol extends TradeProtocol implements SellerProtocol, MakerProtocol {
|
||||
private final SellerAsMakerTrade sellerAsMakerTrade;
|
||||
@ -204,9 +206,8 @@ 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;
|
||||
}
|
||||
checkArgument(!wasDisputed(), "A call to onFiatPaymentReceived is not permitted once a " +
|
||||
"dispute has been opened.");
|
||||
|
||||
if (trade.getPayoutTx() == null) {
|
||||
sellerAsMakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
|
||||
|
@ -56,6 +56,7 @@ import bisq.common.handlers.ResultHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
@ -196,9 +197,8 @@ 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;
|
||||
}
|
||||
checkArgument(!wasDisputed(), "A call to onFiatPaymentReceived is not permitted once a " +
|
||||
"dispute has been opened.");
|
||||
|
||||
if (trade.getPayoutTx() == null) {
|
||||
sellerAsTakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
|
||||
|
@ -345,14 +345,8 @@ 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;
|
||||
protected boolean wasDisputed() {
|
||||
return trade.getDisputeState() != Trade.DisputeState.NO_DISPUTE;
|
||||
}
|
||||
|
||||
private void sendAckMessage(@Nullable TradeMessage tradeMessage, boolean result, @Nullable String errorMessage) {
|
||||
|
Loading…
Reference in New Issue
Block a user