mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-25 07:10:48 -04:00
recover payment sent message state on startup if undefined
This commit is contained in:
parent
a7d8e4560f
commit
ce27818f43
2 changed files with 30 additions and 1 deletions
|
@ -46,6 +46,7 @@ import haveno.common.taskrunner.Model;
|
||||||
import haveno.common.util.Utilities;
|
import haveno.common.util.Utilities;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
import haveno.core.monetary.Volume;
|
import haveno.core.monetary.Volume;
|
||||||
|
import haveno.core.network.MessageState;
|
||||||
import haveno.core.offer.Offer;
|
import haveno.core.offer.Offer;
|
||||||
import haveno.core.offer.OfferDirection;
|
import haveno.core.offer.OfferDirection;
|
||||||
import haveno.core.offer.OpenOffer;
|
import haveno.core.offer.OpenOffer;
|
||||||
|
@ -738,6 +739,15 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
xmrWalletService.addWalletListener(idlePayoutSyncer);
|
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
|
// handle confirmations
|
||||||
walletHeight.addListener((observable, oldValue, newValue) -> {
|
walletHeight.addListener((observable, oldValue, newValue) -> {
|
||||||
importMultisigHexIfScheduled();
|
importMultisigHexIfScheduled();
|
||||||
|
@ -2074,6 +2084,25 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
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) {
|
public String getPeerRole(TradePeer peer) {
|
||||||
if (peer == getBuyer()) return "Buyer";
|
if (peer == getBuyer()) return "Buyer";
|
||||||
if (peer == getSeller()) return "Seller";
|
if (peer == getSeller()) return "Seller";
|
||||||
|
|
|
@ -424,7 +424,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// seller step 3
|
// seller step 3 or 4 if published
|
||||||
case SELLER_CONFIRMED_PAYMENT_RECEIPT:
|
case SELLER_CONFIRMED_PAYMENT_RECEIPT:
|
||||||
case SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG:
|
case SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG:
|
||||||
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG:
|
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue