Refactor: rename DelayedPayoutTxValidation to TradeDataValidation

This commit is contained in:
chimp1984 2020-09-20 21:40:21 -05:00
parent 2943316f90
commit 30e9add4dc
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
10 changed files with 40 additions and 40 deletions

View File

@ -36,8 +36,8 @@ import bisq.core.support.dispute.messages.OpenNewDisputeMessage;
import bisq.core.support.dispute.messages.PeerOpenedDisputeMessage;
import bisq.core.support.messages.ChatMessage;
import bisq.core.trade.Contract;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.TradeManager;
import bisq.core.trade.closed.ClosedTradableManager;
@ -92,7 +92,7 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
protected final DaoFacade daoFacade;
@Getter
protected final ObservableList<DelayedPayoutTxValidation.ValidationException> validationExceptions =
protected final ObservableList<TradeDataValidation.ValidationException> validationExceptions =
FXCollections.observableArrayList();
@Getter
private final KeyPair signatureKeyPair;
@ -262,15 +262,15 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
ObservableList<Dispute> disputes = getDisputeList().getList();
disputes.forEach(dispute -> {
try {
DelayedPayoutTxValidation.validateDonationAddress(dispute, dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
} catch (DelayedPayoutTxValidation.AddressException e) {
TradeDataValidation.validateDonationAddress(dispute, dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
} catch (TradeDataValidation.AddressException e) {
log.error(e.toString());
validationExceptions.add(e);
}
});
DelayedPayoutTxValidation.testIfAnyDisputeTriedReplay(disputes,
TradeDataValidation.testIfAnyDisputeTriedReplay(disputes,
disputeReplayException -> {
log.error(disputeReplayException.toString());
validationExceptions.add(disputeReplayException);
@ -313,9 +313,9 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
addPriceInfoMessage(dispute, 0);
try {
DelayedPayoutTxValidation.validateDonationAddress(dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
DelayedPayoutTxValidation.testIfDisputeTriesReplay(dispute, disputeList.getList());
} catch (DelayedPayoutTxValidation.AddressException | DelayedPayoutTxValidation.DisputeReplayException e) {
TradeDataValidation.validateDonationAddress(dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
TradeDataValidation.testIfDisputeTriesReplay(dispute, disputeList.getList());
} catch (TradeDataValidation.AddressException | TradeDataValidation.DisputeReplayException e) {
log.error(e.toString());
validationExceptions.add(e);
}
@ -370,12 +370,12 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
Trade trade = optionalTrade.get();
try {
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
trade.getDelayedPayoutTx(),
dispute,
daoFacade,
btcWalletService);
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
// The peer sent us an invalid donation address. We do not return here as we don't want to break
// mediation/arbitration and log only the issue. The dispute agent will run validation as well and will get
// a popup displayed to react.

View File

@ -48,7 +48,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
public class DelayedPayoutTxValidation {
public class TradeDataValidation {
public static void validateDonationAddress(String addressAsString, DaoFacade daoFacade)
throws AddressException {
@ -96,7 +96,7 @@ public class DelayedPayoutTxValidation {
public static void testIfDisputeTriesReplay(Dispute dispute,
List<Dispute> disputeList) throws DisputeReplayException {
var tuple = DelayedPayoutTxValidation.getTestReplayHashMaps(disputeList);
var tuple = TradeDataValidation.getTestReplayHashMaps(disputeList);
Map<String, Set<String>> disputesPerTradeId = tuple.first;
Map<String, Set<String>> disputesPerDelayedPayoutTxId = tuple.second;
Map<String, Set<String>> disputesPerDepositTxId = tuple.third;

View File

@ -306,11 +306,11 @@ public class TradeManager implements PersistedDataHost {
}
try {
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
trade.getDelayedPayoutTx(),
daoFacade,
btcWalletService);
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
log.warn("Delayed payout tx exception, trade {}, exception {}", trade.getId(), e.getMessage());
if (!allowFaultyDelayedTxs) {
// We move it to failed trades so it cannot be continued.

View File

@ -17,8 +17,8 @@
package bisq.core.trade.protocol.tasks.buyer;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.common.taskrunner.TaskRunner;
@ -44,7 +44,7 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
checkNotNull(delayedPayoutTx, "trade.getDelayedPayoutTx() must not be null");
// Check again tx
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
delayedPayoutTx,
processModel.getDaoFacade(),
processModel.getBtcWalletService());
@ -52,10 +52,10 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
// Now as we know the deposit tx we can also verify the input
Transaction depositTx = trade.getDepositTx();
checkNotNull(depositTx, "trade.getDepositTx() must not be null");
DelayedPayoutTxValidation.validatePayoutTxInput(depositTx, delayedPayoutTx);
TradeDataValidation.validatePayoutTxInput(depositTx, delayedPayoutTx);
complete();
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
failed(e.getMessage());
} catch (Throwable t) {
failed(t);

View File

@ -17,8 +17,8 @@
package bisq.core.trade.protocol.tasks.buyer;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.common.taskrunner.TaskRunner;
@ -37,13 +37,13 @@ public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask {
try {
runInterceptHook();
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
processModel.getPreparedDelayedPayoutTx(),
processModel.getDaoFacade(),
processModel.getBtcWalletService());
complete();
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
failed(e.getMessage());
} catch (Throwable t) {
failed(t);

View File

@ -47,7 +47,7 @@ import bisq.core.support.dispute.DisputeResult;
import bisq.core.support.dispute.mediation.MediationManager;
import bisq.core.support.dispute.refund.RefundManager;
import bisq.core.trade.Contract;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.TradeDataValidation;
import bisq.core.util.FormattingUtils;
import bisq.core.util.ParsingUtils;
import bisq.core.util.coin.CoinFormatter;
@ -757,10 +757,10 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
private void doCloseIfValid(Button closeTicketButton) {
var disputeManager = checkNotNull(getDisputeManager(dispute));
try {
DelayedPayoutTxValidation.validateDonationAddress(dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
DelayedPayoutTxValidation.testIfDisputeTriesReplay(dispute, disputeManager.getDisputesAsObservableList());
TradeDataValidation.validateDonationAddress(dispute.getDonationAddressOfDelayedPayoutTx(), daoFacade);
TradeDataValidation.testIfDisputeTriesReplay(dispute, disputeManager.getDisputesAsObservableList());
doClose(closeTicketButton);
} catch (DelayedPayoutTxValidation.AddressException exception) {
} catch (TradeDataValidation.AddressException exception) {
String addressAsString = dispute.getDonationAddressOfDelayedPayoutTx();
String tradeId = dispute.getTradeId();
@ -788,7 +788,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
Res.get("support.warning.disputesWithInvalidDonationAddress.refundAgent")))
.show();
}
} catch (DelayedPayoutTxValidation.DisputeReplayException exception) {
} catch (TradeDataValidation.DisputeReplayException exception) {
if (disputeManager instanceof MediationManager) {
new Popup().width(900)
.warning(exception.getMessage())

View File

@ -47,9 +47,9 @@ import bisq.core.support.dispute.refund.RefundManager;
import bisq.core.support.messages.ChatMessage;
import bisq.core.support.traderchat.TraderChatManager;
import bisq.core.trade.BuyerTrade;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.SellerTrade;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.TradeManager;
import bisq.core.trade.messages.RefreshTradeStateRequest;
import bisq.core.user.Preferences;
@ -541,12 +541,12 @@ public class PendingTradesDataModel extends ActivatableDataModel {
AtomicReference<String> donationAddressString = new AtomicReference<>("");
Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
try {
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
delayedPayoutTx,
daoFacade,
btcWalletService,
donationAddressString::set);
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
// The peer sent us an invalid donation address. We do not return here as we don't want to break
// mediation/arbitration and log only the issue. The dispute agent will run validation as well and will get
// a popup displayed to react.

View File

@ -22,7 +22,7 @@ import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
import bisq.desktop.main.portfolio.pendingtrades.steps.TradeStepView;
import bisq.core.locale.Res;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.TradeDataValidation;
import bisq.common.UserThread;
@ -99,15 +99,15 @@ public class BuyerStep1View extends TradeStepView {
private void validatePayoutTx() {
try {
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
trade.getDelayedPayoutTx(),
model.dataModel.daoFacade,
model.dataModel.btcWalletService);
} catch (DelayedPayoutTxValidation.MissingTxException ignore) {
} catch (TradeDataValidation.MissingTxException ignore) {
// We don't react on those errors as a failed trade might get listed initially but getting removed from the
// trade manager after initPendingTrades which happens after activate might be called.
log.error("");
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
if (!model.dataModel.tradeManager.isAllowFaultyDelayedTxs()) {
new Popup().warning(Res.get("portfolio.pending.invalidDelayedPayoutTx", e.getMessage())).show();
}

View File

@ -70,8 +70,8 @@ import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.USPostalMoneyOrderAccountPayload;
import bisq.core.payment.payload.WesternUnionAccountPayload;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.user.DontShowAgainLookup;
import bisq.common.Timer;
@ -635,15 +635,15 @@ public class BuyerStep2View extends TradeStepView {
private void validatePayoutTx() {
try {
DelayedPayoutTxValidation.validatePayoutTx(trade,
TradeDataValidation.validatePayoutTx(trade,
trade.getDelayedPayoutTx(),
model.dataModel.daoFacade,
model.dataModel.btcWalletService);
} catch (DelayedPayoutTxValidation.MissingTxException ignore) {
} catch (TradeDataValidation.MissingTxException ignore) {
// We don't react on those errors as a failed trade might get listed initially but getting removed from the
// trade manager after initPendingTrades which happens after activate might be called.
log.error("");
} catch (DelayedPayoutTxValidation.ValidationException e) {
} catch (TradeDataValidation.ValidationException e) {
if (!model.dataModel.tradeManager.isAllowFaultyDelayedTxs()) {
new Popup().warning(Res.get("portfolio.pending.invalidDelayedPayoutTx", e.getMessage())).show();
}

View File

@ -36,7 +36,7 @@ import bisq.core.support.dispute.DisputeSession;
import bisq.core.support.dispute.agent.MultipleHolderNameDetection;
import bisq.core.support.dispute.mediation.mediator.MediatorManager;
import bisq.core.support.dispute.refund.refundagent.RefundAgentManager;
import bisq.core.trade.DelayedPayoutTxValidation;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.TradeManager;
import bisq.core.user.DontShowAgainLookup;
import bisq.core.util.coin.CoinFormatter;
@ -62,7 +62,7 @@ import javafx.collections.ListChangeListener;
import java.util.List;
import static bisq.core.trade.DelayedPayoutTxValidation.ValidationException;
import static bisq.core.trade.TradeDataValidation.ValidationException;
import static bisq.desktop.util.FormBuilder.getIconForLabel;
public abstract class DisputeAgentView extends DisputeView implements MultipleHolderNameDetection.Listener {
@ -136,7 +136,7 @@ public abstract class DisputeAgentView extends DisputeView implements MultipleHo
.filter(ex -> !ex.getDispute().isClosed())
.forEach(ex -> {
Dispute dispute = ex.getDispute();
if (ex instanceof DelayedPayoutTxValidation.AddressException) {
if (ex instanceof TradeDataValidation.AddressException) {
new Popup().width(900).warning(Res.get("support.warning.disputesWithInvalidDonationAddress",
dispute.getDonationAddressOfDelayedPayoutTx(),
daoFacade.getAllDonationAddresses(),