mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
seller state is PAYMENT_RECEIVED or PAYOUT_PUBLISHED after confirming
This commit is contained in:
parent
730bee3e71
commit
2d3043093e
@ -162,14 +162,14 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
|||||||
trade = aliceClient.getTrade(tradeId);
|
trade = aliceClient.getTrade(tradeId);
|
||||||
|
|
||||||
if (!trade.getIsPaymentSent()) {
|
if (!trade.getIsPaymentSent()) {
|
||||||
log.warn("Alice still waiting for trade {} BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG, attempt # {}",
|
log.warn("Alice still waiting for trade {} BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG, attempt # {}",
|
||||||
trade.getShortId(),
|
trade.getShortId(),
|
||||||
i);
|
i);
|
||||||
sleep(5000);
|
sleep(5000);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
assertEquals(OFFER_FEE_PAID.name(), trade.getOffer().getState());
|
assertEquals(OFFER_FEE_PAID.name(), trade.getOffer().getState());
|
||||||
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG)
|
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG)
|
||||||
.setPhase(PAYMENT_SENT)
|
.setPhase(PAYMENT_SENT)
|
||||||
.setFiatSent(true);
|
.setFiatSent(true);
|
||||||
verifyExpectedProtocolStatus(trade);
|
verifyExpectedProtocolStatus(trade);
|
||||||
@ -189,7 +189,7 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
|||||||
var trade = bobClient.getTrade(tradeId);
|
var trade = bobClient.getTrade(tradeId);
|
||||||
|
|
||||||
Predicate<TradeInfo> tradeStateAndPhaseCorrect = (t) ->
|
Predicate<TradeInfo> tradeStateAndPhaseCorrect = (t) ->
|
||||||
t.getState().equals(SELLER_RECEIVED_PAYMENT_INITIATED_MSG.name())
|
t.getState().equals(SELLER_RECEIVED_PAYMENT_SENT_MSG.name())
|
||||||
&& (t.getPhase().equals(PAYOUT_PUBLISHED.name()) || t.getPhase().equals(PAYMENT_SENT.name()));
|
&& (t.getPhase().equals(PAYOUT_PUBLISHED.name()) || t.getPhase().equals(PAYMENT_SENT.name()));
|
||||||
|
|
||||||
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
||||||
|
@ -164,7 +164,7 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
|||||||
trade = bobClient.getTrade(tradeId);
|
trade = bobClient.getTrade(tradeId);
|
||||||
|
|
||||||
if (!trade.getIsPaymentSent()) {
|
if (!trade.getIsPaymentSent()) {
|
||||||
log.warn("Bob still waiting for trade {} BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG, attempt # {}",
|
log.warn("Bob still waiting for trade {} BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG, attempt # {}",
|
||||||
trade.getShortId(),
|
trade.getShortId(),
|
||||||
i);
|
i);
|
||||||
sleep(5000);
|
sleep(5000);
|
||||||
@ -172,7 +172,7 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
|||||||
} else {
|
} else {
|
||||||
// Note: offer.state == available
|
// Note: offer.state == available
|
||||||
assertEquals(AVAILABLE.name(), trade.getOffer().getState());
|
assertEquals(AVAILABLE.name(), trade.getOffer().getState());
|
||||||
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG)
|
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG)
|
||||||
.setPhase(PAYMENT_SENT)
|
.setPhase(PAYMENT_SENT)
|
||||||
.setFiatSent(true);
|
.setFiatSent(true);
|
||||||
verifyExpectedProtocolStatus(trade);
|
verifyExpectedProtocolStatus(trade);
|
||||||
@ -192,7 +192,7 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
|||||||
var trade = aliceClient.getTrade(tradeId);
|
var trade = aliceClient.getTrade(tradeId);
|
||||||
|
|
||||||
Predicate<TradeInfo> tradeStateAndPhaseCorrect = (t) ->
|
Predicate<TradeInfo> tradeStateAndPhaseCorrect = (t) ->
|
||||||
t.getState().equals(SELLER_RECEIVED_PAYMENT_INITIATED_MSG.name())
|
t.getState().equals(SELLER_RECEIVED_PAYMENT_SENT_MSG.name())
|
||||||
&& (t.getPhase().equals(PAYOUT_PUBLISHED.name()) || t.getPhase().equals(PAYMENT_SENT.name()));
|
&& (t.getPhase().equals(PAYOUT_PUBLISHED.name()) || t.getPhase().equals(PAYMENT_SENT.name()));
|
||||||
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
for (int i = 1; i <= maxTradeStateAndPhaseChecks.get(); i++) {
|
||||||
if (!tradeStateAndPhaseCorrect.test(trade)) {
|
if (!tradeStateAndPhaseCorrect.test(trade)) {
|
||||||
|
@ -154,21 +154,24 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
|
|
||||||
|
|
||||||
// #################### Phase PAYMENT_SENT
|
// #################### Phase PAYMENT_SENT
|
||||||
BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED(Phase.PAYMENT_SENT),
|
BUYER_CONFIRMED_IN_UI_PAYMENT_SENT(Phase.PAYMENT_SENT),
|
||||||
BUYER_SENT_PAYMENT_INITIATED_MSG(Phase.PAYMENT_SENT),
|
BUYER_SENT_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT),
|
||||||
BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG(Phase.PAYMENT_SENT),
|
BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT),
|
||||||
BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG(Phase.PAYMENT_SENT),
|
BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT),
|
||||||
BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG(Phase.PAYMENT_SENT),
|
BUYER_SEND_FAILED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT),
|
||||||
|
|
||||||
SELLER_RECEIVED_PAYMENT_INITIATED_MSG(Phase.PAYMENT_SENT),
|
SELLER_RECEIVED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT),
|
||||||
|
|
||||||
// #################### Phase PAYMENT_RECEIVED
|
// #################### Phase PAYMENT_RECEIVED
|
||||||
// note that this state can also be triggered by auto confirmation feature
|
// note that this state can also be triggered by auto confirmation feature
|
||||||
SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT(Phase.PAYMENT_RECEIVED),
|
SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT(Phase.PAYMENT_RECEIVED),
|
||||||
|
SELLER_SENT_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED),
|
||||||
|
SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED),
|
||||||
|
SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED),
|
||||||
|
SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED),
|
||||||
|
|
||||||
// #################### Phase PAYOUT_PUBLISHED
|
// #################### Phase PAYOUT_PUBLISHED
|
||||||
SELLER_PUBLISHED_PAYOUT_TX(Phase.PAYOUT_PUBLISHED), // TODO (woodser): this enum is over used, like during arbitration
|
SELLER_PUBLISHED_PAYOUT_TX(Phase.PAYOUT_PUBLISHED), // TODO (woodser): this enum is over used, like during arbitration
|
||||||
|
|
||||||
SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
||||||
SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
||||||
SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED),
|
||||||
@ -850,10 +853,10 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
walletService.closeMultisigWallet(getId());
|
walletService.closeMultisigWallet(getId());
|
||||||
|
|
||||||
// update trade state
|
// update trade state
|
||||||
this.getSelf().setPayoutTxHex(signedPayoutTxHex);
|
getSelf().setPayoutTxHex(signedPayoutTxHex);
|
||||||
this.setPayoutTx(parsedTxSet.getTxs().get(0));
|
setPayoutTx(parsedTxSet.getTxs().get(0));
|
||||||
this.setPayoutTxId(parsedTxSet.getTxs().get(0).getHash());
|
setPayoutTxId(parsedTxSet.getTxs().get(0).getHash());
|
||||||
this.setState(Trade.State.SELLER_PUBLISHED_PAYOUT_TX);
|
setState(isBuyer() ? Trade.State.BUYER_PUBLISHED_PAYOUT_TX : Trade.State.SELLER_PUBLISHED_PAYOUT_TX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1116,26 +1119,42 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Getter
|
// Getter
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public boolean isBuyer() {
|
||||||
|
return offer.getDirection() == Direction.BUY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeller() {
|
||||||
|
return offer.getDirection() == Direction.SELL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMaker() {
|
||||||
|
return this instanceof MakerTrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTaker() {
|
||||||
|
return this instanceof TakerTrade;
|
||||||
|
}
|
||||||
|
|
||||||
public TradingPeer getSelf() {
|
public TradingPeer getSelf() {
|
||||||
if (this instanceof MakerTrade) return processModel.getMaker();
|
if (this instanceof MakerTrade) return processModel.getMaker();
|
||||||
if (this instanceof TakerTrade) return processModel.getTaker();
|
if (this instanceof TakerTrade) return processModel.getTaker();
|
||||||
if (this instanceof ArbitratorTrade) return processModel.getArbitrator();
|
if (this instanceof ArbitratorTrade) return processModel.getArbitrator();
|
||||||
throw new RuntimeException("Trade is not maker, taker, or arbitrator");
|
throw new RuntimeException("Trade is not maker, taker, or arbitrator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradingPeer getMaker() {
|
public TradingPeer getMaker() {
|
||||||
return processModel.getMaker();
|
return processModel.getMaker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradingPeer getTaker() {
|
public TradingPeer getTaker() {
|
||||||
return processModel.getTaker();
|
return processModel.getTaker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradingPeer getBuyer() {
|
public TradingPeer getBuyer() {
|
||||||
return offer.getDirection() == Direction.BUY ? processModel.getMaker() : processModel.getTaker();
|
return offer.getDirection() == Direction.BUY ? processModel.getMaker() : processModel.getTaker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradingPeer getSeller() {
|
public TradingPeer getSeller() {
|
||||||
return offer.getDirection() == Direction.BUY ? processModel.getTaker() : processModel.getMaker();
|
return offer.getDirection() == Direction.BUY ? processModel.getTaker() : processModel.getMaker();
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ public abstract class BuyerProtocol extends DisputeProtocol {
|
|||||||
.executeTasks();
|
.executeTasks();
|
||||||
|
|
||||||
given(anyPhase(Trade.Phase.PAYMENT_SENT, Trade.Phase.PAYMENT_RECEIVED)
|
given(anyPhase(Trade.Phase.PAYMENT_SENT, Trade.Phase.PAYMENT_RECEIVED)
|
||||||
.anyState(Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG,
|
.anyState(Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG,
|
||||||
Trade.State.BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG)
|
Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG)
|
||||||
.with(BuyerEvent.STARTUP))
|
.with(BuyerEvent.STARTUP))
|
||||||
.setup(tasks(BuyerSendsPaymentSentMessage.class))
|
.setup(tasks(BuyerSendsPaymentSentMessage.class))
|
||||||
.executeTasks();
|
.executeTasks();
|
||||||
@ -151,7 +151,7 @@ public abstract class BuyerProtocol extends DisputeProtocol {
|
|||||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||||
handleTaskRunnerFault(event, errorMessage);
|
handleTaskRunnerFault(event, errorMessage);
|
||||||
})))
|
})))
|
||||||
.run(() -> trade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED))
|
.run(() -> trade.setState(Trade.State.BUYER_CONFIRMED_IN_UI_PAYMENT_SENT))
|
||||||
.executeTasks();
|
.executeTasks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public abstract class SellerProtocol extends DisputeProtocol {
|
|||||||
synchronized (trade) {
|
synchronized (trade) {
|
||||||
SellerEvent event = SellerEvent.PAYMENT_RECEIVED;
|
SellerEvent event = SellerEvent.PAYMENT_RECEIVED;
|
||||||
// CountDownLatch latch = new CountDownLatch(1); // TODO (woodser): user countdown latch, but freezes legacy app
|
// CountDownLatch latch = new CountDownLatch(1); // TODO (woodser): user countdown latch, but freezes legacy app
|
||||||
expect(anyPhase(Trade.Phase.PAYMENT_SENT, Trade.Phase.PAYOUT_PUBLISHED)
|
expect(anyPhase(Trade.Phase.PAYMENT_SENT)
|
||||||
.with(event)
|
.with(event)
|
||||||
.preCondition(trade.confirmPermitted()))
|
.preCondition(trade.confirmPermitted()))
|
||||||
.setup(tasks(
|
.setup(tasks(
|
||||||
|
@ -89,8 +89,8 @@ public class BuyerSendsPaymentSentMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateSent() {
|
protected void setStateSent() {
|
||||||
if (trade.getState().ordinal() < Trade.State.BUYER_SENT_PAYMENT_INITIATED_MSG.ordinal()) {
|
if (trade.getState().ordinal() < Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal()) {
|
||||||
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SENT_PAYMENT_INITIATED_MSG);
|
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
@ -112,7 +112,7 @@ public class BuyerSendsPaymentSentMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateStoredInMailbox() {
|
protected void setStateStoredInMailbox() {
|
||||||
trade.setStateIfValidTransitionTo(Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG);
|
trade.setStateIfValidTransitionTo(Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG);
|
||||||
if (!trade.isPayoutPublished()) {
|
if (!trade.isPayoutPublished()) {
|
||||||
tryToSendAgainLater();
|
tryToSendAgainLater();
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public class BuyerSendsPaymentSentMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateFault() {
|
protected void setStateFault() {
|
||||||
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG);
|
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG);
|
||||||
if (!trade.isPayoutPublished()) {
|
if (!trade.isPayoutPublished()) {
|
||||||
tryToSendAgainLater();
|
tryToSendAgainLater();
|
||||||
}
|
}
|
||||||
@ -192,8 +192,8 @@ public class BuyerSendsPaymentSentMessage extends SendMailboxMessageTask {
|
|||||||
private void onMessageStateChange(MessageState newValue) {
|
private void onMessageStateChange(MessageState newValue) {
|
||||||
// Once we receive an ACK from our msg we know the peer has received the msg and we stop.
|
// Once we receive an ACK from our msg we know the peer has received the msg and we stop.
|
||||||
if (newValue == MessageState.ACKNOWLEDGED) {
|
if (newValue == MessageState.ACKNOWLEDGED) {
|
||||||
// We treat a ACK like BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG
|
// We treat a ACK like BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG
|
||||||
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG);
|
trade.setStateIfValidTransitionTo(Trade.State.BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG);
|
||||||
|
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class SellerProcessesPaymentSentMessage extends TradeTask {
|
|||||||
trade.setCounterCurrencyExtraData(counterCurrencyExtraData);
|
trade.setCounterCurrencyExtraData(counterCurrencyExtraData);
|
||||||
}
|
}
|
||||||
|
|
||||||
trade.setState(Trade.State.SELLER_RECEIVED_PAYMENT_INITIATED_MSG);
|
trade.setState(Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG);
|
||||||
|
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class SellerSendsPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateSent() {
|
protected void setStateSent() {
|
||||||
trade.setState(Trade.State.SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG);
|
trade.setState(trade.getState() == Trade.State.SELLER_PUBLISHED_PAYOUT_TX ? Trade.State.SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG);
|
||||||
log.info("Sent SellerReceivedPaymentMessage: tradeId={} at peer {} SignedWitness {}",
|
log.info("Sent SellerReceivedPaymentMessage: tradeId={} at peer {} SignedWitness {}",
|
||||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
@ -85,7 +85,7 @@ public class SellerSendsPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateArrived() {
|
protected void setStateArrived() {
|
||||||
trade.setState(Trade.State.SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG);
|
trade.setState(trade.getState() == Trade.State.SELLER_PUBLISHED_PAYOUT_TX ? Trade.State.SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG);
|
||||||
log.info("SellerReceivedPaymentMessage arrived: tradeId={} at peer {} SignedWitness {}",
|
log.info("SellerReceivedPaymentMessage arrived: tradeId={} at peer {} SignedWitness {}",
|
||||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
@ -93,7 +93,7 @@ public class SellerSendsPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateStoredInMailbox() {
|
protected void setStateStoredInMailbox() {
|
||||||
trade.setState(Trade.State.SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG);
|
trade.setState(trade.getState() == Trade.State.SELLER_PUBLISHED_PAYOUT_TX ? Trade.State.SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG);
|
||||||
log.info("SellerReceivedPaymentMessage storedInMailbox: tradeId={} at peer {} SignedWitness {}",
|
log.info("SellerReceivedPaymentMessage storedInMailbox: tradeId={} at peer {} SignedWitness {}",
|
||||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
@ -101,7 +101,7 @@ public class SellerSendsPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setStateFault() {
|
protected void setStateFault() {
|
||||||
trade.setState(Trade.State.SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG);
|
trade.setState(trade.getState() == Trade.State.SELLER_PUBLISHED_PAYOUT_TX ? Trade.State.SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG);
|
||||||
log.error("SellerReceivedPaymentMessage failed: tradeId={} at peer {} SignedWitness {}",
|
log.error("SellerReceivedPaymentMessage failed: tradeId={} at peer {} SignedWitness {}",
|
||||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
|
@ -207,7 +207,7 @@ public class XmrTxProofService implements AssetTxProofService {
|
|||||||
if (isExpectedTradeState(trade.getState())) {
|
if (isExpectedTradeState(trade.getState())) {
|
||||||
startRequestsIfValid(trade);
|
startRequestsIfValid(trade);
|
||||||
} else {
|
} else {
|
||||||
// We are expecting SELLER_RECEIVED_PAYMENT_INITIATED_MSG in the future, so listen on changes
|
// We are expecting SELLER_RECEIVED_PAYMENT_SENT_MSG in the future, so listen on changes
|
||||||
ChangeListener<Trade.State> tradeStateListener = (observable, oldValue, newValue) -> {
|
ChangeListener<Trade.State> tradeStateListener = (observable, oldValue, newValue) -> {
|
||||||
if (isExpectedTradeState(newValue)) {
|
if (isExpectedTradeState(newValue)) {
|
||||||
ChangeListener<Trade.State> listener = tradeStateListenerMap.remove(trade.getId());
|
ChangeListener<Trade.State> listener = tradeStateListenerMap.remove(trade.getId());
|
||||||
@ -346,7 +346,7 @@ public class XmrTxProofService implements AssetTxProofService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isExpectedTradeState(Trade.State newValue) {
|
private boolean isExpectedTradeState(Trade.State newValue) {
|
||||||
return newValue == Trade.State.SELLER_RECEIVED_PAYMENT_INITIATED_MSG;
|
return newValue == Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean is32BitHexStringInValid(String hexString) {
|
private boolean is32BitHexStringInValid(String hexString) {
|
||||||
|
@ -452,31 +452,35 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// buyer step 3
|
// buyer step 3
|
||||||
case BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED: // UI action
|
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT: // UI action
|
||||||
case BUYER_SENT_PAYMENT_INITIATED_MSG: // PAYMENT_INITIATED_MSG sent
|
case BUYER_SENT_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG sent
|
||||||
// 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);
|
||||||
break;
|
break;
|
||||||
case BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG: // PAYMENT_INITIATED_MSG arrived
|
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG arrived
|
||||||
case BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG: // PAYMENT_INITIATED_MSG in mailbox
|
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG in mailbox
|
||||||
buyerState.set(BuyerState.STEP3);
|
buyerState.set(BuyerState.STEP3);
|
||||||
break;
|
break;
|
||||||
case BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG: // PAYMENT_INITIATED_MSG failed
|
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG failed
|
||||||
// if failed we need to repeat sending so back to step 2
|
// if failed we need to repeat sending so back to step 2
|
||||||
buyerState.set(BuyerState.STEP2);
|
buyerState.set(BuyerState.STEP2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// seller step 3
|
// seller step 3
|
||||||
case SELLER_RECEIVED_PAYMENT_INITIATED_MSG: // PAYMENT_INITIATED_MSG received
|
case SELLER_RECEIVED_PAYMENT_SENT_MSG: // PAYMENT_SENT_MSG received
|
||||||
sellerState.set(SellerState.STEP3);
|
sellerState.set(SellerState.STEP3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// seller step 4
|
// seller step 4
|
||||||
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT: // UI action
|
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT: // UI action
|
||||||
case SELLER_PUBLISHED_PAYOUT_TX: // payout tx broad casted
|
case SELLER_SENT_PAYMENT_RECEIVED_MSG:
|
||||||
|
case SELLER_PUBLISHED_PAYOUT_TX: // payout tx broadcasted
|
||||||
case SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG sent
|
case SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG sent
|
||||||
sellerState.set(SellerState.STEP3);
|
sellerState.set(SellerState.STEP3);
|
||||||
break;
|
break;
|
||||||
|
case SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG:
|
||||||
|
case SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG:
|
||||||
|
case SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG:
|
||||||
case SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG arrived
|
case SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG arrived
|
||||||
case SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG mailbox
|
case SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG mailbox
|
||||||
case SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG failed - payout tx is published, peer will see it in network so we ignore failure and complete
|
case SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG failed - payout tx is published, peer will see it in network so we ignore failure and complete
|
||||||
|
@ -135,12 +135,12 @@ public class BuyerStep2View extends TradeStepView {
|
|||||||
|
|
||||||
if (trade.isDepositConfirmed() && !trade.isPaymentSent()) {
|
if (trade.isDepositConfirmed() && !trade.isPaymentSent()) {
|
||||||
showPopup();
|
showPopup();
|
||||||
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG.ordinal()) {
|
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG.ordinal()) {
|
||||||
if (!trade.hasFailed()) {
|
if (!trade.hasFailed()) {
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED:
|
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT:
|
||||||
case BUYER_SENT_PAYMENT_INITIATED_MSG:
|
case BUYER_SENT_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);
|
||||||
@ -149,17 +149,17 @@ public class BuyerStep2View extends TradeStepView {
|
|||||||
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
|
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
|
||||||
}, 10);
|
}, 10);
|
||||||
break;
|
break;
|
||||||
case BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG:
|
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
|
||||||
busyAnimation.stop();
|
busyAnimation.stop();
|
||||||
statusLabel.setText(Res.get("shared.messageArrived"));
|
statusLabel.setText(Res.get("shared.messageArrived"));
|
||||||
model.setMessageStateProperty(MessageState.ARRIVED);
|
model.setMessageStateProperty(MessageState.ARRIVED);
|
||||||
break;
|
break;
|
||||||
case BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG:
|
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
|
||||||
busyAnimation.stop();
|
busyAnimation.stop();
|
||||||
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
|
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
|
||||||
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
|
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
|
||||||
break;
|
break;
|
||||||
case BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG:
|
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG:
|
||||||
// We get a popup and the trade closed, so we dont need to show anything here
|
// We get a popup and the trade closed, so we dont need to show anything here
|
||||||
busyAnimation.stop();
|
busyAnimation.stop();
|
||||||
statusLabel.setText("");
|
statusLabel.setText("");
|
||||||
|
@ -1524,22 +1524,26 @@ message Trade {
|
|||||||
MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG = 16;
|
MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG = 16;
|
||||||
MAKER_SAW_DEPOSIT_TX_IN_NETWORK = 17;
|
MAKER_SAW_DEPOSIT_TX_IN_NETWORK = 17;
|
||||||
DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN = 18;
|
DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN = 18;
|
||||||
BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED = 19;
|
BUYER_CONFIRMED_IN_UI_PAYMENT_SENT = 19;
|
||||||
BUYER_SENT_PAYMENT_INITIATED_MSG = 20;
|
BUYER_SENT_PAYMENT_SENT_MSG = 20;
|
||||||
BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG = 21;
|
BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG = 21;
|
||||||
BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG = 22;
|
BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG = 22;
|
||||||
BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG = 23;
|
BUYER_SEND_FAILED_PAYMENT_SENT_MSG = 23;
|
||||||
SELLER_RECEIVED_PAYMENT_INITIATED_MSG = 24;
|
SELLER_RECEIVED_PAYMENT_SENT_MSG = 24;
|
||||||
SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT = 25;
|
SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT = 25;
|
||||||
SELLER_PUBLISHED_PAYOUT_TX = 26;
|
SELLER_SENT_PAYMENT_RECEIVED_MSG = 26;
|
||||||
SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG = 27;
|
SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG = 27;
|
||||||
SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG = 28;
|
SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG = 28;
|
||||||
SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG = 29;
|
SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG = 29;
|
||||||
SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG = 30;
|
SELLER_PUBLISHED_PAYOUT_TX = 30;
|
||||||
BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG = 31;
|
SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG = 31;
|
||||||
BUYER_SAW_PAYOUT_TX_IN_NETWORK = 32;
|
SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG = 32;
|
||||||
BUYER_PUBLISHED_PAYOUT_TX = 33;
|
SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG = 33;
|
||||||
WITHDRAW_COMPLETED = 34;
|
SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG = 34;
|
||||||
|
BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG = 35;
|
||||||
|
BUYER_SAW_PAYOUT_TX_IN_NETWORK = 36;
|
||||||
|
BUYER_PUBLISHED_PAYOUT_TX = 37;
|
||||||
|
WITHDRAW_COMPLETED = 38;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Phase {
|
enum Phase {
|
||||||
|
Loading…
Reference in New Issue
Block a user