Search in sources :

Example 1 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class ArbitratorRegistrationView method buildUI.

private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    root.getChildren().add(gridPane);
    addTitledGroupBg(gridPane, gridRow, 3, "Arbitrator registration");
    pubKeyTextField = FormBuilder.addLabelTextField(gridPane, gridRow, "Public key:", model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;
    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);
    Tuple2<Label, ListView> tuple = addLabelListView(gridPane, ++gridRow, "Your languages:");
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {

        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<String>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    languageComboBox = addLabelComboBox(gridPane, ++gridRow).second;
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText("Add language");
    languageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());
    registerButton = addButtonAfterGroup(gridPane, ++gridRow, "Register arbitrator");
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());
    revokeButton = addButton(gridPane, ++gridRow, "Revoke registration");
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());
    addTitledGroupBg(gridPane, ++gridRow, 2, "Information", Layout.GROUP_DISTANCE);
    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText("Please note that you need to stay  available for 15 days after revoking as there might be trades which are using you as " + "arbitrator. The max. allowed trade period is 8 days and the dispute process might take up to 7 days.");
}
Also used : HPos(javafx.geometry.HPos) Popup(io.bitsquare.gui.main.overlays.popups.Popup) javafx.scene.layout(javafx.scene.layout) Arbitrator(io.bitsquare.arbitration.Arbitrator) javafx.scene.control(javafx.scene.control) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) Tuple2(io.bitsquare.common.util.Tuple2) StringConverter(javafx.util.StringConverter) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) LanguageUtil(io.bitsquare.locale.LanguageUtil) EnterPrivKeyWindow(io.bitsquare.gui.main.overlays.windows.EnterPrivKeyWindow) Inject(javax.inject.Inject) FormBuilder(io.bitsquare.gui.util.FormBuilder) Insets(javafx.geometry.Insets) ListChangeListener(javafx.collections.ListChangeListener) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) ImageView(javafx.scene.image.ImageView) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) Callback(javafx.util.Callback) Insets(javafx.geometry.Insets) ImageView(javafx.scene.image.ImageView)

Example 2 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class ArbitratorRegistrationViewModel method onRegister.

void onRegister(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
    updateDisableStates();
    if (allDataValid) {
        AddressEntry arbitratorDepositAddressEntry = walletService.getOrCreateAddressEntry(AddressEntry.Context.ARBITRATOR);
        String registrationSignature = arbitratorManager.signStorageSignaturePubKey(registrationKey);
        Arbitrator arbitrator = new Arbitrator(p2PService.getAddress(), arbitratorDepositAddressEntry.getPubKey(), arbitratorDepositAddressEntry.getAddressString(), keyRing.getPubKeyRing(), new ArrayList<>(languageCodes), new Date(), registrationKey.getPubKey(), registrationSignature);
        arbitratorManager.addArbitrator(arbitrator, () -> {
            updateDisableStates();
            resultHandler.handleResult();
        }, (errorMessage) -> {
            updateDisableStates();
            errorMessageHandler.handleErrorMessage(errorMessage);
        });
    }
}
Also used : AddressEntry(io.bitsquare.btc.AddressEntry) Arbitrator(io.bitsquare.arbitration.Arbitrator) Date(java.util.Date)

Example 3 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class ArbitratorRegistrationViewModel method activate.

@Override
protected void activate() {
    arbitratorManager.getArbitratorsObservableMap().addListener(arbitratorMapChangeListener);
    Arbitrator myRegisteredArbitrator = user.getRegisteredArbitrator();
    myArbitratorProperty.set(myRegisteredArbitrator);
    updateDisableStates();
}
Also used : Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 4 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class Trade method applyArbitratorNodeAddress.

public void applyArbitratorNodeAddress(NodeAddress arbitratorNodeAddress) {
    this.arbitratorNodeAddress = arbitratorNodeAddress;
    Arbitrator arbitrator = processModel.getUser().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
    checkNotNull(arbitrator, "arbitrator must not be null");
    arbitratorBtcPubKey = arbitrator.getBtcPubKey();
}
Also used : Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 5 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class CreateOfferFeeTx method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        NodeAddress selectedArbitratorNodeAddress = ArbitrationSelectionRule.select(model.user.getAcceptedArbitratorAddresses(), model.offer);
        log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
        Arbitrator selectedArbitrator = model.user.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
        checkNotNull(selectedArbitrator, "selectedArbitrator must not be null at CreateOfferFeeTx");
        WalletService walletService = model.walletService;
        String id = model.offer.getId();
        Address fundingAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.OFFER_FUNDING).getAddress();
        Address reservedForTradeAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE).getAddress();
        Address changeAddress = walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE).getAddress();
        Transaction transaction = model.tradeWalletService.createTradingFeeTx(fundingAddress, reservedForTradeAddress, changeAddress, model.reservedFundsForOffer, model.useSavingsWallet, FeePolicy.getCreateOfferFee(), selectedArbitrator.getBtcAddress());
        // We assume there will be no tx malleability. We add a check later in case the published offer has a different hash.
        // As the txId is part of the offer and therefore change the hash data we need to be sure to have no
        // tx malleability
        model.offer.setOfferFeePaymentTxID(transaction.getHashAsString());
        model.setTransaction(transaction);
        complete();
    } catch (Throwable t) {
        model.offer.setErrorMessage("An error occurred.\n" + "Error message:\n" + t.getMessage());
        failed(t);
    }
}
Also used : NodeAddress(io.bitsquare.p2p.NodeAddress) Address(org.bitcoinj.core.Address) Transaction(org.bitcoinj.core.Transaction) NodeAddress(io.bitsquare.p2p.NodeAddress) Arbitrator(io.bitsquare.arbitration.Arbitrator) WalletService(io.bitsquare.btc.WalletService)

Aggregations

Arbitrator (io.bitsquare.arbitration.Arbitrator)9 Transaction (org.bitcoinj.core.Transaction)3 AddressEntry (io.bitsquare.btc.AddressEntry)2 WalletService (io.bitsquare.btc.WalletService)2 Popup (io.bitsquare.gui.main.overlays.popups.Popup)2 NodeAddress (io.bitsquare.p2p.NodeAddress)2 Address (org.bitcoinj.core.Address)2 Dispute (io.bitsquare.arbitration.Dispute)1 UserThread (io.bitsquare.common.UserThread)1 Tuple2 (io.bitsquare.common.util.Tuple2)1 ActivatableViewAndModel (io.bitsquare.gui.common.view.ActivatableViewAndModel)1 FxmlView (io.bitsquare.gui.common.view.FxmlView)1 EnterPrivKeyWindow (io.bitsquare.gui.main.overlays.windows.EnterPrivKeyWindow)1 FormBuilder (io.bitsquare.gui.util.FormBuilder)1 ImageUtil (io.bitsquare.gui.util.ImageUtil)1 Layout (io.bitsquare.gui.util.Layout)1 LanguageUtil (io.bitsquare.locale.LanguageUtil)1 BuyerTrade (io.bitsquare.trade.BuyerTrade)1 SellerTrade (io.bitsquare.trade.SellerTrade)1 Trade (io.bitsquare.trade.Trade)1