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.");
}
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);
});
}
}
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();
}
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();
}
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);
}
}
Aggregations