Skip to content

Commit 138527a

Browse files
committed
fixes when a deposit transaction does not confirm
1 parent 017d8d5 commit 138527a

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

core/src/main/java/haveno/core/support/dispute/DisputeValidation.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@
4242
public class DisputeValidation {
4343

4444
public static void validatePaymentAccountPayloads(Dispute dispute) throws ValidationException {
45-
if (dispute.getSellerPaymentAccountPayload() == null) throw new ValidationException(dispute, "Seller's payment account payload is null in dispute opened for trade " + dispute.getTradeId());
46-
if (!Arrays.equals(dispute.getSellerPaymentAccountPayload().getHash(), dispute.getContract().getSellerPaymentAccountPayloadHash())) throw new ValidationException(dispute, "Hash of seller's payment account payload does not match contract");
45+
if (dispute.getSellerPaymentAccountPayload() != null) {
46+
if (!Arrays.equals(dispute.getSellerPaymentAccountPayload().getHash(), dispute.getContract().getSellerPaymentAccountPayloadHash())) {
47+
throw new ValidationException(dispute, "Hash of seller's payment account payload does not match contract");
48+
}
49+
}
4750
if (dispute.getBuyerPaymentAccountPayload() != null) {
48-
if (!Arrays.equals(dispute.getBuyerPaymentAccountPayload().getHash(), dispute.getContract().getBuyerPaymentAccountPayloadHash())) throw new ValidationException(dispute, "Hash of buyer's payment account payload does not match contract");
51+
if (!Arrays.equals(dispute.getBuyerPaymentAccountPayload().getHash(), dispute.getContract().getBuyerPaymentAccountPayloadHash())) {
52+
throw new ValidationException(dispute, "Hash of buyer's payment account payload does not match contract");
53+
}
4954
}
5055
}
5156

core/src/main/java/haveno/core/trade/Trade.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,8 +2710,6 @@ private void doPollWallet() {
27102710
}
27112711
}
27122712
setDepositTxs(txs);
2713-
if (!isPublished(getMaker().getDepositTx()) || (!hasBuyerAsTakerWithoutDeposit() && !isPublished(getTaker().getDepositTx()))) return; // skip if deposit txs not published successfully
2714-
setStateDepositsSeen();
27152713

27162714
// set actual security deposits
27172715
if (getBuyer().getDepositTx() != null) {
@@ -2729,17 +2727,23 @@ private void doPollWallet() {
27292727
getSeller().setSecurityDeposit(sellerSecurityDeposit);
27302728
}
27312729

2732-
// check for deposit txs confirmation
2733-
if (getMaker().getDepositTx().isConfirmed() && (hasBuyerAsTakerWithoutDeposit() || getTaker().getDepositTx().isConfirmed())) setStateDepositsConfirmed();
2730+
// handle deposits seen
2731+
if (isPublished(getMaker().getDepositTx()) && (hasBuyerAsTakerWithoutDeposit() || isPublished(getTaker().getDepositTx()))) {
2732+
setStateDepositsSeen();
27342733

2735-
// check for deposit txs unlocked
2736-
if (getMaker().getDepositTx().getNumConfirmations() >= XmrWalletService.NUM_BLOCKS_UNLOCK && (hasBuyerAsTakerWithoutDeposit() || getTaker().getDepositTx().getNumConfirmations() >= XmrWalletService.NUM_BLOCKS_UNLOCK)) {
2737-
setStateDepositsUnlocked();
2734+
// check for deposit txs confirmed
2735+
if (getMaker().getDepositTx().isConfirmed() && (hasBuyerAsTakerWithoutDeposit() || getTaker().getDepositTx().isConfirmed())) setStateDepositsConfirmed();
2736+
2737+
// check for deposit txs unlocked
2738+
if (getMaker().getDepositTx().getNumConfirmations() >= XmrWalletService.NUM_BLOCKS_UNLOCK && (hasBuyerAsTakerWithoutDeposit() || getTaker().getDepositTx().getNumConfirmations() >= XmrWalletService.NUM_BLOCKS_UNLOCK)) {
2739+
setStateDepositsUnlocked();
2740+
}
27382741
}
27392742
}
27402743

27412744
// check for payout tx
2742-
if (isDepositsUnlocked()) {
2745+
boolean hasUnlockedDeposit = isUnlocked(getMaker().getDepositTx()) || isUnlocked(getTaker().getDepositTx());
2746+
if (hasUnlockedDeposit) {
27432747

27442748
// determine if payout tx expected
27452749
boolean isPayoutExpected = isPaymentReceived() || hasPaymentReceivedMessage() || hasDisputeClosedMessage() || disputeState.ordinal() >= DisputeState.ARBITRATOR_SENT_DISPUTE_CLOSED_MSG.ordinal();
@@ -2827,6 +2831,12 @@ private static boolean isPublished(MoneroTx tx) {
28272831
return true;
28282832
}
28292833

2834+
private static boolean isUnlocked(MoneroTx tx) {
2835+
if (tx == null) return false;
2836+
if (tx.getNumConfirmations() == null || tx.getNumConfirmations() < XmrWalletService.NUM_BLOCKS_UNLOCK) return false;
2837+
return true;
2838+
}
2839+
28302840
private void syncWalletIfBehind() {
28312841
synchronized (walletLock) {
28322842
if (isWalletBehind()) {

0 commit comments

Comments
 (0)