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:
woodser 2023-04-21 09:52:31 -04:00
parent 7e8e145c85
commit 33147e1c7c
6 changed files with 13 additions and 11 deletions

View file

@ -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.PAYMENT_SENT;
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.SELLER_RECEIVED_PAYMENT_SENT_MSG;
import static java.lang.String.format;
import static java.lang.System.out;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -144,7 +144,7 @@ public class AbstractTradeTest extends AbstractOfferTest {
GrpcClient grpcClient,
String tradeId) {
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());
String userName = toUserName.apply(grpcClient);
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {

View file

@ -494,7 +494,7 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
if (trade.isArbitrator() && message.getPaymentSentMessage() != null) {
HavenoUtils.verifyPaymentSentMessage(trade, message.getPaymentSentMessage());
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

View file

@ -609,8 +609,8 @@ public abstract class Trade implements Tradable, Model {
// 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()) {
log.warn("Resetting state of {} {} from {} to {} because no ack was received", getClass().getSimpleName(), getId(), getState(), Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG);
setState(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.BUYER_SENT_PAYMENT_SENT_MSG);
}
// handle trade phase events

View file

@ -70,7 +70,7 @@ public class ProcessPaymentSentMessage extends TradeTask {
}
// 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();
complete();
} catch (Throwable t) {

View file

@ -377,8 +377,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
case SENT_PUBLISH_DEPOSIT_TX_REQUEST:
case SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST:
case SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST:
sellerState.set(UNDEFINED); // TODO: show view while trade initializes?
buyerState.set(BuyerState.UNDEFINED);
sellerState.set(UNDEFINED); // TODO: show view while trade initializes?
break;
case ARBITRATOR_PUBLISHED_DEPOSIT_TXS:
@ -391,18 +391,20 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
// buyer and seller step 2
// deposits unlocked
case DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN:
sellerState.set(SellerState.STEP2);
buyerState.set(BuyerState.STEP2);
sellerState.set(SellerState.STEP2);
break;
// buyer step 3
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT: // UI action
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
buyerState.set(BuyerState.STEP2);
sellerState.set(trade.isPayoutPublished() ? SellerState.STEP4 : SellerState.STEP3);
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);
break;
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG failed
@ -417,7 +419,6 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
break;
// seller step 3
case SELLER_RECEIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG received
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT:
case SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG:
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG:

View file

@ -156,6 +156,7 @@ public class BuyerStep2View extends TradeStepView {
statusLabel.setText(Res.get("shared.preparingConfirmation"));
break;
case BUYER_SENT_PAYMENT_SENT_MSG:
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(MessageState.SENT);