mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-14 18:06:34 -04:00
Use IRC as paymeent method
This commit is contained in:
parent
3d494ecc67
commit
0a9222db21
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum BankAccountType {
|
||||
IRC("", ""),
|
||||
SEPA("IBAN", "BIC"),
|
||||
WIRE("primary ID", "secondary ID"),
|
||||
INTERNATIONAL("primary ID", "secondary ID"),
|
||||
|
@ -200,7 +200,7 @@ public class Navigation {
|
||||
CHANGE_PASSWORD("/io/bitsquare/gui/main/account/content/password/PasswordView.fxml"),
|
||||
RESTRICTIONS("/io/bitsquare/gui/main/account/content/restrictions/RestrictionsView.fxml"),
|
||||
REGISTRATION("/io/bitsquare/gui/main/account/content/registration/RegistrationView.fxml"),
|
||||
FIAT_ACCOUNT("/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml"),
|
||||
FIAT_ACCOUNT("/io/bitsquare/gui/main/account/content/irc/IrcAccountView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -348,7 +348,7 @@ textfield */
|
||||
#wizard-title-deactivated {
|
||||
-fx-font-weight: bold;
|
||||
-fx-font-size: 16;
|
||||
-fx-text-fill: #CCCCCC;
|
||||
-fx-text-fill: #999999;
|
||||
}
|
||||
#wizard-title-active {
|
||||
-fx-font-weight: bold;
|
||||
@ -362,7 +362,7 @@ textfield */
|
||||
}
|
||||
|
||||
#wizard-sub-title-deactivated {
|
||||
-fx-text-fill: #CCCCCC;
|
||||
-fx-text-fill: #999999;
|
||||
}
|
||||
#wizard-sub-title-active {
|
||||
-fx-text-fill: #333333;
|
||||
@ -409,7 +409,7 @@ textfield */
|
||||
#wizard-title-disabled {
|
||||
-fx-font-weight: bold;
|
||||
-fx-font-size: 16;
|
||||
-fx-text-fill: #CCCCCC;
|
||||
-fx-text-fill: #999999;
|
||||
}
|
||||
#wizard-title-active {
|
||||
-fx-font-weight: bold;
|
||||
|
@ -187,7 +187,7 @@ public class FiatAccountViewCB extends CachedViewCB<FiatAccountPm> implements Co
|
||||
|
||||
@FXML
|
||||
void onCompleted() {
|
||||
if (parent != null)
|
||||
if (parent instanceof MultiStepNavigation)
|
||||
((MultiStepNavigation) parent).nextStep(this);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,211 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.account.content.irc;
|
||||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.arbitrator.Reputation;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.locale.Region;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.Utils;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class IrcAccountModel extends UIModel {
|
||||
private static final Logger log = LoggerFactory.getLogger(IrcAccountModel.class);
|
||||
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private MessageFacade messageFacade;
|
||||
private final Persistence persistence;
|
||||
|
||||
final StringProperty nickName = new SimpleStringProperty();
|
||||
final ObjectProperty<BankAccountType> type = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
||||
|
||||
final ObservableList<BankAccountType> allTypes = FXCollections.observableArrayList(BankAccountType
|
||||
.getAllBankAccountTypes());
|
||||
final ObservableList<Currency> allCurrencies = FXCollections.observableArrayList(CurrencyUtil
|
||||
.getAllCurrencies());
|
||||
final ObservableList<BankAccount> allBankAccounts = FXCollections.observableArrayList();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
IrcAccountModel(User user, Persistence persistence, Settings settings, MessageFacade messageFacade) {
|
||||
this.persistence = persistence;
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.messageFacade = messageFacade;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (settings.getAcceptedArbitrators().isEmpty())
|
||||
addMockArbitrator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
super.activate();
|
||||
allBankAccounts.setAll(user.getBankAccounts());
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void terminate() {
|
||||
super.terminate();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void saveBankAccount() {
|
||||
BankAccount bankAccount = new BankAccount(type.get(),
|
||||
currency.get(),
|
||||
CountryUtil.getDefaultCountry(),
|
||||
nickName.get(),
|
||||
nickName.get(),
|
||||
"irc",
|
||||
"irc");
|
||||
user.setBankAccount(bankAccount);
|
||||
saveUser();
|
||||
allBankAccounts.setAll(user.getBankAccounts());
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObservableList<Country> getAllCountriesFor(Region selectedRegion) {
|
||||
return FXCollections.observableArrayList(CountryUtil.getAllCountriesFor(selectedRegion));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setType(BankAccountType type) {
|
||||
this.type.set(type);
|
||||
}
|
||||
|
||||
void setCurrency(Currency currency) {
|
||||
this.currency.set(currency);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void reset() {
|
||||
nickName.set(null);
|
||||
|
||||
type.set(null);
|
||||
currency.set(null);
|
||||
}
|
||||
|
||||
private void saveUser() {
|
||||
persistence.write(user);
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
persistence.write(settings);
|
||||
}
|
||||
|
||||
private void addMockArbitrator() {
|
||||
if (settings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
|
||||
String pubKeyAsHex = Utils.HEX.encode(new ECKey().getPubKey());
|
||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
||||
List<Locale> languages = new ArrayList<>();
|
||||
languages.add(LanguageUtil.getDefaultLanguageLocale());
|
||||
List<Arbitrator.METHOD> arbitrationMethods = new ArrayList<>();
|
||||
arbitrationMethods.add(Arbitrator.METHOD.TLS_NOTARY);
|
||||
List<Arbitrator.ID_VERIFICATION> idVerifications = new ArrayList<>();
|
||||
idVerifications.add(Arbitrator.ID_VERIFICATION.PASSPORT);
|
||||
idVerifications.add(Arbitrator.ID_VERIFICATION.GOV_ID);
|
||||
|
||||
Arbitrator arbitrator = new Arbitrator(pubKeyAsHex,
|
||||
messagePubKeyAsHex,
|
||||
"Manfred Karrer",
|
||||
Arbitrator.ID_TYPE.REAL_LIFE_ID,
|
||||
languages,
|
||||
new Reputation(),
|
||||
Coin.parseCoin("0.1"),
|
||||
arbitrationMethods,
|
||||
idVerifications,
|
||||
"http://bitsquare.io/",
|
||||
"Bla bla...");
|
||||
|
||||
settings.addAcceptedArbitrator(arbitrator);
|
||||
persistence.write(settings);
|
||||
|
||||
messageFacade.addArbitrator(arbitrator);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.account.content.irc;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.Currency;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class IrcAccountPm extends PresentationModel<IrcAccountModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(IrcAccountPm.class);
|
||||
|
||||
private final InputValidator nickNameValidator;
|
||||
|
||||
final StringProperty ircNickName = new SimpleStringProperty();
|
||||
final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
|
||||
final ObjectProperty<BankAccountType> type = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
IrcAccountPm(IrcAccountModel model, BankAccountNumberValidator nickNameValidator) {
|
||||
super(model);
|
||||
this.nickNameValidator = nickNameValidator;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
// input
|
||||
ircNickName.bindBidirectional(model.nickName);
|
||||
type.bindBidirectional(model.type);
|
||||
currency.bindBidirectional(model.currency);
|
||||
|
||||
model.nickName.addListener((ov, oldValue, newValue) -> validateInput());
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
super.activate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void terminate() {
|
||||
super.terminate();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
InputValidator.ValidationResult requestSaveBankAccount() {
|
||||
InputValidator.ValidationResult result = validateInput();
|
||||
if (result.isValid) {
|
||||
model.saveBankAccount();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ObservableList<BankAccount> getAllBankAccounts() {
|
||||
return model.allBankAccounts;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Converters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
StringConverter<BankAccountType> getTypesConverter() {
|
||||
return new StringConverter<BankAccountType>() {
|
||||
@Override
|
||||
public String toString(BankAccountType TypeInfo) {
|
||||
return BSResources.get(TypeInfo.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccountType fromString(String s) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
String getBankAccountType(BankAccountType bankAccountType) {
|
||||
return bankAccountType != null ? BSResources.get(bankAccountType.toString()) : "";
|
||||
}
|
||||
|
||||
StringConverter<Currency> getCurrencyConverter() {
|
||||
return new StringConverter<Currency>() {
|
||||
@Override
|
||||
public String toString(Currency currency) {
|
||||
return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Currency fromString(String s) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObservableList<BankAccountType> getAllTypes() {
|
||||
return model.allTypes;
|
||||
}
|
||||
|
||||
ObservableList<Currency> getAllCurrencies() {
|
||||
return model.allCurrencies;
|
||||
}
|
||||
|
||||
InputValidator getNickNameValidator() {
|
||||
return nickNameValidator;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setType(BankAccountType type) {
|
||||
model.setType(type);
|
||||
validateInput();
|
||||
}
|
||||
|
||||
void setCurrency(Currency currency) {
|
||||
model.setCurrency(currency);
|
||||
validateInput();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
private InputValidator.ValidationResult validateInput() {
|
||||
InputValidator.ValidationResult result = nickNameValidator.validate(model.nickName.get());
|
||||
if (model.currency.get() == null)
|
||||
result = new InputValidator.ValidationResult(false,
|
||||
"You have not selected a currency");
|
||||
if (result.isValid) {
|
||||
if (model.type.get() == null)
|
||||
result = new InputValidator.ValidationResult(false,
|
||||
"You have not selected a payments method");
|
||||
}
|
||||
|
||||
saveButtonDisable.set(!result.isValid);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bitsquare.
|
||||
~
|
||||
~ Bitsquare is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import io.bitsquare.gui.components.InfoDisplay?>
|
||||
<?import io.bitsquare.gui.components.InputTextField?>
|
||||
<?import io.bitsquare.gui.components.TitledGroupBg?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.account.content.irc.IrcAccountViewCB" hgap="5.0"
|
||||
vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
||||
<!--
|
||||
Setup
|
||||
-->
|
||||
<TitledGroupBg text="Setup your payments account" GridPane.rowSpan="8"/>
|
||||
|
||||
<Label text="Payments method:" GridPane.rowIndex="0">
|
||||
<GridPane.margin>
|
||||
<Insets top="10"/>
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<ComboBox fx:id="typesComboBox" promptText="Select payments method" onAction="#onSelectType"
|
||||
GridPane.rowIndex="0" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets top="10"/>
|
||||
</GridPane.margin>
|
||||
</ComboBox>
|
||||
|
||||
<Label text="IRC nick name:" GridPane.rowIndex="1"/>
|
||||
<InputTextField fx:id="ircNickNameTextField" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="Currency:" GridPane.rowIndex="2"/>
|
||||
<ComboBox fx:id="currencyComboBox" promptText="Select currency"
|
||||
onAction="#onSelectCurrency" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2"/>
|
||||
|
||||
<InfoDisplay gridPane="$root" onAction="#onOpenSetupHelp" rowIndex="3"
|
||||
text="The payments account data will be saved in a encrypted form to the Bitcoin block chain and will be used in the trade process for account verification."/>
|
||||
|
||||
<HBox fx:id="buttonsHBox" GridPane.columnIndex="1" GridPane.rowIndex="4" spacing="10">
|
||||
<Button fx:id="saveButton" text="Save" onAction="#onSave" defaultButton="true" disable="true"/>
|
||||
<GridPane.margin>
|
||||
<Insets top="15.0" bottom="5.0"/>
|
||||
</GridPane.margin>
|
||||
</HBox>
|
||||
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="200.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
|
||||
<rowConstraints>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
|
||||
</GridPane>
|
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.account.content.irc;
|
||||
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Currency;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/*
|
||||
Just temporary for giving the user a possibility to test the app via simulating the bank transfer in a IRC chat.
|
||||
*/
|
||||
public class IrcAccountViewCB extends CachedViewCB<IrcAccountPm> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(IrcAccountViewCB.class);
|
||||
|
||||
@FXML HBox buttonsHBox;
|
||||
@FXML InputTextField ircNickNameTextField;
|
||||
@FXML Button saveButton;
|
||||
@FXML ComboBox<BankAccountType> typesComboBox;
|
||||
@FXML ComboBox<Currency> currencyComboBox;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
IrcAccountViewCB(IrcAccountPm presentationModel) {
|
||||
super(presentationModel);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
typesComboBox.setItems(presentationModel.getAllTypes());
|
||||
typesComboBox.setConverter(presentationModel.getTypesConverter());
|
||||
|
||||
currencyComboBox.setItems(presentationModel.getAllCurrencies());
|
||||
currencyComboBox.setConverter(presentationModel.getCurrencyConverter());
|
||||
|
||||
ircNickNameTextField.setValidator(presentationModel.getNickNameValidator());
|
||||
|
||||
// we use a custom cell for deactivating non IRC items, later we use the standard cell and the StringConverter
|
||||
typesComboBox.setCellFactory(new Callback<ListView<BankAccountType>, ListCell<BankAccountType>>() {
|
||||
@Override
|
||||
public ListCell<BankAccountType> call(ListView<BankAccountType> p) {
|
||||
return new ListCell<BankAccountType>() {
|
||||
|
||||
@Override
|
||||
protected void updateItem(BankAccountType item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
setText(presentationModel.getBankAccountType(item));
|
||||
|
||||
if (item == null || empty) {
|
||||
setGraphic(null);
|
||||
}
|
||||
else if (item != BankAccountType.IRC) {
|
||||
setOpacity(0.3);
|
||||
setDisable(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
super.initialize(url, rb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
super.activate();
|
||||
|
||||
setupListeners();
|
||||
setupBindings();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void terminate() {
|
||||
super.terminate();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ContextAware implementation
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void useSettingsContext(boolean useSettingsContext) {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI handlers
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@FXML
|
||||
void onSelectType() {
|
||||
presentationModel.setType(typesComboBox.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
|
||||
@FXML
|
||||
void onSelectCurrency() {
|
||||
presentationModel.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
|
||||
@FXML
|
||||
void onSave() {
|
||||
InputValidator.ValidationResult result = presentationModel.requestSaveBankAccount();
|
||||
if (result.isValid && parent instanceof MultiStepNavigation)
|
||||
((MultiStepNavigation) parent).nextStep(this);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void onOpenSetupHelp() {
|
||||
Help.openWindow(HelpId.SETUP_FIAT_ACCOUNT);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupListeners() {
|
||||
presentationModel.type.addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
typesComboBox.getSelectionModel().select(typesComboBox.getItems().indexOf(newValue));
|
||||
else
|
||||
typesComboBox.getSelectionModel().clearSelection();
|
||||
});
|
||||
|
||||
presentationModel.currency.addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue));
|
||||
else
|
||||
currencyComboBox.getSelectionModel().clearSelection();
|
||||
});
|
||||
}
|
||||
|
||||
private void setupBindings() {
|
||||
// input
|
||||
ircNickNameTextField.textProperty().bindBidirectional(presentationModel.ircNickName);
|
||||
saveButton.disableProperty().bind(presentationModel.saveButtonDisable);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import javax.inject.Inject;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
|
||||
import org.controlsfx.control.action.AbstractAction;
|
||||
import org.controlsfx.control.action.Action;
|
||||
@ -106,7 +105,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
|
||||
overlayManager.blurContent();
|
||||
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
/* actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
@ -115,7 +114,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
|
||||
content.putString(presentationModel.getTransactionId());
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
|
@ -90,13 +90,16 @@ public class AccountSettingsViewCB extends CachedViewCB {
|
||||
Navigation.Item.SEED_WORDS, toggleGroup);
|
||||
password = new MenuItem(navigation, "Wallet password",
|
||||
Navigation.Item.CHANGE_PASSWORD, toggleGroup);
|
||||
restrictions = new MenuItem(navigation, "Trading restrictions",
|
||||
restrictions = new MenuItem(navigation, "Arbitrator selection",
|
||||
Navigation.Item.RESTRICTIONS, toggleGroup);
|
||||
fiatAccount = new MenuItem(navigation, "Payments account(s)",
|
||||
Navigation.Item.FIAT_ACCOUNT, toggleGroup);
|
||||
registration = new MenuItem(navigation, "Renew your account",
|
||||
Navigation.Item.REGISTRATION, toggleGroup);
|
||||
|
||||
seedWords.setDisable(true);
|
||||
password.setDisable(true);
|
||||
restrictions.setDisable(true);
|
||||
registration.setDisable(true);
|
||||
|
||||
leftVBox.getChildren().addAll(seedWords, password,
|
||||
@ -114,7 +117,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
|
||||
if (items.length == 3 &&
|
||||
items[2] == Navigation.Item.ACCOUNT_SETTINGS) {
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.SEED_WORDS);
|
||||
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.FIAT_ACCOUNT);
|
||||
}
|
||||
else {
|
||||
if (items.length == 4 &&
|
||||
|
@ -22,7 +22,7 @@ import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.account.content.fiat.FiatAccountViewCB;
|
||||
import io.bitsquare.gui.main.account.content.irc.IrcAccountViewCB;
|
||||
import io.bitsquare.gui.main.account.content.password.PasswordViewCB;
|
||||
import io.bitsquare.gui.main.account.content.registration.RegistrationViewCB;
|
||||
import io.bitsquare.gui.main.account.content.restrictions.RestrictionsViewCB;
|
||||
@ -83,6 +83,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
|
||||
if (navigationItems != null &&
|
||||
navigationItems.length == 4 &&
|
||||
navigationItems[2] == Navigation.Item.ACCOUNT_SETUP) {
|
||||
|
||||
switch (navigationItems[3]) {
|
||||
case SEED_WORDS:
|
||||
childController = seedWords.show();
|
||||
@ -117,8 +118,8 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
|
||||
Navigation.Item.SEED_WORDS);
|
||||
password = new WizardItem(this, "Setup password", "Protect your wallet with a password",
|
||||
Navigation.Item.ADD_PASSWORD);
|
||||
restrictions = new WizardItem(this, "Setup your preferences",
|
||||
"Define your preferences with whom you want to trade",
|
||||
restrictions = new WizardItem(this, "Select arbitrators",
|
||||
"Select which arbitrators you want to use for trading",
|
||||
Navigation.Item.RESTRICTIONS);
|
||||
fiatAccount = new WizardItem(this, " Setup Payments account(s)",
|
||||
"You need to setup at least one payment account",
|
||||
@ -129,10 +130,15 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
|
||||
|
||||
leftVBox.getChildren().addAll(seedWords, password, restrictions, fiatAccount, registration);
|
||||
|
||||
seedWords.setDisable(true);
|
||||
password.setDisable(true);
|
||||
restrictions.setDisable(true);
|
||||
registration.setDisable(true);
|
||||
|
||||
super.initialize(url, rb);
|
||||
|
||||
navigation.addListener(listener);
|
||||
childController = seedWords.show();
|
||||
childController = fiatAccount.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -160,7 +166,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
|
||||
restrictions.onCompleted();
|
||||
childController = fiatAccount.show();
|
||||
}
|
||||
else if (childView instanceof FiatAccountViewCB) {
|
||||
else if (childView instanceof IrcAccountViewCB) {
|
||||
fiatAccount.onCompleted();
|
||||
childController = registration.show();
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import javafx.geometry.Point2D;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Window;
|
||||
|
||||
@ -351,7 +350,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
// Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added
|
||||
// our own actions.
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
/* actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
@ -360,7 +359,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
content.putString(presentationModel.transactionId.get());
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
@ -376,7 +375,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
});
|
||||
|
||||
Popups.openInfo(BSResources.get("createOffer.success.headline"),
|
||||
BSResources.get("createOffer.success.info", presentationModel.transactionId.get()),
|
||||
BSResources.get("createOffer.success.info"),
|
||||
actions);
|
||||
}
|
||||
});
|
||||
|
@ -54,7 +54,6 @@ import javafx.geometry.Point2D;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Window;
|
||||
|
||||
@ -325,7 +324,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
|
||||
// Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added
|
||||
// our own actions.
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
/* actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
@ -334,7 +333,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
|
||||
content.putString(presentationModel.transactionId.get());
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
@ -352,7 +351,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
|
||||
});
|
||||
|
||||
Popups.openInfo(BSResources.get("takeOffer.success.headline"),
|
||||
BSResources.get("takeOffer.success.info", presentationModel.transactionId.get()),
|
||||
BSResources.get("takeOffer.success.info"),
|
||||
actions);
|
||||
}
|
||||
});
|
||||
|
@ -157,7 +157,7 @@ public class P2PNode {
|
||||
}
|
||||
|
||||
public FutureGet getData(Number160 locationKey) {
|
||||
log.trace("getData");
|
||||
//log.trace("getData");
|
||||
return peerDHT.get(locationKey).start();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class VerifyOffer {
|
||||
checkNotNull(offer.getAcceptedLanguageLocales(), "AcceptedLanguageLocales is null");
|
||||
checkNotNull(offer.getAmount(), "Amount is null");
|
||||
checkNotNull(offer.getArbitrators(), "Arbitrator is null");
|
||||
checkNotNull(offer.getBankAccountCountry(), "BankAccountCountry is null");
|
||||
//checkNotNull(offer.getBankAccountCountry(), "BankAccountCountry is null");
|
||||
checkNotNull(offer.getBankAccountId(), "BankAccountId is null");
|
||||
checkNotNull(offer.getSecurityDeposit(), "SecurityDeposit is null");
|
||||
checkNotNull(offer.getCreationDate(), "CreationDate is null");
|
||||
@ -50,8 +50,8 @@ public class VerifyOffer {
|
||||
checkNotNull(offer.getMinAmount(), "MinAmount is null");
|
||||
checkNotNull(offer.getPrice(), "Price is null");
|
||||
|
||||
checkArgument(!offer.getAcceptedCountries().isEmpty(), "AcceptedCountries is empty");
|
||||
checkArgument(!offer.getAcceptedLanguageLocales().isEmpty(), "AcceptedLanguageLocales is empty");
|
||||
//checkArgument(!offer.getAcceptedCountries().isEmpty(), "AcceptedCountries is empty");
|
||||
//checkArgument(!offer.getAcceptedLanguageLocales().isEmpty(), "AcceptedLanguageLocales is empty");
|
||||
checkArgument(offer.getMinAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0,
|
||||
"MinAmount is less then " + Restrictions.MIN_TRADE_AMOUNT);
|
||||
checkArgument(offer.getAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0,
|
||||
|
@ -12,7 +12,6 @@ shared.no=No
|
||||
shared.openSettings=Open settings for editing
|
||||
shared.buy=Buy Bitcoin
|
||||
shared.sell=Sell Bitcoin
|
||||
shared.copyTxId=Copy transaction ID
|
||||
|
||||
# validation
|
||||
validation.empty=Empty input is not allowed.
|
||||
@ -71,8 +70,7 @@ createOffer.advancedBox.county=Payments account country:
|
||||
createOffer.advancedBox.info=Your trading partners must fulfill your offer restrictions. You can edit the accepted countries, languages and arbitrators in the settings. The payments account details are used from your current selected payments account (if you have multiple payments accounts).
|
||||
|
||||
createOffer.success.headline=Your offer has been successfully published to the distributed offerbook.
|
||||
createOffer.success.info=In the Offers screen you can manage your open offers.\n\nThe Transaction ID for the offer \
|
||||
payment is: {0}
|
||||
createOffer.success.info=In the Offers screen you can manage your open offers.
|
||||
|
||||
createOffer.error.message=An error occurred when placing the offer.\n{0}
|
||||
|
||||
@ -126,7 +124,7 @@ takeOffer.advancedBox.info=These are the offer restrictions your trading partner
|
||||
takeOffer.success.headline=Your have successfully published the deposit.
|
||||
takeOffer.success.info=You need to wait now for the Bitcoin buyer to transfer the money to you. \nYou will get a \
|
||||
notification when he has started the EUR payment. You can see the status of your trade in the trades section under \
|
||||
pending trades.\n\nThe Transaction ID for the deposit payment is: {0}
|
||||
pending trades.
|
||||
takeOffer.error.message=An error occurred when taking the offer.\n{0}
|
||||
|
||||
|
||||
@ -136,6 +134,7 @@ takeOffer.error.message=An error occurred when taking the offer.\n{0}
|
||||
OTHER=Other
|
||||
|
||||
# BankAccountTypeInfo.BankAccountType
|
||||
IRC=Demo mode with IRC
|
||||
SEPA=Sepa
|
||||
WIRE=Wire
|
||||
INTERNATIONAL=International
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
<logger name="io.bitsquare" level="TRACE"/>
|
||||
|
||||
<logger name="org.bitcoinj" level="WARN"/>
|
||||
<logger name="net.tomp2p" level="TRACE"/>
|
||||
<logger name="org.bitcoinj" level="INFO"/>
|
||||
<logger name="net.tomp2p" level="WARN"/>
|
||||
|
||||
<logger name="io.netty.util" level="WARN"/>
|
||||
<logger name="io.netty.channel" level="WARN"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user