Fix bug at mediation with old client

If dispute opener is old client the delayed payout tx is not sent in mediation case (only in refund agent cases).
At 1.4.0 we send it as well in mediation case and the mediator get a warning shown in case its missing.
To avoid that warning we check if dispute is of refund agent type and only check in that case.
This can be removed once we have enforced update to 1.4.0 (segwit will require that).
Also added checks to not add null entries in the duplicates checks.
This commit is contained in:
chimp1984 2020-10-13 10:26:20 -05:00
parent 41b2e6a56d
commit 3b4d109652
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 30 additions and 15 deletions

View file

@ -103,7 +103,7 @@ public final class Dispute implements NetworkPayload, PersistablePayload {
@Nullable @Nullable
private String delayedPayoutTxId; private String delayedPayoutTxId;
// Added at v1.3.9 // Added at v1.4.0
@Setter @Setter
@Nullable @Nullable
private String donationAddressOfDelayedPayoutTx; private String donationAddressOfDelayedPayoutTx;

View file

@ -20,6 +20,7 @@ package bisq.core.trade;
import bisq.core.btc.wallet.BtcWalletService; import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.DaoFacade; import bisq.core.dao.DaoFacade;
import bisq.core.offer.Offer; import bisq.core.offer.Offer;
import bisq.core.support.SupportType;
import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.Dispute;
import bisq.core.util.validation.RegexValidatorFactory; import bisq.core.util.validation.RegexValidatorFactory;
@ -136,14 +137,18 @@ public class TradeDataValidation {
set.add(uid); set.add(uid);
String delayedPayoutTxId = dispute.getDelayedPayoutTxId(); String delayedPayoutTxId = dispute.getDelayedPayoutTxId();
disputesPerDelayedPayoutTxId.putIfAbsent(delayedPayoutTxId, new HashSet<>()); if (delayedPayoutTxId != null) {
set = disputesPerDelayedPayoutTxId.get(delayedPayoutTxId); disputesPerDelayedPayoutTxId.putIfAbsent(delayedPayoutTxId, new HashSet<>());
set.add(uid); set = disputesPerDelayedPayoutTxId.get(delayedPayoutTxId);
set.add(uid);
}
String depositTxId = dispute.getDepositTxId(); String depositTxId = dispute.getDepositTxId();
disputesPerDepositTxId.putIfAbsent(depositTxId, new HashSet<>()); if (depositTxId != null) {
set = disputesPerDepositTxId.get(depositTxId); disputesPerDepositTxId.putIfAbsent(depositTxId, new HashSet<>());
set.add(uid); set = disputesPerDepositTxId.get(depositTxId);
set.add(uid);
}
}); });
return new Tuple3<>(disputesPerTradeId, disputesPerDelayedPayoutTxId, disputesPerDepositTxId); return new Tuple3<>(disputesPerTradeId, disputesPerDelayedPayoutTxId, disputesPerDepositTxId);
@ -161,8 +166,14 @@ public class TradeDataValidation {
String disputeToTestDepositTxId = disputeToTest.getDepositTxId(); String disputeToTestDepositTxId = disputeToTest.getDepositTxId();
String disputeToTestUid = disputeToTest.getUid(); String disputeToTestUid = disputeToTest.getUid();
checkNotNull(disputeToTestDelayedPayoutTxId, // For pre v1.4.0 we do not get the delayed payout tx sent in mediation cases but in refund agent case we do.
"delayedPayoutTxId must not be null. Trade ID: " + disputeToTestTradeId); // So until all users have updated to 1.4.0 we only check in refund agent case. With 1.4.0 we send the
// delayed payout tx also in mediation cases and that if check can be removed.
if (disputeToTest.getSupportType() == SupportType.REFUND) {
checkNotNull(disputeToTestDelayedPayoutTxId,
"Delayed payout transaction ID is null. " +
"Trade ID: " + disputeToTestTradeId);
}
checkNotNull(disputeToTestDepositTxId, checkNotNull(disputeToTestDepositTxId,
"depositTxId must not be null. Trade ID: " + disputeToTestTradeId); "depositTxId must not be null. Trade ID: " + disputeToTestTradeId);
checkNotNull(disputeToTestUid, checkNotNull(disputeToTestUid,
@ -171,12 +182,16 @@ public class TradeDataValidation {
checkArgument(disputesPerTradeId.get(disputeToTestTradeId).size() <= 2, checkArgument(disputesPerTradeId.get(disputeToTestTradeId).size() <= 2,
"We found more then 2 disputes with the same trade ID. " + "We found more then 2 disputes with the same trade ID. " +
"Trade ID: " + disputeToTestTradeId); "Trade ID: " + disputeToTestTradeId);
checkArgument(disputesPerDelayedPayoutTxId.get(disputeToTestDelayedPayoutTxId).size() <= 2, if (!disputesPerDelayedPayoutTxId.isEmpty()) {
"We found more then 2 disputes with the same delayedPayoutTxId. " + checkArgument(disputesPerDelayedPayoutTxId.get(disputeToTestDelayedPayoutTxId).size() <= 2,
"Trade ID: " + disputeToTestTradeId); "We found more then 2 disputes with the same delayedPayoutTxId. " +
checkArgument(disputesPerDepositTxId.get(disputeToTestDepositTxId).size() <= 2, "Trade ID: " + disputeToTestTradeId);
"We found more then 2 disputes with the same depositTxId. " + }
"Trade ID: " + disputeToTestTradeId); if (!disputesPerDepositTxId.isEmpty()) {
checkArgument(disputesPerDepositTxId.get(disputeToTestDepositTxId).size() <= 2,
"We found more then 2 disputes with the same depositTxId. " +
"Trade ID: " + disputeToTestTradeId);
}
} catch (IllegalArgumentException | NullPointerException e) { } catch (IllegalArgumentException | NullPointerException e) {
throw new DisputeReplayException(disputeToTest, e.getMessage()); throw new DisputeReplayException(disputeToTest, e.getMessage());