|
74 | 74 | import haveno.network.p2p.NodeAddress;
|
75 | 75 | import haveno.network.p2p.P2PService;
|
76 | 76 | import haveno.network.p2p.network.TorNetworkNode;
|
| 77 | +import javafx.beans.property.BooleanProperty; |
77 | 78 | import javafx.beans.property.DoubleProperty;
|
78 | 79 | import javafx.beans.property.IntegerProperty;
|
79 | 80 | import javafx.beans.property.ObjectProperty;
|
80 | 81 | import javafx.beans.property.ReadOnlyDoubleProperty;
|
81 | 82 | import javafx.beans.property.ReadOnlyObjectProperty;
|
82 | 83 | import javafx.beans.property.ReadOnlyStringProperty;
|
| 84 | +import javafx.beans.property.SimpleBooleanProperty; |
83 | 85 | import javafx.beans.property.SimpleDoubleProperty;
|
84 | 86 | import javafx.beans.property.SimpleIntegerProperty;
|
85 | 87 | import javafx.beans.property.SimpleObjectProperty;
|
@@ -153,6 +155,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
153 | 155 | private Subscription protocolErrorStateSubscription;
|
154 | 156 | private Subscription protocolErrorHeightSubscription;
|
155 | 157 | public static final String PROTOCOL_VERSION = "protocolVersion"; // key for extraDataMap in trade statistics
|
| 158 | + private BooleanProperty wasWalletPolled = new SimpleBooleanProperty(false); |
156 | 159 |
|
157 | 160 | ///////////////////////////////////////////////////////////////////////////////////////////
|
158 | 161 | // Enums
|
@@ -639,21 +642,23 @@ public void initialize(ProcessModelServiceProvider serviceProvider) {
|
639 | 642 | ThreadUtils.execute(() -> onConnectionChanged(connection), getId());
|
640 | 643 | });
|
641 | 644 |
|
642 |
| - // reset states if no ack receive |
643 |
| - if (!isPayoutPublished()) { |
| 645 | + // reset state after first poll if necessary |
| 646 | + wasWalletPolled.addListener((observable, oldValue, newValue) -> { |
| 647 | + if (!isPayoutPublished()) { |
644 | 648 |
|
645 |
| - // reset buyer's payment sent state if no ack receive |
646 |
| - if (this instanceof BuyerTrade && getState().ordinal() >= Trade.State.BUYER_CONFIRMED_PAYMENT_SENT.ordinal() && getState().ordinal() < Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG.ordinal()) { |
647 |
| - log.warn("Resetting state of {} {} from {} to {} because no ack was received", getClass().getSimpleName(), getId(), getState(), Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN); |
648 |
| - setState(Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN); |
649 |
| - } |
650 |
| - |
651 |
| - // reset seller's payment received state if no ack receive |
652 |
| - if (this instanceof SellerTrade && getState().ordinal() >= Trade.State.SELLER_CONFIRMED_PAYMENT_RECEIPT.ordinal() && getState().ordinal() < Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG.ordinal()) { |
653 |
| - log.warn("Resetting state of {} {} from {} to {} because no ack was received", getClass().getSimpleName(), getId(), getState(), Trade.State.BUYER_SENT_PAYMENT_SENT_MSG); |
654 |
| - resetToPaymentSentState(); |
655 |
| - } |
656 |
| - } |
| 649 | + // reset buyer's payment sent state if no ack received |
| 650 | + if (this instanceof BuyerTrade && getState().ordinal() >= Trade.State.BUYER_CONFIRMED_PAYMENT_SENT.ordinal() && getState().ordinal() < Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG.ordinal() && getState() != Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG) { |
| 651 | + log.warn("Resetting state of {} {} from {} to {} because payout is not published", getClass().getSimpleName(), getId(), getState(), Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN); |
| 652 | + setState(Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN); |
| 653 | + } |
| 654 | + |
| 655 | + // reset seller's payment received state unless stored in mailbox |
| 656 | + if (this instanceof SellerTrade && getState().ordinal() >= Trade.State.SELLER_CONFIRMED_PAYMENT_RECEIPT.ordinal() && getState().ordinal() != Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG.ordinal()) { |
| 657 | + log.warn("Resetting state of {} {} from {} to {} because payout is not published", getClass().getSimpleName(), getId(), getState(), Trade.State.BUYER_SENT_PAYMENT_SENT_MSG); |
| 658 | + resetToPaymentSentState(); |
| 659 | + } |
| 660 | + }; |
| 661 | + }); |
657 | 662 |
|
658 | 663 | // handle trade state events
|
659 | 664 | tradeStateSubscription = EasyBind.subscribe(stateProperty, newValue -> {
|
@@ -2840,6 +2845,7 @@ else if (hasFailedTx && isPayoutPublished()) {
|
2840 | 2845 | pollInProgress = false;
|
2841 | 2846 | }
|
2842 | 2847 | }
|
| 2848 | + wasWalletPolled.set(true); |
2843 | 2849 | saveWalletWithDelay();
|
2844 | 2850 | }
|
2845 | 2851 | }
|
|
0 commit comments