Search in sources :

Example 16 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class DisputeSummaryWindow method isPayoutAmountValid.

private boolean isPayoutAmountValid() {
    Coin buyerAmount = formatter.parseToCoin(buyerPayoutAmountInputTextField.getText());
    Coin sellerAmount = formatter.parseToCoin(sellerPayoutAmountInputTextField.getText());
    Contract contract = dispute.getContract();
    Coin tradeAmount = contract.getTradeAmount();
    Offer offer = new Offer(contract.getOfferPayload());
    Coin available = tradeAmount.add(offer.getBuyerSecurityDeposit()).add(offer.getSellerSecurityDeposit());
    Coin totalAmount = buyerAmount.add(sellerAmount);
    return (totalAmount.compareTo(available) == 0);
}
Also used : Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer) Contract(bisq.core.trade.Contract)

Example 17 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class DisputeSummaryWindow method applyTradeAmountRadioButtonStates.

private void applyTradeAmountRadioButtonStates() {
    Contract contract = dispute.getContract();
    Offer offer = new Offer(contract.getOfferPayload());
    Coin buyerSecurityDeposit = offer.getBuyerSecurityDeposit();
    Coin sellerSecurityDeposit = offer.getSellerSecurityDeposit();
    Coin tradeAmount = contract.getTradeAmount();
    Coin buyerPayoutAmount = disputeResult.getBuyerPayoutAmount();
    Coin sellerPayoutAmount = disputeResult.getSellerPayoutAmount();
    buyerPayoutAmountInputTextField.setText(formatter.formatCoin(buyerPayoutAmount));
    sellerPayoutAmountInputTextField.setText(formatter.formatCoin(sellerPayoutAmount));
    if (buyerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit)) && sellerPayoutAmount.equals(sellerSecurityDeposit)) {
        buyerGetsTradeAmountRadioButton.setSelected(true);
    } else if (buyerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit)) && sellerPayoutAmount.equals(Coin.ZERO)) {
        buyerGetsAllRadioButton.setSelected(true);
    } else if (sellerPayoutAmount.equals(tradeAmount.add(sellerSecurityDeposit)) && buyerPayoutAmount.equals(buyerSecurityDeposit)) {
        sellerGetsTradeAmountRadioButton.setSelected(true);
    } else if (sellerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit)) && buyerPayoutAmount.equals(Coin.ZERO)) {
        sellerGetsAllRadioButton.setSelected(true);
    } else {
        customRadioButton.setSelected(true);
    }
}
Also used : Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer) Contract(bisq.core.trade.Contract)

Example 18 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class DisputeSummaryWindow method applyCustomAmounts.

private void applyCustomAmounts(InputTextField inputTextField) {
    Contract contract = dispute.getContract();
    Coin buyerAmount = formatter.parseToCoin(buyerPayoutAmountInputTextField.getText());
    Coin sellerAmount = formatter.parseToCoin(sellerPayoutAmountInputTextField.getText());
    Offer offer = new Offer(contract.getOfferPayload());
    Coin available = contract.getTradeAmount().add(offer.getBuyerSecurityDeposit()).add(offer.getSellerSecurityDeposit());
    Coin totalAmount = buyerAmount.add(sellerAmount);
    if (totalAmount.compareTo(available) > 0) {
        new Popup<>().warning(Res.get("disputeSummaryWindow.payout.adjustAmount", available.toFriendlyString())).show();
        if (inputTextField == buyerPayoutAmountInputTextField) {
            buyerAmount = available.subtract(sellerAmount);
            inputTextField.setText(formatter.formatCoin(buyerAmount));
        } else if (inputTextField == sellerPayoutAmountInputTextField) {
            sellerAmount = available.subtract(buyerAmount);
            inputTextField.setText(formatter.formatCoin(sellerAmount));
        }
    }
    disputeResult.setBuyerPayoutAmount(buyerAmount);
    disputeResult.setSellerPayoutAmount(sellerAmount);
    if (buyerAmount.compareTo(sellerAmount) > 0)
        disputeResult.setWinner(DisputeResult.Winner.BUYER);
    else
        disputeResult.setWinner(DisputeResult.Winner.SELLER);
}
Also used : Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer) Popup(bisq.desktop.main.overlays.popups.Popup) Contract(bisq.core.trade.Contract)

Example 19 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class PendingTradesViewModel method getSecurityDeposit.

public String getSecurityDeposit() {
    Offer offer = dataModel.getOffer();
    Trade trade = dataModel.getTrade();
    if (offer != null && trade != null && trade.getTradeAmount() != null) {
        Coin securityDeposit = dataModel.isBuyer() ? offer.getBuyerSecurityDeposit() : offer.getSellerSecurityDeposit();
        String percentage = GUIUtil.getPercentageOfTradeAmount(securityDeposit, trade.getTradeAmount(), btcFormatter);
        return btcFormatter.formatCoinWithCode(securityDeposit) + percentage;
    } else {
        return "";
    }
}
Also used : Trade(bisq.core.trade.Trade) Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer)

Example 20 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class PendingTradesViewModel method getPaymentMethod.

String getPaymentMethod(PendingTradesListItem item) {
    String result = "";
    if (item != null) {
        Offer offer = item.getTrade().getOffer();
        String method = Res.get(offer.getPaymentMethod().getId() + "_SHORT");
        String methodCountryCode = offer.getCountryCode();
        if (methodCountryCode != null)
            result = method + " (" + methodCountryCode + ")";
        else
            result = method;
    }
    return result;
}
Also used : Offer(bisq.core.offer.Offer)

Aggregations

Offer (bisq.core.offer.Offer)49 Coin (org.bitcoinj.core.Coin)15 Test (org.junit.Test)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 OfferPayload (bisq.core.offer.OfferPayload)10 Price (bisq.core.monetary.Price)9 OfferMaker.btcUsdOffer (bisq.core.offer.OfferMaker.btcUsdOffer)8 PaymentMethod (bisq.core.payment.payload.PaymentMethod)7 Contract (bisq.core.trade.Contract)7 NodeAddress (bisq.network.p2p.NodeAddress)7 Volume (bisq.core.monetary.Volume)6 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 MainView (bisq.desktop.main.MainView)5 Button (javafx.scene.control.Button)5 TableCell (javafx.scene.control.TableCell)5 TableColumn (javafx.scene.control.TableColumn)5 TradeCurrency (bisq.core.locale.TradeCurrency)4 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)4