mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00:00
use BUYER_SENT_PAYMENT_SENT_MSG when peers see payment sent message
use SELLER_RECEIVED_PAYMENT_SENT_MSG only for ack to buyer
This commit is contained in:
parent
7e8e145c85
commit
33147e1c7c
6 changed files with 13 additions and 11 deletions
|
@ -18,8 +18,8 @@ import static haveno.cli.table.builder.TableType.TRADE_DETAIL_TBL;
|
||||||
import static haveno.core.trade.Trade.Phase.DEPOSITS_UNLOCKED;
|
import static haveno.core.trade.Trade.Phase.DEPOSITS_UNLOCKED;
|
||||||
import static haveno.core.trade.Trade.Phase.PAYMENT_SENT;
|
import static haveno.core.trade.Trade.Phase.PAYMENT_SENT;
|
||||||
import static haveno.core.trade.Trade.State.BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG;
|
import static haveno.core.trade.Trade.State.BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG;
|
||||||
|
import static haveno.core.trade.Trade.State.BUYER_SENT_PAYMENT_SENT_MSG;
|
||||||
import static haveno.core.trade.Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN;
|
import static haveno.core.trade.Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN;
|
||||||
import static haveno.core.trade.Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG;
|
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import static java.lang.System.out;
|
import static java.lang.System.out;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
@ -144,7 +144,7 @@ public class AbstractTradeTest extends AbstractOfferTest {
|
||||||
GrpcClient grpcClient,
|
GrpcClient grpcClient,
|
||||||
String tradeId) {
|
String tradeId) {
|
||||||
Predicate<TradeInfo> isTradeInPaymentReceiptConfirmedStateAndPhase = (t) ->
|
Predicate<TradeInfo> isTradeInPaymentReceiptConfirmedStateAndPhase = (t) ->
|
||||||
t.getState().equals(SELLER_RECEIVED_PAYMENT_SENT_MSG.name()) &&
|
t.getState().equals(BUYER_SENT_PAYMENT_SENT_MSG.name()) &&
|
||||||
t.getPhase().equals(PAYMENT_SENT.name());
|
t.getPhase().equals(PAYMENT_SENT.name());
|
||||||
String userName = toUserName.apply(grpcClient);
|
String userName = toUserName.apply(grpcClient);
|
||||||
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
||||||
|
|
|
@ -494,7 +494,7 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
|
||||||
if (trade.isArbitrator() && message.getPaymentSentMessage() != null) {
|
if (trade.isArbitrator() && message.getPaymentSentMessage() != null) {
|
||||||
HavenoUtils.verifyPaymentSentMessage(trade, message.getPaymentSentMessage());
|
HavenoUtils.verifyPaymentSentMessage(trade, message.getPaymentSentMessage());
|
||||||
trade.getBuyer().setUpdatedMultisigHex(message.getPaymentSentMessage().getUpdatedMultisigHex());
|
trade.getBuyer().setUpdatedMultisigHex(message.getPaymentSentMessage().getUpdatedMultisigHex());
|
||||||
trade.advanceState(sender == trade.getBuyer() ? Trade.State.BUYER_SENT_PAYMENT_SENT_MSG : Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG);
|
trade.advanceState(Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update multisig hex
|
// update multisig hex
|
||||||
|
|
|
@ -609,8 +609,8 @@ public abstract class Trade implements Tradable, Model {
|
||||||
|
|
||||||
// reset seller's payment received state if no ack receive
|
// reset seller's payment received state if no ack receive
|
||||||
if (this instanceof SellerTrade && getState().ordinal() >= Trade.State.SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT.ordinal() && getState().ordinal() < Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG.ordinal()) {
|
if (this instanceof SellerTrade && getState().ordinal() >= Trade.State.SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT.ordinal() && getState().ordinal() < Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG.ordinal()) {
|
||||||
log.warn("Resetting state of {} {} from {} to {} because no ack was received", getClass().getSimpleName(), getId(), getState(), Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG);
|
log.warn("Resetting state of {} {} from {} to {} because no ack was received", getClass().getSimpleName(), getId(), getState(), Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
||||||
setState(Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG);
|
setState(Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle trade phase events
|
// handle trade phase events
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class ProcessPaymentSentMessage extends TradeTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update state
|
// update state
|
||||||
trade.advanceState(trade.isSeller() ? Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG : Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
trade.advanceState(Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
||||||
trade.requestPersistence();
|
trade.requestPersistence();
|
||||||
complete();
|
complete();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -377,8 +377,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
case SENT_PUBLISH_DEPOSIT_TX_REQUEST:
|
case SENT_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||||
case SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST:
|
case SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||||
case SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST:
|
case SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST:
|
||||||
sellerState.set(UNDEFINED); // TODO: show view while trade initializes?
|
|
||||||
buyerState.set(BuyerState.UNDEFINED);
|
buyerState.set(BuyerState.UNDEFINED);
|
||||||
|
sellerState.set(UNDEFINED); // TODO: show view while trade initializes?
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARBITRATOR_PUBLISHED_DEPOSIT_TXS:
|
case ARBITRATOR_PUBLISHED_DEPOSIT_TXS:
|
||||||
|
@ -391,18 +391,20 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
// buyer and seller step 2
|
// buyer and seller step 2
|
||||||
// deposits unlocked
|
// deposits unlocked
|
||||||
case DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN:
|
case DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN:
|
||||||
sellerState.set(SellerState.STEP2);
|
|
||||||
buyerState.set(BuyerState.STEP2);
|
buyerState.set(BuyerState.STEP2);
|
||||||
|
sellerState.set(SellerState.STEP2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// buyer step 3
|
// buyer step 3
|
||||||
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT: // UI action
|
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT: // UI action
|
||||||
case BUYER_SENT_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG sent
|
case BUYER_SENT_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG sent
|
||||||
|
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG arrived
|
||||||
// We don't switch the UI before we got the feedback of the msg delivery
|
// We don't switch the UI before we got the feedback of the msg delivery
|
||||||
buyerState.set(BuyerState.STEP2);
|
buyerState.set(BuyerState.STEP2);
|
||||||
|
sellerState.set(trade.isPayoutPublished() ? SellerState.STEP4 : SellerState.STEP3);
|
||||||
break;
|
break;
|
||||||
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG arrived
|
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG in mailbox
|
||||||
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG in mailbox
|
case SELLER_RECEIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG acked
|
||||||
buyerState.set(BuyerState.STEP3);
|
buyerState.set(BuyerState.STEP3);
|
||||||
break;
|
break;
|
||||||
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG failed
|
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG failed
|
||||||
|
@ -417,7 +419,6 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// seller step 3
|
// seller step 3
|
||||||
case SELLER_RECEIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG received
|
|
||||||
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT:
|
case SELLER_CONFIRMED_IN_UI_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:
|
||||||
|
|
|
@ -156,6 +156,7 @@ public class BuyerStep2View extends TradeStepView {
|
||||||
statusLabel.setText(Res.get("shared.preparingConfirmation"));
|
statusLabel.setText(Res.get("shared.preparingConfirmation"));
|
||||||
break;
|
break;
|
||||||
case BUYER_SENT_PAYMENT_SENT_MSG:
|
case BUYER_SENT_PAYMENT_SENT_MSG:
|
||||||
|
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
|
||||||
busyAnimation.play();
|
busyAnimation.play();
|
||||||
statusLabel.setText(Res.get("shared.sendingConfirmation"));
|
statusLabel.setText(Res.get("shared.sendingConfirmation"));
|
||||||
model.setMessageStateProperty(MessageState.SENT);
|
model.setMessageStateProperty(MessageState.SENT);
|
||||||
|
|
Loading…
Reference in a new issue