recover payment sent message state on startup if undefined

This commit is contained in:
woodser 2025-03-20 08:02:01 -04:00
parent cce7c204f3
commit 8581c9b15e
No known key found for this signature in database
GPG key ID: 55A10DD48ADEE5EF
2 changed files with 30 additions and 1 deletions
core/src/main/java/haveno/core/trade
desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades

View file

@ -46,6 +46,7 @@ import haveno.common.taskrunner.Model;
import haveno.common.util.Utilities;
import haveno.core.monetary.Price;
import haveno.core.monetary.Volume;
import haveno.core.network.MessageState;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection;
import haveno.core.offer.OpenOffer;
@ -738,6 +739,15 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
xmrWalletService.addWalletListener(idlePayoutSyncer);
}
// TODO: buyer's payment sent message state property became unsynced if shut down while awaiting ack from seller. fixed mismatch in v1.0.19, but can this check can be removed?
if (isBuyer()) {
MessageState expectedState = getPaymentSentMessageState();
if (expectedState != null && expectedState != getSeller().getPaymentSentMessageStateProperty().get()) {
log.warn("Updating unexpected payment sent message state for {} {}, expected={}, actual={}", getClass().getSimpleName(), getId(), expectedState, processModel.getPaymentSentMessageStatePropertySeller().get());
getSeller().getPaymentSentMessageStateProperty().set(expectedState);
}
}
// handle confirmations
walletHeight.addListener((observable, oldValue, newValue) -> {
importMultisigHexIfScheduled();
@ -2074,6 +2084,25 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
}
private MessageState getPaymentSentMessageState() {
if (isPaymentReceived()) return MessageState.ACKNOWLEDGED;
if (getSeller().getPaymentSentMessageStateProperty().get() == MessageState.ACKNOWLEDGED) return MessageState.ACKNOWLEDGED;
switch (state) {
case BUYER_SENT_PAYMENT_SENT_MSG:
return MessageState.SENT;
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
return MessageState.ARRIVED;
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
return MessageState.STORED_IN_MAILBOX;
case SELLER_RECEIVED_PAYMENT_SENT_MSG:
return MessageState.ACKNOWLEDGED;
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG:
return MessageState.FAILED;
default:
return null;
}
}
public String getPeerRole(TradePeer peer) {
if (peer == getBuyer()) return "Buyer";
if (peer == getSeller()) return "Seller";

View file

@ -424,7 +424,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
}
break;
// seller step 3
// seller step 3 or 4 if published
case SELLER_CONFIRMED_PAYMENT_RECEIPT:
case SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG:
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG: