Add verification of chain of transactions at DisputeSummaryWindow

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-11-02 23:24:05 -05:00
parent 60cd8b1e16
commit c49b811da3
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307
2 changed files with 53 additions and 2 deletions

View file

@ -2736,6 +2736,11 @@ disputeSummaryWindow.reason=Reason of dispute
disputeSummaryWindow.tradePeriodEnd=Trade period end
disputeSummaryWindow.extraInfo=Extra information
disputeSummaryWindow.delayedPayoutStatus=Delayed Payout Status
disputeSummaryWindow.requestingTxs=Requesting blockchain transactions from block explorer...
disputeSummaryWindow.requestTransactionsError=Requesting the 4 trade transactions failed. Error message: {0}.\n\n\
Please verify the transactions manually before closing the dispute.
disputeSummaryWindow.delayedPayoutTxVerificationFailed=Verification of the delayed payout transaction failed. Error message: {0}.\n\n\
Please do not make the payout but get in touch with developers to clearify the case.
# dynamic values are not recognized by IntelliJ
# suppress inspection "UnusedProperty"

View file

@ -55,6 +55,7 @@ import bisq.core.util.coin.CoinUtil;
import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.config.Config;
import bisq.common.handlers.ResultHandler;
import bisq.common.util.Tuple2;
import bisq.common.util.Tuple3;
@ -692,9 +693,9 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
!peersDisputeOptional.get().isClosed()) {
showPayoutTxConfirmation(contract,
disputeResult,
() -> doCloseIfValid(closeTicketButton));
() -> doCloseAfterTxsVerified(closeTicketButton));
} else {
doCloseIfValid(closeTicketButton);
doCloseAfterTxsVerified(closeTicketButton);
}
});
@ -811,6 +812,51 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
}
}
private void doCloseAfterTxsVerified(Button closeTicketButton) {
var disputeManager = getDisputeManager(dispute);
// Only RefundAgent need to verify transactions to ensure payout is safe
if (disputeManager instanceof RefundManager && Config.baseCurrencyNetwork().isMainnet()) {
RefundManager refundManager = (RefundManager) disputeManager;
Contract contract = dispute.getContract();
String makerFeeTxId = contract.getOfferPayload().getOfferFeePaymentTxId();
String takerFeeTxId = contract.getTakerFeeTxID();
String depositTxId = dispute.getDepositTxId();
String delayedPayoutTxId = dispute.getDelayedPayoutTxId();
Popup requestingTxsPopup = new Popup().feedback(Res.get("disputeSummaryWindow.requestingTxs"));
requestingTxsPopup.show();
refundManager.requestBlockchainTransactions(makerFeeTxId,
takerFeeTxId,
depositTxId,
delayedPayoutTxId
).whenComplete((txList, throwable) -> {
UserThread.execute(() -> {
if (throwable == null) {
try {
requestingTxsPopup.hide();
refundManager.verifyTradeTxChain(txList);
doCloseIfValid(closeTicketButton);
} catch (Throwable error) {
UserThread.runAfter(() ->
new Popup().warning(Res.get("disputeSummaryWindow.delayedPayoutTxVerificationFailed", error.getMessage()))
.show(),
100,
TimeUnit.MILLISECONDS);
}
} else {
UserThread.runAfter(() ->
new Popup().warning(Res.get("disputeSummaryWindow.requestTransactionsError", throwable.getMessage()))
.onAction(() -> doCloseIfValid(closeTicketButton))
.show(),
100,
TimeUnit.MILLISECONDS);
}
});
});
} else {
doCloseIfValid(closeTicketButton);
}
}
private void doCloseIfValid(Button closeTicketButton) {
var disputeManager = checkNotNull(getDisputeManager(dispute));
try {