refactor payout protocol to work with or without updated multisig

This commit is contained in:
woodser 2022-03-31 14:23:58 -04:00
parent bb95b4b1d6
commit 32070fbafb
50 changed files with 1026 additions and 899 deletions

View file

@ -28,11 +28,11 @@ import bisq.core.offer.placeoffer.tasks.MakerReservesTradeFunds;
import bisq.core.offer.placeoffer.tasks.ValidateOffer;
import bisq.core.trade.protocol.tasks.ApplyFilter;
import bisq.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness;
import bisq.core.trade.protocol.tasks.buyer.BuyerCreateAndSignPayoutTx;
import bisq.core.trade.protocol.tasks.buyer.BuyerPreparesPaymentSentMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest;
import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDepositTxAndDelayedPayoutTxMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerProcessPayoutTxPublishedMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerSendCounterCurrencyTransferStartedMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerProcessesPaymentReceivedMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerSendsPaymentSentMessage;
import bisq.core.trade.protocol.tasks.buyer.BuyerSendsDelayedPayoutTxSignatureResponse;
import bisq.core.trade.protocol.tasks.buyer.BuyerSetupPayoutTxListener;
import bisq.core.trade.protocol.tasks.buyer.BuyerSignsDelayedPayoutTx;
@ -48,13 +48,13 @@ import bisq.core.trade.protocol.tasks.maker.MakerSetsLockTime;
import bisq.core.trade.protocol.tasks.maker.MakerVerifyTakerFeePayment;
import bisq.core.trade.protocol.tasks.seller.SellerCreatesDelayedPayoutTx;
import bisq.core.trade.protocol.tasks.seller.SellerFinalizesDelayedPayoutTx;
import bisq.core.trade.protocol.tasks.seller.SellerProcessCounterCurrencyTransferStartedMessage;
import bisq.core.trade.protocol.tasks.seller.SellerProcessesPaymentSentMessage;
import bisq.core.trade.protocol.tasks.seller.SellerProcessDelayedPayoutTxSignatureResponse;
import bisq.core.trade.protocol.tasks.seller.SellerPublishesDepositTx;
import bisq.core.trade.protocol.tasks.seller.SellerPublishesTradeStatistics;
import bisq.core.trade.protocol.tasks.seller.SellerSendDelayedPayoutTxSignatureRequest;
import bisq.core.trade.protocol.tasks.seller.SellerSendPayoutTxPublishedMessage;
import bisq.core.trade.protocol.tasks.seller.SellerSignAndPublishPayoutTx;
import bisq.core.trade.protocol.tasks.seller.SellerSendsPaymentReceivedMessage;
import bisq.core.trade.protocol.tasks.seller.SellerPreparesPaymentReceivedMessage;
import bisq.core.trade.protocol.tasks.seller.SellerSignsDelayedPayoutTx;
import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerCreatesUnsignedDepositTx;
import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerFinalizesDepositTx;
@ -135,15 +135,15 @@ public class DebugView extends InitializableView<GridPane, Void> {
SellerPublishesDepositTx.class,
SellerPublishesTradeStatistics.class,
SellerProcessCounterCurrencyTransferStartedMessage.class,
SellerProcessesPaymentSentMessage.class,
ApplyFilter.class,
TakerVerifyMakerFeePayment.class,
ApplyFilter.class,
TakerVerifyMakerFeePayment.class,
SellerSignAndPublishPayoutTx.class,
SellerPreparesPaymentReceivedMessage.class,
//SellerBroadcastPayoutTx.class, // TODO (woodser): removed from main pipeline; debug view?
SellerSendPayoutTxPublishedMessage.class
SellerSendsPaymentReceivedMessage.class
)
));
@ -167,11 +167,11 @@ public class DebugView extends InitializableView<GridPane, Void> {
ApplyFilter.class,
MakerVerifyTakerFeePayment.class,
BuyerCreateAndSignPayoutTx.class,
BuyerPreparesPaymentSentMessage.class,
BuyerSetupPayoutTxListener.class,
BuyerSendCounterCurrencyTransferStartedMessage.class,
BuyerSendsPaymentSentMessage.class,
BuyerProcessPayoutTxPublishedMessage.class
BuyerProcessesPaymentReceivedMessage.class
)
));
@ -199,11 +199,11 @@ public class DebugView extends InitializableView<GridPane, Void> {
ApplyFilter.class,
TakerVerifyMakerFeePayment.class,
BuyerCreateAndSignPayoutTx.class,
BuyerPreparesPaymentSentMessage.class,
BuyerSetupPayoutTxListener.class,
BuyerSendCounterCurrencyTransferStartedMessage.class,
BuyerSendsPaymentSentMessage.class,
BuyerProcessPayoutTxPublishedMessage.class)
BuyerProcessesPaymentReceivedMessage.class)
));
addGroup("SellerAsMakerProtocol",
FXCollections.observableArrayList(Arrays.asList(
@ -227,15 +227,15 @@ public class DebugView extends InitializableView<GridPane, Void> {
SellerPublishesDepositTx.class,
SellerPublishesTradeStatistics.class,
SellerProcessCounterCurrencyTransferStartedMessage.class,
SellerProcessesPaymentSentMessage.class,
ApplyFilter.class,
MakerVerifyTakerFeePayment.class,
ApplyFilter.class,
MakerVerifyTakerFeePayment.class,
SellerSignAndPublishPayoutTx.class,
SellerPreparesPaymentReceivedMessage.class,
//SellerBroadcastPayoutTx.class, // TODO (woodser): removed from main pipeline; debug view?
SellerSendPayoutTxPublishedMessage.class
SellerSendsPaymentReceivedMessage.class
)
));
}

View file

@ -409,8 +409,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
appendMsg = Res.get("takeOffer.error.feePaid");
break;
case DEPOSIT_PUBLISHED:
case FIAT_SENT:
case FIAT_RECEIVED:
case PAYMENT_SENT:
case PAYMENT_RECEIVED:
appendMsg = Res.get("takeOffer.error.depositPublished");
break;
case PAYOUT_PUBLISHED:

View file

@ -194,7 +194,7 @@ public class NotificationCenter {
if (trade instanceof BuyerTrade && phase.ordinal() == Trade.Phase.DEPOSIT_CONFIRMED.ordinal())
message = Res.get("notification.trade.confirmed");
else if (trade instanceof SellerTrade && phase.ordinal() == Trade.Phase.FIAT_SENT.ordinal())
else if (trade instanceof SellerTrade && phase.ordinal() == Trade.Phase.PAYMENT_SENT.ordinal())
message = Res.get("notification.trade.paymentStarted");
}

View file

@ -468,27 +468,33 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
TradeChatSession tradeChatSession = new TradeChatSession(trade, isTaker);
tradeStateListener = (observable, oldValue, newValue) -> {
if (trade.isPayoutPublished()) {
if (chatPopupStage.isShowing()) {
chatPopupStage.hide();
UserThread.execute(() -> {
if (trade.isPayoutPublished()) {
if (chatPopupStage.isShowing()) {
chatPopupStage.hide();
}
}
}
});
};
trade.stateProperty().addListener(tradeStateListener);
disputeStateListener = (observable, oldValue, newValue) -> {
if (newValue == Trade.DisputeState.DISPUTE_CLOSED || newValue == Trade.DisputeState.REFUND_REQUEST_CLOSED) {
chatPopupStage.hide();
}
UserThread.execute(() -> {
if (newValue == Trade.DisputeState.DISPUTE_CLOSED || newValue == Trade.DisputeState.REFUND_REQUEST_CLOSED) {
chatPopupStage.hide();
}
});
};
trade.disputeStateProperty().addListener(disputeStateListener);
mediationResultStateListener = (observable, oldValue, newValue) -> {
if (newValue == MediationResultState.PAYOUT_TX_PUBLISHED ||
newValue == MediationResultState.RECEIVED_PAYOUT_TX_PUBLISHED_MSG ||
newValue == MediationResultState.PAYOUT_TX_SEEN_IN_NETWORK) {
chatPopupStage.hide();
}
UserThread.execute(() -> {
if (newValue == MediationResultState.PAYOUT_TX_PUBLISHED ||
newValue == MediationResultState.RECEIVED_PAYOUT_TX_PUBLISHED_MSG ||
newValue == MediationResultState.PAYOUT_TX_SEEN_IN_NETWORK) {
chatPopupStage.hide();
}
});
};
trade.mediationResultStateProperty().addListener(mediationResultStateListener);
@ -559,21 +565,23 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
}
private void updateChatMessageCount(Trade trade, JFXBadge badge) {
if (!trade.getId().equals(tradeIdOfOpenChat)) {
updateNewChatMessagesByTradeMap();
long num = newChatMessagesByTradeMap.get(trade.getId());
if (num > 0) {
badge.setText(String.valueOf(num));
badge.setEnabled(true);
UserThread.execute(() -> {
if (!trade.getId().equals(tradeIdOfOpenChat)) {
updateNewChatMessagesByTradeMap();
long num = newChatMessagesByTradeMap.get(trade.getId());
if (num > 0) {
badge.setText(String.valueOf(num));
badge.setEnabled(true);
} else {
badge.setText("");
badge.setEnabled(false);
}
} else {
badge.setText("");
badge.setEnabled(false);
}
} else {
badge.setText("");
badge.setEnabled(false);
}
badge.refreshBadge();
badge.refreshBadge();
});
}
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -452,27 +452,27 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
break;
// buyer step 3
case BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED: // UI action
case BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG sent
case BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED: // UI action
case BUYER_SENT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG sent
// We don't switch the UI before we got the feedback of the msg delivery
buyerState.set(BuyerState.STEP2);
break;
case BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG arrived
case BUYER_STORED_IN_MAILBOX_FIAT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG in mailbox
case BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG arrived
case BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG in mailbox
buyerState.set(BuyerState.STEP3);
break;
case BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG failed
case BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG failed
// if failed we need to repeat sending so back to step 2
buyerState.set(BuyerState.STEP2);
break;
// seller step 3
case SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG received
case SELLER_RECEIVED_PAYMENT_INITIATED_MSG: // FIAT_PAYMENT_INITIATED_MSG received
sellerState.set(SellerState.STEP3);
break;
// seller step 4
case SELLER_CONFIRMED_IN_UI_FIAT_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_PAYOUT_TX_PUBLISHED_MSG: // PAYOUT_TX_PUBLISHED_MSG sent
sellerState.set(SellerState.STEP3);
@ -487,6 +487,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
case BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG:
// Alternatively the maker could have seen the payout tx earlier before he received the PAYOUT_TX_PUBLISHED_MSG:
case BUYER_SAW_PAYOUT_TX_IN_NETWORK:
// Alternatively the buyer could fully sign and publish the payout tx
case BUYER_PUBLISHED_PAYOUT_TX:
buyerState.set(BuyerState.STEP4);
break;

View file

@ -135,12 +135,12 @@ public class BuyerStep2View extends TradeStepView {
if (trade.isDepositConfirmed() && !trade.isFiatSent()) {
showPopup();
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG.ordinal()) {
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG.ordinal()) {
if (!trade.hasFailed()) {
UserThread.execute(() -> {
switch (state) {
case BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED:
case BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG:
case BUYER_CONFIRMED_IN_UI_PAYMENT_INITIATED:
case BUYER_SENT_PAYMENT_INITIATED_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(MessageState.SENT);
@ -149,17 +149,17 @@ public class BuyerStep2View extends TradeStepView {
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
}, 10);
break;
case BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG:
case BUYER_SAW_ARRIVED_PAYMENT_INITIATED_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
model.setMessageStateProperty(MessageState.ARRIVED);
break;
case BUYER_STORED_IN_MAILBOX_FIAT_PAYMENT_INITIATED_MSG:
case BUYER_STORED_IN_MAILBOX_PAYMENT_INITIATED_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
break;
case BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG:
case BUYER_SEND_FAILED_PAYMENT_INITIATED_MSG:
// We get a popup and the trade closed, so we dont need to show anything here
busyAnimation.stop();
statusLabel.setText("");

View file

@ -116,7 +116,7 @@ public class SellerStep3View extends TradeStepView {
} else if (trade.isFiatReceived()) {
if (!trade.hasFailed()) {
switch (state) {
case SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT:
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT:
case SELLER_PUBLISHED_PAYOUT_TX:
case SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG:
busyAnimation.play();