Search in sources :

Example 6 with Offer

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

the class BSFormatterTest method testFormatAmountWithAlignmenWithDecimals.

@Test
public void testFormatAmountWithAlignmenWithDecimals() {
    OfferPayload offerPayload = mock(OfferPayload.class);
    Offer offer = new Offer(offerPayload);
    when(offerPayload.getMinAmount()).thenReturn(10000000L);
    when(offerPayload.getAmount()).thenReturn(20000000L);
    assertEquals("0.1000 - 0.2000", formatter.formatAmount(offer, 4, true, 15));
}
Also used : OfferMaker.btcUsdOffer(bisq.core.offer.OfferMaker.btcUsdOffer) Offer(bisq.core.offer.Offer) OfferPayload(bisq.core.offer.OfferPayload) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with Offer

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

the class BuyerAsMakerCreatesAndSignsDepositTx method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        checkNotNull(trade.getTradeAmount(), "trade.getTradeAmount() must not be null");
        BtcWalletService walletService = processModel.getBtcWalletService();
        String id = processModel.getOffer().getId();
        TradingPeer tradingPeer = processModel.getTradingPeer();
        final Offer offer = trade.getOffer();
        // params
        final boolean makerIsBuyer = true;
        final byte[] contractHash = Hash.getSha256Hash(trade.getContractAsJson());
        trade.setContractHash(contractHash);
        log.debug("\n\n------------------------------------------------------------\n" + "Contract as json\n" + trade.getContractAsJson() + "\n------------------------------------------------------------\n");
        final Coin makerInputAmount = offer.getBuyerSecurityDeposit();
        Optional<AddressEntry> addressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG);
        checkArgument(addressEntryOptional.isPresent(), "addressEntryOptional must be present");
        AddressEntry makerMultiSigAddressEntry = addressEntryOptional.get();
        makerMultiSigAddressEntry.setCoinLockedInMultiSig(makerInputAmount);
        walletService.saveAddressEntryList();
        final Coin msOutputAmount = makerInputAmount.add(trade.getTxFee()).add(offer.getSellerSecurityDeposit()).add(trade.getTradeAmount());
        final List<RawTransactionInput> takerRawTransactionInputs = tradingPeer.getRawTransactionInputs();
        final long takerChangeOutputValue = tradingPeer.getChangeOutputValue();
        final String takerChangeAddressString = tradingPeer.getChangeOutputAddress();
        final Address makerAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE).getAddress();
        final Address makerChangeAddress = walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE).getAddress();
        final byte[] buyerPubKey = processModel.getMyMultiSigPubKey();
        checkArgument(Arrays.equals(buyerPubKey, makerMultiSigAddressEntry.getPubKey()), "buyerPubKey from AddressEntry must match the one from the trade data. trade id =" + id);
        final byte[] sellerPubKey = tradingPeer.getMultiSigPubKey();
        final byte[] arbitratorBtcPubKey = trade.getArbitratorBtcPubKey();
        PreparedDepositTxAndMakerInputs result = processModel.getTradeWalletService().makerCreatesAndSignsDepositTx(makerIsBuyer, contractHash, makerInputAmount, msOutputAmount, takerRawTransactionInputs, takerChangeOutputValue, takerChangeAddressString, makerAddress, makerChangeAddress, buyerPubKey, sellerPubKey, arbitratorBtcPubKey);
        processModel.setPreparedDepositTx(result.depositTransaction);
        processModel.setRawTransactionInputs(result.rawMakerInputs);
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : Address(org.bitcoinj.core.Address) AddressEntry(bisq.core.btc.AddressEntry) RawTransactionInput(bisq.core.btc.data.RawTransactionInput) Coin(org.bitcoinj.core.Coin) TradingPeer(bisq.core.trade.protocol.TradingPeer) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Offer(bisq.core.offer.Offer) PreparedDepositTxAndMakerInputs(bisq.core.btc.data.PreparedDepositTxAndMakerInputs)

Example 8 with Offer

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

the class TransactionAwareOpenOffer method isRelatedToTransaction.

public boolean isRelatedToTransaction(Transaction transaction) {
    Offer offer = delegate.getOffer();
    String paymentTxId = offer.getOfferFeePaymentTxId();
    String txId = transaction.getHashAsString();
    return paymentTxId.equals(txId);
}
Also used : Offer(bisq.core.offer.Offer) OpenOffer(bisq.core.offer.OpenOffer)

Example 9 with Offer

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

the class CreateOfferView method onPlaceOffer.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
private void onPlaceOffer() {
    if (model.isReadyForTxBroadcast()) {
        if (model.dataModel.isMakerFeeValid()) {
            if (model.hasAcceptedArbitrators()) {
                Offer offer = model.createAndGetOffer();
                // noinspection PointlessBooleanExpression
                if (!DevEnv.isDevMode()) {
                    offerDetailsWindow.onPlaceOffer(() -> model.onPlaceOffer(offer, offerDetailsWindow::hide)).show(offer);
                } else {
                    balanceSubscription.unsubscribe();
                    model.onPlaceOffer(offer, () -> {
                    });
                }
            } else {
                new Popup<>().headLine(Res.get("popup.warning.noArbitratorSelected.headline")).instruction(Res.get("popup.warning.noArbitratorSelected.msg")).actionButtonTextWithGoTo("navigation.arbitratorSelection").onAction(() -> {
                    navigation.setReturnPath(navigation.getCurrentPath());
                    // noinspection unchecked
                    navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
                }).show();
            }
        } else {
            showInsufficientBsqFundsForBtcFeePaymentPopup();
        }
    } else {
        model.showNotReadyForTxBroadcastPopups();
    }
}
Also used : AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) MainView(bisq.desktop.main.MainView) Offer(bisq.core.offer.Offer) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) AccountView(bisq.desktop.main.account.AccountView)

Example 10 with Offer

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

the class OfferBookView method getPaymentMethodColumn.

private TableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
    TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>(Res.get("shared.paymentMethod")) {

        {
            setMinWidth(80);
        }
    };
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

        @Override
        public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
            return new TableCell<OfferBookListItem, OfferBookListItem>() {

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getPaymentMethod(item));
                        field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
                        field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) FiatAccountsView(bisq.desktop.main.account.content.fiataccounts.FiatAccountsView) BSFormatter(bisq.desktop.util.BSFormatter) FormBuilder.getIcon(bisq.desktop.util.FormBuilder.getIcon) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) TableView(javafx.scene.control.TableView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Canvas(javafx.scene.canvas.Canvas) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FiatCurrency(bisq.core.locale.FiatCurrency) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) StringConverter(javafx.util.StringConverter) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) MainView(bisq.desktop.main.MainView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) Price(bisq.core.monetary.Price) ObservableValue(javafx.beans.value.ObservableValue) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ContentDisplay(javafx.scene.control.ContentDisplay) Tooltip(javafx.scene.control.Tooltip) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

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