Search in sources :

Example 6 with PaymentAccountPayload

use of bisq.core.payment.payload.PaymentAccountPayload in project bisq-desktop by bisq-network.

the class TradeDetailsWindow method addContent.

private void addContent() {
    Offer offer = trade.getOffer();
    Contract contract = trade.getContract();
    int rows = 5;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("tradeDetailsWindow.headline"));
    boolean myOffer = tradeManager.isMyOffer(offer);
    String fiatDirectionInfo;
    String btcDirectionInfo;
    String toReceive = " " + Res.get("shared.toReceive");
    String toSpend = " " + Res.get("shared.toSpend");
    String offerType = Res.getWithCol("shared.offerType");
    if (tradeManager.isBuyer(offer)) {
        addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = toSpend;
        btcDirectionInfo = toReceive;
    } else {
        addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = toReceive;
        btcDirectionInfo = toSpend;
    }
    addLabelTextField(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo, formatter.formatCoinWithCode(trade.getTradeAmount()));
    addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, formatter.formatVolumeWithCode(trade.getTradeVolume()));
    addLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"), formatter.formatPrice(trade.getTradePrice()));
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(offer.getPaymentMethod().getId()));
    // second group
    rows = 6;
    PaymentAccountPayload buyerPaymentAccountPayload = null;
    PaymentAccountPayload sellerPaymentAccountPayload = null;
    if (contract != null) {
        rows++;
        buyerPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
        sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
        if (buyerPaymentAccountPayload != null)
            rows++;
        if (sellerPaymentAccountPayload != null)
            rows++;
        if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
            rows++;
    }
    if (trade.getTakerFeeTxId() != null)
        rows++;
    if (trade.getDepositTx() != null)
        rows++;
    if (trade.getPayoutTx() != null)
        rows++;
    boolean showDisputedTx = disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null;
    if (showDisputedTx)
        rows++;
    if (trade.hasFailed())
        rows += 2;
    if (trade.getTradingPeerNodeAddress() != null)
        rows++;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
    addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.tradeId"), trade.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"), formatter.formatDateTime(trade.getDate()));
    String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), securityDeposit);
    String txFee = Res.get("shared.makerTxFee", formatter.formatCoinWithCode(offer.getTxFee())) + " / " + Res.get("shared.takerTxFee", formatter.formatCoinWithCode(offer.getTxFee().multiply(3L)));
    addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
    if (trade.getArbitratorNodeAddress() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.arbitrator"), trade.getArbitratorNodeAddress().getFullAddress());
    if (trade.getTradingPeerNodeAddress() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"), trade.getTradingPeerNodeAddress().getFullAddress());
    if (contract != null) {
        if (buyerPaymentAccountPayload != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.buyer")), buyerPaymentAccountPayload.getPaymentDetails()).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (sellerPaymentAccountPayload != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.seller")), sellerPaymentAccountPayload.getPaymentDetails()).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
            addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(contract.getPaymentMethodId()));
    }
    addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
    if (trade.getTakerFeeTxId() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), trade.getTakerFeeTxId());
    if (trade.getDepositTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.getWithCol("shared.depositTransactionId"), trade.getDepositTx().getHashAsString());
    if (trade.getPayoutTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.payoutTxId"), trade.getPayoutTx().getHashAsString());
    if (showDisputedTx)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.disputedPayoutTxId"), disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
    if (contract != null) {
        Button viewContractButton = addLabelButton(gridPane, ++rowIndex, Res.get("shared.contractAsJson"), Res.get("shared.viewContractAsJson"), 0).second;
        viewContractButton.setDefaultButton(false);
        viewContractButton.setOnAction(e -> {
            TextArea textArea = new TextArea();
            textArea.setText(trade.getContractAsJson());
            String contractAsJson = trade.getContractAsJson();
            contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
            contractAsJson += "\nSellerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getSellerMultiSigPubKey());
            textArea.setText(contractAsJson);
            textArea.setPrefHeight(50);
            textArea.setEditable(false);
            textArea.setWrapText(true);
            textArea.setPrefSize(800, 600);
            Scene viewContractScene = new Scene(textArea);
            Stage viewContractStage = new Stage();
            viewContractStage.setTitle(Res.get("shared.contract.title", trade.getShortId()));
            viewContractStage.setScene(viewContractScene);
            if (owner == null)
                owner = MainView.getRootContainer();
            Scene rootScene = owner.getScene();
            viewContractStage.initOwner(rootScene.getWindow());
            viewContractStage.initModality(Modality.NONE);
            viewContractStage.initStyle(StageStyle.UTILITY);
            viewContractStage.show();
            Window window = rootScene.getWindow();
            double titleBarHeight = window.getHeight() - rootScene.getHeight();
            viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
            viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
        });
    }
    if (trade.hasFailed()) {
        textArea = addLabelTextArea(gridPane, ++rowIndex, Res.get("shared.errorMessage"), "").second;
        textArea.setText(trade.getErrorMessage());
        textArea.setEditable(false);
        IntegerProperty count = new SimpleIntegerProperty(20);
        int rowHeight = 10;
        textArea.prefHeightProperty().bindBidirectional(count);
        changeListener = (ov, old, newVal) -> {
            if (newVal.intValue() > rowHeight)
                count.setValue(count.get() + newVal.intValue() + 10);
        };
        textArea.scrollTopProperty().addListener(changeListener);
        textArea.setScrollTop(30);
        TextField state = addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeState")).second;
        state.setText(trade.getState().getPhase().name());
    }
    Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
    // TODO app wide focus
    // closeButton.requestFocus();
    closeButton.setOnAction(e -> {
        closeHandlerOptional.ifPresent(Runnable::run);
        hide();
    });
}
Also used : Window(javafx.stage.Window) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TextArea(javafx.scene.control.TextArea) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Scene(javafx.scene.Scene) Offer(bisq.core.offer.Offer) Button(javafx.scene.control.Button) Stage(javafx.stage.Stage) TextField(javafx.scene.control.TextField) Contract(bisq.core.trade.Contract) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty)

Example 7 with PaymentAccountPayload

use of bisq.core.payment.payload.PaymentAccountPayload in project bisq-desktop by bisq-network.

the class SellerStep3View method showPopup.

@SuppressWarnings("PointlessBooleanExpression")
private void showPopup() {
    PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload();
    // noinspection UnusedAssignment
    String key = "confirmPayment" + trade.getId();
    String message = "";
    String tradeVolumeWithCode = model.btcFormatter.formatVolumeWithCode(trade.getTradeVolume());
    String currencyName = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode());
    String part1 = Res.get("portfolio.pending.step3_seller.part", currencyName);
    String id = trade.getShortId();
    if (paymentAccountPayload instanceof CryptoCurrencyAccountPayload) {
        String address = ((CryptoCurrencyAccountPayload) paymentAccountPayload).getAddress();
        // noinspection UnusedAssignment
        message = Res.get("portfolio.pending.step3_seller.altcoin", part1, currencyName, address, tradeVolumeWithCode, currencyName);
    } else {
        if (paymentAccountPayload instanceof USPostalMoneyOrderAccountPayload)
            message = Res.get("portfolio.pending.step3_seller.postal", part1, tradeVolumeWithCode, id);
        else if (!(paymentAccountPayload instanceof WesternUnionAccountPayload))
            message = Res.get("portfolio.pending.step3_seller.bank", currencyName, tradeVolumeWithCode, id);
        String part = Res.get("portfolio.pending.step3_seller.openDispute");
        if (paymentAccountPayload instanceof CashDepositAccountPayload)
            message = message + Res.get("portfolio.pending.step3_seller.cash", part);
        else if (paymentAccountPayload instanceof WesternUnionAccountPayload)
            message = message + Res.get("portfolio.pending.step3_seller.westernUnion", part);
        Optional<String> optionalHolderName = getOptionalHolderName();
        if (optionalHolderName.isPresent()) {
            // noinspection UnusedAssignment
            message = message + Res.get("portfolio.pending.step3_seller.bankCheck", optionalHolderName.get(), part);
        }
    }
    // noinspection ConstantConditions
    if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) {
        DontShowAgainLookup.dontShowAgain(key, true);
        new Popup<>().headLine(Res.get("popup.attention.forTradeWithId", id)).attention(message).show();
    }
}
Also used : CashDepositAccountPayload(bisq.core.payment.payload.CashDepositAccountPayload) USPostalMoneyOrderAccountPayload(bisq.core.payment.payload.USPostalMoneyOrderAccountPayload) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) WesternUnionAccountPayload(bisq.core.payment.payload.WesternUnionAccountPayload) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Example 8 with PaymentAccountPayload

use of bisq.core.payment.payload.PaymentAccountPayload in project bisq-desktop by bisq-network.

the class SellerStep3View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 3, Res.get("portfolio.pending.step3_seller.confirmPaymentReceipt"), Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = addLabelTextFieldWithCopyIcon(gridPane, gridRow, Res.get("portfolio.pending.step3_seller.amountToReceive"), model.getFiatVolume(), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);
    String myPaymentDetails = "";
    String peersPaymentDetails = "";
    String myTitle = "";
    String peersTitle = "";
    boolean isBlockChain = false;
    String nameByCode = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode());
    Contract contract = trade.getContract();
    if (contract != null) {
        PaymentAccountPayload myPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
        PaymentAccountPayload peersPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
        if (myPaymentAccountPayload instanceof CryptoCurrencyAccountPayload) {
            myPaymentDetails = ((CryptoCurrencyAccountPayload) myPaymentAccountPayload).getAddress();
            peersPaymentDetails = ((CryptoCurrencyAccountPayload) peersPaymentAccountPayload).getAddress();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", nameByCode);
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", nameByCode);
            isBlockChain = true;
        } else {
            myPaymentDetails = myPaymentAccountPayload.getPaymentDetails();
            peersPaymentDetails = peersPaymentAccountPayload.getPaymentDetails();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAccount");
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAccount");
        }
    }
    TextFieldWithCopyIcon myPaymentDetailsTextField = addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, myTitle, myPaymentDetails).second;
    myPaymentDetailsTextField.setMouseTransparent(false);
    myPaymentDetailsTextField.setTooltip(new Tooltip(myPaymentDetails));
    TextFieldWithCopyIcon peersPaymentDetailsTextField = addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, peersTitle, peersPaymentDetails).second;
    peersPaymentDetailsTextField.setMouseTransparent(false);
    peersPaymentDetailsTextField.setTooltip(new Tooltip(peersPaymentDetails));
    if (!isBlockChain) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.getWithCol("shared.reasonForPayment"), model.dataModel.getReference());
        GridPane.setRowSpan(titledGroupBg, 4);
    }
    Tuple3<Button, BusyAnimation, Label> tuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, Res.get("portfolio.pending.step3_seller.confirmReceipt"));
    confirmButton = tuple.first;
    confirmButton.setOnAction(e -> onPaymentReceived());
    busyAnimation = tuple.second;
    statusLabel = tuple.third;
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) Button(javafx.scene.control.Button) FormBuilder.addLabelTextFieldWithCopyIcon(bisq.desktop.util.FormBuilder.addLabelTextFieldWithCopyIcon) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Label(javafx.scene.control.Label) TitledGroupBg(bisq.desktop.components.TitledGroupBg) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Contract(bisq.core.trade.Contract) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Example 9 with PaymentAccountPayload

use of bisq.core.payment.payload.PaymentAccountPayload in project bisq-desktop by bisq-network.

the class BuyerStep2View method showPopup.

@SuppressWarnings("PointlessBooleanExpression")
private void showPopup() {
    PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload();
    if (paymentAccountPayload != null) {
        String paymentDetailsForTradePopup = paymentAccountPayload.getPaymentDetailsForTradePopup();
        String message = Res.get("portfolio.pending.step2.confReached");
        String copyPaste = Res.get("portfolio.pending.step2_buyer.copyPaste");
        String refTextWarn = Res.get("portfolio.pending.step2_buyer.refTextWarn");
        String accountDetails = Res.get("portfolio.pending.step2_buyer.accountDetails");
        String tradeId = Res.get("portfolio.pending.step2_buyer.tradeId");
        String assign = Res.get("portfolio.pending.step2_buyer.assign");
        String fees = Res.get("portfolio.pending.step2_buyer.fees");
        String id = trade.getShortId();
        String paddedId = " " + id + " ";
        String amount = model.btcFormatter.formatVolumeWithCode(trade.getTradeVolume());
        if (paymentAccountPayload instanceof CryptoCurrencyAccountPayload) {
            // noinspection UnusedAssignment
            message += Res.get("portfolio.pending.step2_buyer.altcoin", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()), amount) + accountDetails + paymentDetailsForTradePopup + ".\n\n" + copyPaste;
        } else if (paymentAccountPayload instanceof CashDepositAccountPayload) {
            // noinspection UnusedAssignment
            message += Res.get("portfolio.pending.step2_buyer.cash", amount) + accountDetails + paymentDetailsForTradePopup + ".\n" + copyPaste + "\n\n" + tradeId + paddedId + assign + refTextWarn + "\n\n" + fees + "\n\n" + Res.get("portfolio.pending.step2_buyer.cash.extra");
        } else if (paymentAccountPayload instanceof WesternUnionAccountPayload) {
            final String email = ((WesternUnionAccountPayload) paymentAccountPayload).getEmail();
            final String extra = Res.get("portfolio.pending.step2_buyer.westernUnion.extra", email);
            message += Res.get("portfolio.pending.step2_buyer.westernUnion", amount) + accountDetails + paymentDetailsForTradePopup + ".\n" + copyPaste + "\n\n" + extra;
        } else if (paymentAccountPayload instanceof USPostalMoneyOrderAccountPayload) {
            // noinspection UnusedAssignment
            message += Res.get("portfolio.pending.step2_buyer.postal", amount) + accountDetails + paymentDetailsForTradePopup + ".\n" + copyPaste + "\n\n" + tradeId + paddedId + assign + refTextWarn;
        } else {
            // noinspection UnusedAssignment
            message += Res.get("portfolio.pending.step2_buyer.bank", amount) + accountDetails + paymentDetailsForTradePopup + ".\n" + copyPaste + "\n\n" + tradeId + paddedId + assign + refTextWarn + "\n\n" + fees;
        }
        // noinspection ConstantConditions,UnusedAssignment
        String key = "startPayment" + trade.getId();
        // noinspection ConstantConditions,ConstantConditions
        if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) {
            DontShowAgainLookup.dontShowAgain(key, true);
            new Popup<>().headLine(Res.get("popup.attention.forTradeWithId", id)).attention(message).show();
        }
    }
}
Also used : CashDepositAccountPayload(bisq.core.payment.payload.CashDepositAccountPayload) USPostalMoneyOrderAccountPayload(bisq.core.payment.payload.USPostalMoneyOrderAccountPayload) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) WesternUnionAccountPayload(bisq.core.payment.payload.WesternUnionAccountPayload) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Example 10 with PaymentAccountPayload

use of bisq.core.payment.payload.PaymentAccountPayload in project bisq-desktop by bisq-network.

the class ContractWindow method addContent.

private void addContent() {
    Contract contract = dispute.getContract();
    Offer offer = new Offer(contract.getOfferPayload());
    List<String> acceptedBanks = offer.getAcceptedBankIds();
    boolean showAcceptedBanks = acceptedBanks != null && !acceptedBanks.isEmpty();
    List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
    boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
    int rows = 17;
    if (dispute.getDepositTxSerialized() != null)
        rows++;
    if (dispute.getPayoutTxSerialized() != null)
        rows++;
    if (showAcceptedCountryCodes)
        rows++;
    if (showAcceptedBanks)
        rows++;
    PaymentAccountPayload sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("contractWindow.title"));
    addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.getWithCol("shared.offerId"), offer.getId(), Layout.FIRST_ROW_DISTANCE).second.setMouseTransparent(false);
    addLabelTextField(gridPane, ++rowIndex, Res.get("contractWindow.dates"), formatter.formatDateTime(offer.getDate()) + " / " + formatter.formatDateTime(dispute.getTradeDate()));
    String currencyCode = offer.getCurrencyCode();
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.offerType"), formatter.getDirectionBothSides(offer.getDirection(), currencyCode));
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.tradePrice"), formatter.formatPrice(contract.getTradePrice()));
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.tradeAmount"), formatter.formatCoinWithCode(contract.getTradeAmount()));
    addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode, ":"), formatter.formatVolumeWithCode(contract.getTradePrice().getVolumeByAmount(contract.getTradeAmount())));
    String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), securityDeposit);
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.btcAddresses"), contract.getBuyerPayoutAddressString() + " / " + contract.getSellerPayoutAddressString()).second.setMouseTransparent(false);
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.onions"), contract.getBuyerNodeAddress().getFullAddress() + " / " + contract.getSellerNodeAddress().getFullAddress());
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.numDisputes"), disputeManager.getNrOfDisputes(true, contract) + " / " + disputeManager.getNrOfDisputes(false, contract));
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.buyer")), contract.getBuyerPaymentAccountPayload().getPaymentDetails()).second.setMouseTransparent(false);
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.seller")), sellerPaymentAccountPayload.getPaymentDetails()).second.setMouseTransparent(false);
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.arbitrator"), contract.getArbitratorNodeAddress().getFullAddress());
    if (showAcceptedCountryCodes) {
        String countries;
        Tooltip tooltip = null;
        if (CountryUtil.containsAllSepaEuroCountries(acceptedCountryCodes)) {
            countries = Res.getWithCol("shared.allEuroCountries");
        } else {
            countries = CountryUtil.getCodesString(acceptedCountryCodes);
            tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes));
        }
        TextField acceptedCountries = addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.acceptedTakerCountries"), countries).second;
        if (tooltip != null)
            acceptedCountries.setTooltip(new Tooltip());
    }
    if (showAcceptedBanks) {
        if (offer.getPaymentMethod().equals(PaymentMethod.SAME_BANK)) {
            addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.bankName"), acceptedBanks.get(0));
        } else if (offer.getPaymentMethod().equals(PaymentMethod.SPECIFIC_BANKS)) {
            String value = Joiner.on(", ").join(acceptedBanks);
            Tooltip tooltip = new Tooltip(Res.getWithCol("shared.acceptedBanks") + value);
            TextField acceptedBanksTextField = addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.acceptedBanks"), value).second;
            acceptedBanksTextField.setMouseTransparent(false);
            acceptedBanksTextField.setTooltip(tooltip);
        }
    }
    addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
    addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), contract.getTakerFeeTxID());
    if (dispute.getDepositTxSerialized() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.getWithCol("shared.depositTransactionId"), dispute.getDepositTxId());
    if (dispute.getPayoutTxSerialized() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.payoutTxId"), dispute.getPayoutTxId());
    if (dispute.getContractHash() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.contractHash"), Utils.HEX.encode(dispute.getContractHash())).second.setMouseTransparent(false);
    Button viewContractButton = addLabelButton(gridPane, ++rowIndex, Res.get("shared.contractAsJson"), Res.get("shared.viewContractAsJson"), 0).second;
    viewContractButton.setDefaultButton(false);
    viewContractButton.setOnAction(e -> {
        TextArea textArea = new TextArea();
        String contractAsJson = dispute.getContractAsJson();
        contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
        contractAsJson += "\nSellerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getSellerMultiSigPubKey());
        textArea.setText(contractAsJson);
        textArea.setPrefHeight(50);
        textArea.setEditable(false);
        textArea.setWrapText(true);
        textArea.setPrefSize(800, 600);
        Scene viewContractScene = new Scene(textArea);
        Stage viewContractStage = new Stage();
        viewContractStage.setTitle(Res.get("shared.contract.title", dispute.getShortTradeId()));
        viewContractStage.setScene(viewContractScene);
        if (owner == null)
            owner = MainView.getRootContainer();
        Scene rootScene = owner.getScene();
        viewContractStage.initOwner(rootScene.getWindow());
        viewContractStage.initModality(Modality.NONE);
        viewContractStage.initStyle(StageStyle.UTILITY);
        viewContractStage.show();
        Window window = rootScene.getWindow();
        double titleBarHeight = window.getHeight() - rootScene.getHeight();
        viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
        viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
    });
    Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
    // TODO app wide focus
    // closeButton.requestFocus();
    closeButton.setOnAction(e -> {
        closeHandlerOptional.ifPresent(Runnable::run);
        hide();
    });
}
Also used : Window(javafx.stage.Window) TextArea(javafx.scene.control.TextArea) Tooltip(javafx.scene.control.Tooltip) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Scene(javafx.scene.Scene) Offer(bisq.core.offer.Offer) Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) Stage(javafx.stage.Stage) Contract(bisq.core.trade.Contract)

Aggregations

PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)14 CryptoCurrencyAccountPayload (bisq.core.payment.payload.CryptoCurrencyAccountPayload)5 Contract (bisq.core.trade.Contract)5 AddressEntry (bisq.core.btc.AddressEntry)4 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)4 NodeAddress (bisq.network.p2p.NodeAddress)4 Button (javafx.scene.control.Button)4 WesternUnionAccountPayload (bisq.core.payment.payload.WesternUnionAccountPayload)3 TradingPeer (bisq.core.trade.protocol.TradingPeer)3 TextFieldWithCopyIcon (bisq.desktop.components.TextFieldWithCopyIcon)3 Date (java.util.Date)3 Tooltip (javafx.scene.control.Tooltip)3 Offer (bisq.core.offer.Offer)2 CashDepositAccountPayload (bisq.core.payment.payload.CashDepositAccountPayload)2 USPostalMoneyOrderAccountPayload (bisq.core.payment.payload.USPostalMoneyOrderAccountPayload)2 BusyAnimation (bisq.desktop.components.BusyAnimation)2 TitledGroupBg (bisq.desktop.components.TitledGroupBg)2 Scene (javafx.scene.Scene)2 Label (javafx.scene.control.Label)2 TextArea (javafx.scene.control.TextArea)2