Skip to content

Commit 8c0f453

Browse files
committed
set error on revert state, deposit seen fixes
1 parent 02bd1dc commit 8c0f453

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,8 +2720,7 @@ private void tryInitSyncing() {
27202720
if (isShutDownStarted) return;
27212721

27222722
// set known deposit txs
2723-
List<MoneroTxWallet> depositTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true).setInTxPool(false));
2724-
setDepositTxs(depositTxs);
2723+
doPollWallet(true);
27252724

27262725
// start polling
27272726
if (isIdling() && isArbitrator()) {
@@ -2986,15 +2985,17 @@ private void onPayoutInvalidated() {
29862985
}
29872986
setPayoutState(PayoutState.PAYOUT_UNPUBLISHED);
29882987
if (isCompleted()) processModel.getTradeManager().onMoveClosedTradeToPendingTrades(this);
2988+
String errorMsg = "The payout transaction is missing for trade " + getShortId() + ". This may be due to a blockchain reorganization.\n\nIf the payout does not confirm automatically, you can open a dispute or mark this trade as failed.";
29892989
if (isSeller() && getState().ordinal() >= State.BUYER_RECEIVED_PAYMENT_RECEIVED_MSG.ordinal()) {
29902990
log.warn("Resetting state of {} {} from {} to {} because payout is unpublished", getClass().getSimpleName(), getId(), getState(), Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
29912991
setState(State.SELLER_SENT_PAYMENT_RECEIVED_MSG);
29922992
onPayoutError(false, true, null);
2993+
setErrorMessage(errorMsg);
29932994
} else if (getState().ordinal() >= State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal()) {
29942995
log.warn("Resetting state of {} {} from {} to {} because payout is unpublished", getClass().getSimpleName(), getId(), getState(), Trade.State.SELLER_CONFIRMED_PAYMENT_RECEIPT);
29952996
setState(State.SELLER_CONFIRMED_PAYMENT_RECEIPT);
2997+
setErrorMessage(errorMsg);
29962998
}
2997-
setErrorMessage("The payout transaction is missing for trade " + getShortId() + ". This may be due to a blockchain reorganization.\n\nIf the payout does not confirm automatically, you can open a dispute or mark this trade as failed.");
29982999
}
29993000

30003001
/**
@@ -3045,13 +3046,6 @@ public boolean onPayoutError(boolean syncAndPoll, boolean resendPaymentReceivedM
30453046
return false;
30463047
}
30473048

3048-
private static boolean isSeen(MoneroTx tx) {
3049-
if (tx == null) return false;
3050-
if (Boolean.TRUE.equals(tx.isFailed())) return false;
3051-
if (!Boolean.TRUE.equals(tx.inTxPool()) && !Boolean.TRUE.equals(tx.isConfirmed())) return false;
3052-
return true;
3053-
}
3054-
30553049
private static boolean isUnlocked(MoneroTx tx) {
30563050
if (tx == null) return false;
30573051
if (tx.getNumConfirmations() == null || tx.getNumConfirmations() < XmrWalletService.NUM_BLOCKS_UNLOCK) return false;
@@ -3137,6 +3131,13 @@ private void setDepositTxs(List<MoneroTxWallet> txs) {
31373131
depositTxsUpdateCounter.set(depositTxsUpdateCounter.get() + 1);
31383132
}
31393133

3134+
private static boolean isSeen(MoneroTx tx) {
3135+
if (tx == null) return false;
3136+
if (Boolean.TRUE.equals(tx.isFailed())) return false;
3137+
if (!Boolean.TRUE.equals(tx.inTxPool()) && !Boolean.TRUE.equals(tx.isConfirmed())) return false;
3138+
return true;
3139+
}
3140+
31403141
private State getDepositsState() {
31413142
if (getMaker().getDepositTx() == null || (!hasBuyerAsTakerWithoutDeposit() && getTaker().getDepositTx() == null)) return State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS;
31423143
if (getMaker().getDepositTx().isFailed() || (!hasBuyerAsTakerWithoutDeposit() && getTaker().getDepositTx().isFailed())) return State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS;
@@ -3329,7 +3330,7 @@ private void forceRestartTradeWallet() {
33293330
}
33303331

33313332
private void setStateDepositsSeen() {
3332-
if (!isDepositsPublished()) setState(State.DEPOSIT_TXS_SEEN_IN_NETWORK);
3333+
if (getState().ordinal() < State.DEPOSIT_TXS_SEEN_IN_NETWORK.ordinal()) setState(State.DEPOSIT_TXS_SEEN_IN_NETWORK);
33333334
}
33343335

33353336
private void setStateDepositsConfirmed() {

0 commit comments

Comments
 (0)