mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-21 04:38:51 -04:00
Change protocol to support timelock correctly
This commit is contained in:
parent
36c2e4f1f7
commit
973aa73c76
36 changed files with 505 additions and 216 deletions
|
@ -30,14 +30,14 @@ import io.bitsquare.trade.protocol.placeoffer.tasks.CreateOfferFeeTx;
|
|||
import io.bitsquare.trade.protocol.placeoffer.tasks.ValidateOffer;
|
||||
import io.bitsquare.trade.protocol.trade.BuyerAsOffererProtocol;
|
||||
import io.bitsquare.trade.protocol.trade.SellerAsTakerProtocol;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.CreateAndSignPayoutTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.CreateDepositTxInputs;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.ProcessPayoutTxFinalizedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.ProcessRequestDepositTxInputsMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.ProcessRequestPublishDepositTxMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SendDepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SendFiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SendPayoutTxFinalizedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SendRequestPayDepositMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SignAndFinalizePayoutTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.SignAndPublishDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.offerer.VerifyTakeOfferFeePayment;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.offerer.VerifyTakerAccount;
|
||||
|
@ -45,10 +45,10 @@ import io.bitsquare.trade.protocol.trade.tasks.seller.CommitDepositTx;
|
|||
import io.bitsquare.trade.protocol.trade.tasks.seller.CreateAndSignDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.ProcessDepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.ProcessFiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.ProcessPayoutTxFinalizedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.ProcessRequestPayDepositMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.SendPayoutTxFinalizedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.SendRequestDepositTxInputsMessage;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.SignAndFinalizePayoutTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.seller.SignPayoutTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.taker.CreateTakeOfferFeeTx;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.taker.VerifyOfferFeePayment;
|
||||
import io.bitsquare.trade.protocol.trade.tasks.taker.VerifyOffererAccount;
|
||||
|
@ -107,7 +107,7 @@ public class DebugView extends InitializableView {
|
|||
SignAndPublishDepositTx.class,
|
||||
SendDepositTxPublishedMessage.class,
|
||||
|
||||
CreateAndSignPayoutTx.class,
|
||||
SignPayoutTx.class,
|
||||
VerifyTakeOfferFeePayment.class,
|
||||
SendFiatTransferStartedMessage.class,
|
||||
|
||||
|
|
|
@ -255,8 +255,6 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
"Please try later again." + msg);
|
||||
takeOfferRequested = false;
|
||||
break;
|
||||
case PAYOUT_FINALIZED:
|
||||
break;
|
||||
case EXCEPTION:
|
||||
errorMessage.set(msg);
|
||||
takeOfferRequested = false;
|
||||
|
@ -292,8 +290,6 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
"Please try later again." + msg);
|
||||
takeOfferRequested = false;
|
||||
break;
|
||||
case PAYOUT_FINALIZED:
|
||||
break;
|
||||
case EXCEPTION:
|
||||
errorMessage.set(msg);
|
||||
takeOfferRequested = false;
|
||||
|
|
|
@ -50,8 +50,8 @@ public class BuyerSubView extends TradeSubView {
|
|||
@Override
|
||||
protected void addWizards() {
|
||||
waitTxInBlockchain = new TradeWizardItem(WaitTxInBlockchainView.class, "Wait for blockchain confirmation");
|
||||
startFiat = new TradeWizardItem(StartFiatView.class, "Start payment");
|
||||
waitFiatReceived = new TradeWizardItem(WaitFiatReceivedView.class, "Wait until payment has arrived");
|
||||
startFiat = new TradeWizardItem(StartFiatView.class, "Start EUR payment");
|
||||
waitFiatReceived = new TradeWizardItem(WaitFiatReceivedView.class, "Wait until EUR payment arrived");
|
||||
payoutUnlock = new TradeWizardItem(WaitPayoutLockTimeView.class, "Wait for payout unlock");
|
||||
completed = new TradeWizardItem(CompletedView.class, "Completed");
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ class PendingTradesDataModel implements Activatable, DataModel {
|
|||
}
|
||||
|
||||
public long getLockTime() {
|
||||
return trade.getPayoutTx().getLockTime();
|
||||
return trade.getLockTime();
|
||||
}
|
||||
|
||||
public int getBestChainHeight() {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
SELLER_WAIT_TX_CONF,
|
||||
SELLER_WAIT_PAYMENT_STARTED,
|
||||
SELLER_CONFIRM_RECEIVE_PAYMENT,
|
||||
SELLER_SEND_PUBLISHED_MSG,
|
||||
SELLER_REQUEST_PAYOUT_FINALIZE_MSG_SENT,
|
||||
SELLER_PAYOUT_FINALIZED,
|
||||
SELLER_COMPLETED,
|
||||
|
||||
|
@ -329,14 +329,13 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
viewState.set(ViewState.SELLER_CONFIRM_RECEIVE_PAYMENT);
|
||||
break;
|
||||
|
||||
case FIAT_PAYMENT_RECEIVED:
|
||||
case REQUEST_PAYOUT_FINALIZE_MSG_SENT:
|
||||
viewState.set(ViewState.SELLER_REQUEST_PAYOUT_FINALIZE_MSG_SENT);
|
||||
break;
|
||||
case PAYOUT_FINALIZED:
|
||||
viewState.set(ViewState.SELLER_SEND_PUBLISHED_MSG);
|
||||
break;
|
||||
case PAYOUT_FINALIZED_MSG_SENT:
|
||||
viewState.set(ViewState.SELLER_PAYOUT_FINALIZED);
|
||||
break;
|
||||
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
viewState.set(ViewState.SELLER_COMPLETED);
|
||||
break;
|
||||
|
@ -376,14 +375,13 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
viewState.set(ViewState.SELLER_CONFIRM_RECEIVE_PAYMENT);
|
||||
break;
|
||||
|
||||
case FIAT_PAYMENT_RECEIVED:
|
||||
case REQUEST_PAYOUT_FINALIZE_MSG_SENT:
|
||||
viewState.set(ViewState.SELLER_REQUEST_PAYOUT_FINALIZE_MSG_SENT);
|
||||
break;
|
||||
case PAYOUT_FINALIZED:
|
||||
viewState.set(ViewState.SELLER_SEND_PUBLISHED_MSG);
|
||||
break;
|
||||
case PAYOUT_FINALIZED_MSG_SENT:
|
||||
viewState.set(ViewState.SELLER_PAYOUT_FINALIZED);
|
||||
break;
|
||||
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
viewState.set(ViewState.SELLER_COMPLETED);
|
||||
break;
|
||||
|
@ -431,11 +429,10 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
viewState.set(ViewState.BUYER_WAIT_CONFIRM_PAYMENT_RECEIVED);
|
||||
break;
|
||||
|
||||
case FIAT_PAYMENT_RECEIVED:
|
||||
case PAYOUT_FINALIZED:
|
||||
case PAYOUT_FINALIZED_MSG_SENT:
|
||||
case PAYOUT_FINALIZED:
|
||||
viewState.set(ViewState.BUYER_PAYOUT_FINALIZED);
|
||||
break;
|
||||
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
viewState.set(ViewState.BUYER_COMPLETED);
|
||||
break;
|
||||
|
@ -477,11 +474,10 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
viewState.set(ViewState.BUYER_WAIT_CONFIRM_PAYMENT_RECEIVED);
|
||||
break;
|
||||
|
||||
case FIAT_PAYMENT_RECEIVED:
|
||||
case PAYOUT_FINALIZED:
|
||||
case PAYOUT_FINALIZED_MSG_SENT:
|
||||
case PAYOUT_FINALIZED:
|
||||
viewState.set(ViewState.BUYER_PAYOUT_FINALIZED);
|
||||
break;
|
||||
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
viewState.set(ViewState.BUYER_COMPLETED);
|
||||
break;
|
||||
|
|
|
@ -21,6 +21,7 @@ import io.bitsquare.gui.components.Popups;
|
|||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.CompletedView;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.ConfirmFiatReceivedView;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.TradeWizardItem;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.WaitPayoutFinalizedView;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.WaitPayoutLockTimeView;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.steps.WaitTxInBlockchainView;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
@ -49,8 +50,8 @@ public class SellerSubView extends TradeSubView {
|
|||
@Override
|
||||
protected void addWizards() {
|
||||
waitTxInBlockchain = new TradeWizardItem(WaitTxInBlockchainView.class, "Wait for blockchain confirmation");
|
||||
waitFiatStarted = new TradeWizardItem(WaitTxInBlockchainView.class, "Wait for payment started");
|
||||
confirmFiatReceived = new TradeWizardItem(ConfirmFiatReceivedView.class, "Confirm payment received");
|
||||
waitFiatStarted = new TradeWizardItem(WaitTxInBlockchainView.class, "Wait until EUR payment has started");
|
||||
confirmFiatReceived = new TradeWizardItem(ConfirmFiatReceivedView.class, "Confirm EUR payment received");
|
||||
payoutUnlock = new TradeWizardItem(WaitPayoutLockTimeView.class, "Wait for payout unlock");
|
||||
completed = new TradeWizardItem(CompletedView.class, "Completed");
|
||||
|
||||
|
@ -118,14 +119,18 @@ public class SellerSubView extends TradeSubView {
|
|||
model.getCurrencyCode()));*/
|
||||
|
||||
break;
|
||||
case SELLER_SEND_PUBLISHED_MSG:
|
||||
if (tradeStepDetailsView == null) {
|
||||
waitTxInBlockchain.setCompleted();
|
||||
waitFiatStarted.setCompleted();
|
||||
showItem(confirmFiatReceived);
|
||||
}
|
||||
case SELLER_REQUEST_PAYOUT_FINALIZE_MSG_SENT:
|
||||
waitTxInBlockchain.setCompleted();
|
||||
waitFiatStarted.setCompleted();
|
||||
confirmFiatReceived.setCompleted();
|
||||
showItem(payoutUnlock);
|
||||
|
||||
((ConfirmFiatReceivedView) tradeStepDetailsView).setStatusText("Sending message to trading peer transaction...");
|
||||
// We dont use a wizard for that step as it only gets displayed in case the other peer is offline
|
||||
tradeStepDetailsView = new WaitPayoutFinalizedView(model);
|
||||
contentPane.getChildren().setAll(tradeStepDetailsView);
|
||||
|
||||
((WaitPayoutFinalizedView) tradeStepDetailsView).setInfoLabelText("We requested the trading peer to sign and finalize the payout transaction." +
|
||||
"\nIt might be that the other peer is offline, so we need to wait until he finalize the transaction when he goes online again.");
|
||||
break;
|
||||
case SELLER_PAYOUT_FINALIZED:
|
||||
waitTxInBlockchain.setCompleted();
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ConfirmFiatReceivedView extends TradeStepDetailsView {
|
|||
log.debug("onPaymentReceived");
|
||||
model.fiatPaymentReceived();
|
||||
confirmFiatReceivedButton.setDisable(true);
|
||||
statusLabel.setText("Finalizing payout transaction...");
|
||||
statusLabel.setText("Sending message to trading peer...");
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
root = statusProgressIndicator.getScene().getRoot();
|
||||
|
@ -106,10 +106,6 @@ public class ConfirmFiatReceivedView extends TradeStepDetailsView {
|
|||
infoDisplay.setText(text);
|
||||
}
|
||||
|
||||
public void setStatusText(String text) {
|
||||
statusLabel.setText(text);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Build view
|
||||
|
@ -123,11 +119,10 @@ public class ConfirmFiatReceivedView extends TradeStepDetailsView {
|
|||
getAndAddTitledGroupBg(gridPane, gridRow, 1, "Information", Layout.GROUP_DISTANCE);
|
||||
infoLabel = getAndAddInfoLabel(gridPane, gridRow++, Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
|
||||
ButtonWithProgressIndicatorAndLabelBucket bucket = getAndAddButtonWithStatus(gridPane, gridRow++, "Confirm payment receipt", this::onPaymentReceived);
|
||||
ButtonWithProgressIndicatorAndLabel bucket = getAndAddButtonWithStatus(gridPane, gridRow++, "Confirm payment receipt", this::onPaymentReceived);
|
||||
confirmFiatReceivedButton = bucket.button;
|
||||
statusProgressIndicator = bucket.progressIndicator;
|
||||
statusLabel = bucket.label;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class StartFiatView extends TradeStepDetailsView {
|
|||
primaryIdTextField = getAndAddLabelTextFieldWithCopyIconPair(gridPane, gridRow++, "IBAN:").textFieldWithCopyIcon;
|
||||
secondaryIdTextField = getAndAddLabelTextFieldWithCopyIconPair(gridPane, gridRow++, "BIC:").textFieldWithCopyIcon;
|
||||
paymentsInfoDisplay = getAndAddInfoDisplay(gridPane, gridRow++, "infoDisplay", this::onOpenHelp);
|
||||
ButtonWithProgressIndicatorAndLabelBucket bucket = getAndAddButtonWithStatus(gridPane, gridRow++, "Payment started", this::onPaymentStarted);
|
||||
ButtonWithProgressIndicatorAndLabel bucket = getAndAddButtonWithStatus(gridPane, gridRow++, "Payment started", this::onPaymentStarted);
|
||||
paymentStartedButton = bucket.button;
|
||||
statusProgressIndicator = bucket.progressIndicator;
|
||||
statusLabel = bucket.label;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TradeWizardItem extends Button {
|
|||
setMouseTransparent(true);
|
||||
setText(title);
|
||||
setPrefHeight(40);
|
||||
setPrefWidth(270);
|
||||
setPrefWidth(340);
|
||||
setPadding(new Insets(0, 20, 0, 10));
|
||||
setAlignment(Pos.CENTER_LEFT);
|
||||
setDisabled();
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.portfolio.pendingtrades.steps;
|
||||
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
|
||||
import javafx.scene.control.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static io.bitsquare.gui.util.ComponentBuilder.*;
|
||||
|
||||
public class WaitPayoutFinalizedView extends TradeStepDetailsView {
|
||||
private static final Logger log = LoggerFactory.getLogger(WaitPayoutFinalizedView.class);
|
||||
|
||||
private Label infoLabel;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, Initialisation
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public WaitPayoutFinalizedView(PendingTradesViewModel model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
super.activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
public void setInfoLabelText(String text) {
|
||||
if (infoLabel != null)
|
||||
infoLabel.setText(text);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Build view
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void buildGridEntries() {
|
||||
getAndAddTitledGroupBg(gridPane, gridRow, 1, "Information");
|
||||
infoLabel = getAndAddInfoLabel(gridPane, gridRow++, Layout.FIRST_ROW_DISTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,6 @@ public class WaitPayoutLockTimeView extends TradeStepDetailsView {
|
|||
private Label infoLabel;
|
||||
private TextField timeTextField;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, Initialisation
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -114,6 +113,7 @@ public class WaitPayoutLockTimeView extends TradeStepDetailsView {
|
|||
timeTextField.setText(model.getUnlockDate(missingBlocks));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Build view
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -195,7 +195,7 @@ public class ComponentBuilder {
|
|||
return button;
|
||||
}
|
||||
|
||||
public static ButtonWithProgressIndicatorAndLabelBucket getAndAddButtonWithStatus(GridPane gridPane,
|
||||
public static ButtonWithProgressIndicatorAndLabel getAndAddButtonWithStatus(GridPane gridPane,
|
||||
int rowIndex,
|
||||
String ButtonTitle,
|
||||
EventHandler<ActionEvent> onActionHandler) {
|
||||
|
@ -220,7 +220,7 @@ public class ComponentBuilder {
|
|||
GridPane.setMargin(hBox, new Insets(15, 0, 40, 0));
|
||||
gridPane.getChildren().add(hBox);
|
||||
|
||||
return new ButtonWithProgressIndicatorAndLabelBucket(button, progressIndicator, label);
|
||||
return new ButtonWithProgressIndicatorAndLabel(button, progressIndicator, label);
|
||||
}
|
||||
|
||||
public static class LabelTextFieldPair {
|
||||
|
@ -263,12 +263,12 @@ public class ComponentBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public static class ButtonWithProgressIndicatorAndLabelBucket {
|
||||
public static class ButtonWithProgressIndicatorAndLabel {
|
||||
public Button button;
|
||||
public ProgressIndicator progressIndicator;
|
||||
public Label label;
|
||||
|
||||
public ButtonWithProgressIndicatorAndLabelBucket(Button button, ProgressIndicator progressIndicator, Label label) {
|
||||
public ButtonWithProgressIndicatorAndLabel(Button button, ProgressIndicator progressIndicator, Label label) {
|
||||
this.button = button;
|
||||
this.progressIndicator = progressIndicator;
|
||||
this.label = label;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue