From 8856e31d78b85936eaf3003a1fb1a80cb10533e4 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 28 Apr 2014 17:26:26 +0200 Subject: [PATCH] fix confirmations, add logback, ui stuff, add country(local) to bankaccount --- pom.xml | 44 +++++- src/main/java/io/bitsquare/BitSquare.java | 2 +- .../java/io/bitsquare/bank/BankAccount.java | 33 ++-- .../btc/AccountRegistrationWallet.java | 46 +++--- .../java/io/bitsquare/btc/WalletFacade.java | 10 +- .../java/io/bitsquare/btc/WalletUtil.java | 42 +++++ .../java/io/bitsquare/gui/MainController.java | 20 +-- src/main/java/io/bitsquare/gui/MainView.fxml | 2 +- .../bitsquare/gui/setup/SetupController.java | 147 ++++++++++++------ .../java/io/bitsquare/settings/Settings.java | 42 +++-- src/main/java/io/bitsquare/user/User.java | 4 +- src/main/resources/bitsquare.properties | 1 + src/main/resources/logback.xml | 27 ++++ 13 files changed, 303 insertions(+), 117 deletions(-) create mode 100644 src/main/java/io/bitsquare/btc/WalletUtil.java create mode 100644 src/main/resources/logback.xml diff --git a/pom.xml b/pom.xml index 24ffeb56ce..fbf83c9527 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,6 @@ io.bitsquare bitsquare 0.01-SNAPSHOT - BitSquare A P2P Fiat-Bitcoin Exchange https://www.bitsquare.io @@ -21,13 +20,19 @@ - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0 + GNU AFFERO GENERAL PUBLIC LICENSE + http://www.gnu.org/licenses/agpl-3.0.html repo + + GitHub + https://github.com/bitsquare/bitsquare/issues + + + https://github.com/bitsquare/bitsquare @@ -56,13 +61,21 @@ + + bitsquare src/main/java + true + + **/*.fxml + **/*.css + src/main/resources + false @@ -78,6 +91,7 @@ + @@ -92,17 +106,24 @@ 4.11 test - + + + org.slf4j + slf4j-api + 1.7.7 + + ch.qos.logback logback-classic - 1.0.9 + 1.1.2 compile @@ -151,6 +172,17 @@ + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.1 + + + + UTF-8 diff --git a/src/main/java/io/bitsquare/BitSquare.java b/src/main/java/io/bitsquare/BitSquare.java index 6831d17e44..839045e234 100644 --- a/src/main/java/io/bitsquare/BitSquare.java +++ b/src/main/java/io/bitsquare/BitSquare.java @@ -58,7 +58,7 @@ public class BitSquare extends Application @Override public void stop() throws Exception { - walletFacade.terminateWallet(); + walletFacade.shutDown(); super.stop(); } diff --git a/src/main/java/io/bitsquare/bank/BankAccount.java b/src/main/java/io/bitsquare/bank/BankAccount.java index 5d535c2c01..60c5dbf903 100644 --- a/src/main/java/io/bitsquare/bank/BankAccount.java +++ b/src/main/java/io/bitsquare/bank/BankAccount.java @@ -1,16 +1,20 @@ package io.bitsquare.bank; import java.io.Serializable; +import java.util.Locale; public class BankAccount implements Serializable { private static final long serialVersionUID = 1792577576443221268L; + private static final long VERSION = 1; + + private BankAccountType bankAccountType; + private String accountPrimaryID; + private String accountSecondaryID; + private String accountHolderName; + private Locale locale; - public BankAccountType bankAccountType; - public String accountPrimaryID; - public String accountSecondaryID; - public String accountHolderName; private String uid; // TODO just for mock yet @@ -19,14 +23,15 @@ public class BankAccount implements Serializable this.bankAccountType = bankAccountType; } - public BankAccount(BankAccountType bankAccountType, String accountPrimaryID, String accountSecondaryID, String accountHolderName) + public BankAccount(BankAccountType bankAccountType, String accountPrimaryID, String accountSecondaryID, String accountHolderName, Locale locale) { this.bankAccountType = bankAccountType; this.accountPrimaryID = accountPrimaryID; this.accountSecondaryID = accountSecondaryID; this.accountHolderName = accountHolderName; + this.locale = locale; - uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName; + uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName + "_" + locale.getISO3Country(); } public String getAccountPrimaryID() @@ -54,14 +59,16 @@ public class BankAccount implements Serializable return uid; } - @Override - public String toString() + // Changes of that structure must be reflected in VERSION updates + public String getStringifiedBankAccount() { - return "BankAccount{" + - "bankAccountType=" + bankAccountType + - ", accountPrimaryID='" + accountPrimaryID + '\'' + - ", accountSecondaryID='" + accountSecondaryID + '\'' + - ", accountHolderName='" + accountHolderName + '\'' + + return "{" + + "type=" + bankAccountType + + ", primaryID='" + accountPrimaryID + '\'' + + ", secondaryID='" + accountSecondaryID + '\'' + + ", holderName='" + accountHolderName + '\'' + + ", country='" + locale.getISO3Country() + '\'' + + ", v='" + VERSION + '\'' + '}'; } } diff --git a/src/main/java/io/bitsquare/btc/AccountRegistrationWallet.java b/src/main/java/io/bitsquare/btc/AccountRegistrationWallet.java index 2a2f143f98..4c3a59ea1c 100644 --- a/src/main/java/io/bitsquare/btc/AccountRegistrationWallet.java +++ b/src/main/java/io/bitsquare/btc/AccountRegistrationWallet.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import java.util.Set; import java.util.concurrent.TimeUnit; import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN; @@ -25,8 +24,11 @@ import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN; public class AccountRegistrationWallet extends Wallet implements WalletEventListener { private static final Logger log = LoggerFactory.getLogger(AccountRegistrationWallet.class); + private final File walletFile; private NetworkParameters networkParameters; + private BlockChain chain; + private PeerGroup peerGroup; private List walletListeners = new ArrayList<>(); AccountRegistrationWallet(NetworkParameters networkParameters, BlockChain chain, PeerGroup peerGroup) @@ -34,8 +36,10 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList super(networkParameters); this.networkParameters = networkParameters; + this.chain = chain; + this.peerGroup = peerGroup; - File walletFile = new File(".", "bitsquare_account_reg" + ".wallet"); + walletFile = new File(".", "bitsquare_account_reg" + ".wallet"); if (walletFile.exists()) { try @@ -60,9 +64,27 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList chain.addWallet(this); peerGroup.addWallet(this); + try + { + saveToFile(walletFile); + } catch (IOException e) + { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } autosaveToFile(walletFile, 1, TimeUnit.SECONDS, null); } + void shutDown() + { + try + { + saveToFile(walletFile); + } catch (IOException e) + { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + Address getAddress() { return getKey().toAddress(networkParameters); @@ -148,7 +170,7 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) { for (WalletFacade.WalletListener walletListener : walletListeners) - walletListener.onConfidenceChanged(tx.getConfidence().numBroadcastPeers(), tx.getConfidence().getDepthInBlocks()); + walletListener.onConfidenceChanged(tx.getConfidence().numBroadcastPeers(), WalletUtil.getConfirmationDepthInBlocks(this)); log.info("onTransactionConfidenceChanged " + tx.getConfidence().toString()); } @@ -185,24 +207,8 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList int getConfirmationNumBroadcastPeers() { - Transaction transaction = getTransaction(); + Transaction transaction = WalletUtil.getTransaction(this); return (transaction == null || transaction.getConfidence() == null) ? 0 : transaction.getConfidence().numBroadcastPeers(); } - int getConfirmationDepthInBlocks() - { - Transaction transaction = getTransaction(); - return (transaction == null || transaction.getConfidence() == null) ? 0 : transaction.getConfidence().getDepthInBlocks(); - } - - //TODO only 1 tx supported yet... - private Transaction getTransaction() - { - Set transactions = getTransactions(true); - if (transactions != null && transactions.size() == 1) - { - return transactions.iterator().next(); - } - return null; - } } diff --git a/src/main/java/io/bitsquare/btc/WalletFacade.java b/src/main/java/io/bitsquare/btc/WalletFacade.java index b89054c32c..f2cd1eb1d2 100644 --- a/src/main/java/io/bitsquare/btc/WalletFacade.java +++ b/src/main/java/io/bitsquare/btc/WalletFacade.java @@ -87,8 +87,10 @@ public class WalletFacade implements WalletEventListener log.info(walletAppKit.wallet().toString()); } - public void terminateWallet() + public void shutDown() { + if (accountRegistrationWallet != null) + accountRegistrationWallet.shutDown(); walletAppKit.stopAsync(); walletAppKit.awaitTerminated(); } @@ -176,7 +178,7 @@ public class WalletFacade implements WalletEventListener public int getRegistrationConfirmationDepthInBlocks() { - return getAccountRegistrationWallet().getConfirmationDepthInBlocks(); + return WalletUtil.getConfirmationDepthInBlocks(getAccountRegistrationWallet()); } // WalletEventListener @@ -193,7 +195,7 @@ public class WalletFacade implements WalletEventListener public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) { for (WalletListener walletListener : walletListeners) - walletListener.onConfidenceChanged(tx.getConfidence().numBroadcastPeers(), tx.getConfidence().getDepthInBlocks()); + walletListener.onConfidenceChanged(tx.getConfidence().numBroadcastPeers(), WalletUtil.getConfirmationDepthInBlocks(walletAppKit.wallet())); log.info("onTransactionConfidenceChanged " + tx.getConfidence().toString()); } @@ -271,4 +273,6 @@ public class WalletFacade implements WalletEventListener void onCoinsReceived(BigInteger newBalance); } + + } \ No newline at end of file diff --git a/src/main/java/io/bitsquare/btc/WalletUtil.java b/src/main/java/io/bitsquare/btc/WalletUtil.java new file mode 100644 index 0000000000..3f74975634 --- /dev/null +++ b/src/main/java/io/bitsquare/btc/WalletUtil.java @@ -0,0 +1,42 @@ +package io.bitsquare.btc; + +import com.google.bitcoin.core.Transaction; +import com.google.bitcoin.core.TransactionConfidence; +import com.google.bitcoin.core.Wallet; + +import java.math.BigInteger; +import java.util.Set; + +public class WalletUtil +{ + + // TODO check if that is correct and safe + public static int getConfirmationDepthInBlocks(Wallet wallet) + { + Transaction transaction = WalletUtil.getTransaction(wallet); + if (transaction != null && transaction.getConfidence() != null) + { + int appearedAtChainHeight = (transaction.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) ? transaction.getConfidence().getAppearedAtChainHeight() : 0; + return wallet.getLastBlockSeenHeight() - appearedAtChainHeight + 1; + } + else + { + return 0; + } + } + + // TODO check if that is correct and safe + public static Transaction getTransaction(Wallet wallet) + { + Set transactions = wallet.getTransactions(true); + if (transactions != null) + { + for (Transaction transaction : transactions) + { + if (transaction.getValueSentFromMe(wallet).compareTo(BigInteger.ZERO) == 0) + return transaction; + } + } + return null; + } +} diff --git a/src/main/java/io/bitsquare/gui/MainController.java b/src/main/java/io/bitsquare/gui/MainController.java index 077e88ddb5..7cf9ac8d63 100644 --- a/src/main/java/io/bitsquare/gui/MainController.java +++ b/src/main/java/io/bitsquare/gui/MainController.java @@ -46,18 +46,18 @@ public class MainController implements Initializable, NavigationController, Wall private ToggleGroup toggleGroup; private ToggleButton prevToggleButton; private Image prevToggleButtonIcon; - // public ProgressBar networkSyncProgressBar; - //public Label networkSyncInfoLabel; private Pane setupView; private SetupController setupController; + private NetworkSyncPane networkSyncPane; @FXML public Pane contentPane; + @FXML public HBox leftNavPane, rightNavPane; + @FXML public StackPane rootContainer; + @FXML public AnchorPane anchorPane; - private NetworkSyncPane networkSyncPane; - @Inject public MainController(Settings settings, User user, OrderBookFilter orderBookFilter, WalletFacade walletFacade) @@ -74,24 +74,20 @@ public class MainController implements Initializable, NavigationController, Wall networkSyncPane = new NetworkSyncPane(); networkSyncPane.setSpacing(10); networkSyncPane.setPrefHeight(20); - AnchorPane.setBottomAnchor(networkSyncPane, 0.0); - AnchorPane.setLeftAnchor(networkSyncPane, 0.0); walletFacade.addDownloadListener(this); walletFacade.initWallet(); - buildNavigation(); - if (user.getAccountID() != null) - { - anchorPane.getChildren().add(networkSyncPane); - } - else + if (user.getAccountID() == null) { buildSetupView(); anchorPane.setOpacity(0); setupController.setNetworkSyncPane(networkSyncPane); rootContainer.getChildren().add(setupView); } + + AnchorPane.setBottomAnchor(networkSyncPane, 0.0); + AnchorPane.setLeftAnchor(networkSyncPane, 0.0); } diff --git a/src/main/java/io/bitsquare/gui/MainView.fxml b/src/main/java/io/bitsquare/gui/MainView.fxml index 381167ba76..caa4b0afd8 100644 --- a/src/main/java/io/bitsquare/gui/MainView.fxml +++ b/src/main/java/io/bitsquare/gui/MainView.fxml @@ -7,7 +7,7 @@ - diff --git a/src/main/java/io/bitsquare/gui/setup/SetupController.java b/src/main/java/io/bitsquare/gui/setup/SetupController.java index 65ec1a7271..fc5cd27064 100644 --- a/src/main/java/io/bitsquare/gui/setup/SetupController.java +++ b/src/main/java/io/bitsquare/gui/setup/SetupController.java @@ -18,8 +18,6 @@ import io.bitsquare.gui.util.Formatter; import io.bitsquare.settings.Settings; import io.bitsquare.storage.Storage; import io.bitsquare.user.User; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.*; @@ -29,6 +27,7 @@ import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; +import javafx.util.StringConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,11 +46,11 @@ public class SetupController implements Initializable, ChildController, WalletFa private Storage storage; private List processStepItems = new ArrayList(); - private int depthInBlocks = 0; private NavigationController navigationController; private ImageView confirmIconImageView; - private TextField balanceLabel, confirmationsLabel; + private TextField balanceLabel, confirmationsLabel, accountHolderName, accountPrimaryID, accountSecondaryID; + private ComboBox countryComboBox, bankTransferTypeComboBox; @FXML private AnchorPane rootContainer; @@ -102,8 +101,6 @@ public class SetupController implements Initializable, ChildController, WalletFa @Override public void onConfidenceChanged(int numBroadcastPeers, int depthInBlocks) { - this.depthInBlocks = depthInBlocks; - updateCreateAccountButton(); confirmIconImageView.setImage(getConfirmIconImage(numBroadcastPeers, depthInBlocks)); confirmationsLabel.setText(getConfirmationsText(numBroadcastPeers, depthInBlocks)); @@ -145,6 +142,12 @@ public class SetupController implements Initializable, ChildController, WalletFa return Icons.getIconImage(Icons.getIconIDForPeersSeenTx(numBroadcastPeers)); } + private void updateCreateAccountButton() + { + boolean funded = walletFacade.getAccountRegistrationBalance().compareTo(BigInteger.ZERO) > 0; + nextButton.setDisable(!funded || walletFacade.getRegistrationConfirmationDepthInBlocks() == 0); + } + /////////////////////////////////////////////////////////////////////////////////// // GUI BUILDER @@ -202,9 +205,7 @@ public class SetupController implements Initializable, ChildController, WalletFa buildStep1(); }); - skipButton.setOnAction(e -> { - close(); - }); + skipButton.setOnAction(e -> close()); } private void buildStep1() @@ -215,45 +216,81 @@ public class SetupController implements Initializable, ChildController, WalletFa formGridPane.getChildren().clear(); int gridRow = -1; - ComboBox bankTransferTypes = FormBuilder.addComboBox(formGridPane, "Bank account type:", settings.getAllBankAccountTypes(), ++gridRow); - bankTransferTypes.setPromptText("Select"); - //TODO dev - bankTransferTypes.getSelectionModel().select(1); - TextField accountHolderName = FormBuilder.addInputField(formGridPane, "Bank account holder name:", "Bob Brown", ++gridRow); - TextField accountPrimaryID = FormBuilder.addInputField(formGridPane, "Bank account primary ID", "dummy IBAN", ++gridRow); - TextField accountSecondaryID = FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", "dummy BIC", ++gridRow); + bankTransferTypeComboBox = FormBuilder.addComboBox(formGridPane, "Bank account type:", settings.getAllBankAccountTypes(), ++gridRow); + bankTransferTypeComboBox.setPromptText("Select bank account type"); + accountHolderName = FormBuilder.addInputField(formGridPane, "Bank account holder name:", "", ++gridRow); + accountPrimaryID = FormBuilder.addInputField(formGridPane, "Bank account primary ID", "", ++gridRow); + accountSecondaryID = FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", "", ++gridRow); + + countryComboBox = FormBuilder.addComboBox(formGridPane, "Country:", settings.getAllLocales("displayCountry"), ++gridRow); + countryComboBox.setPromptText("Select country"); + countryComboBox.setConverter(new StringConverter() + { + @Override + public String toString(Object o) + { + return ((Locale) o).getDisplayCountry(); + } + + @Override + public Object fromString(String s) + { + return s; + } + }); + + Button addButton = new Button("Add other Bank account"); formGridPane.add(addButton, 1, ++gridRow); nextButton.setText("Create account"); - nextButton.setDisable(true); + checkCreateAccountButtonState(); skipButton.setText("Register later"); // handlers - bankTransferTypes.valueProperty().addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue ov, Object oldValue, Object newValue) - { - if (newValue != null && newValue instanceof BankAccountType) - { - BankAccountType bankAccountType = (BankAccountType) newValue; - accountPrimaryID.setText(""); - accountPrimaryID.setPromptText(bankAccountType.getPrimaryIDName()); - accountSecondaryID.setText(""); - accountSecondaryID.setPromptText(bankAccountType.getSecondaryIDName()); + accountHolderName.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); + accountPrimaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); + accountSecondaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); - nextButton.setDisable(false); + bankTransferTypeComboBox.valueProperty().addListener((ov, oldValue, newValue) -> { + if (newValue != null && newValue instanceof BankAccountType) + { + BankAccountType bankAccountType = (BankAccountType) newValue; + accountPrimaryID.setText(""); + accountPrimaryID.setPromptText(bankAccountType.getPrimaryIDName()); + accountSecondaryID.setText(""); + accountSecondaryID.setPromptText(bankAccountType.getSecondaryIDName()); + + checkCreateAccountButtonState(); + } + }); + + countryComboBox.valueProperty().addListener((ov, oldValue, newValue) -> { + if (newValue != null && newValue instanceof BankAccountType) + { + if (newValue != null) + { + checkCreateAccountButtonState(); } } }); addButton.setOnAction(e -> { - if (bankTransferTypes.getSelectionModel() != null && verifyBankAccountData(bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText())) + if (bankTransferTypeComboBox.getSelectionModel() != null + && verifyBankAccountData(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), + accountPrimaryID.getText(), + accountSecondaryID.getText(), + accountHolderName.getText())) { - user.addBankAccount(new BankAccount((BankAccountType) bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText())); + user.addBankAccount(new BankAccount( + (BankAccountType) bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), + accountPrimaryID.getText(), + accountSecondaryID.getText(), + accountHolderName.getText(), + (Locale) countryComboBox.getSelectionModel().getSelectedItem()) + ); - bankTransferTypes.getSelectionModel().clearSelection(); + bankTransferTypeComboBox.getSelectionModel().clearSelection(); accountPrimaryID.setText(""); accountPrimaryID.setPromptText(""); accountSecondaryID.setText(""); @@ -262,8 +299,21 @@ public class SetupController implements Initializable, ChildController, WalletFa }); nextButton.setOnAction(e -> { - if (bankTransferTypes.getSelectionModel() != null && verifyBankAccountData(bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText())) - user.addBankAccount(new BankAccount((BankAccountType) bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText())); + boolean inputValid = verifyBankAccountData(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), + accountPrimaryID.getText(), + accountSecondaryID.getText(), + accountHolderName.getText()); + + + if (bankTransferTypeComboBox.getSelectionModel() != null && countryComboBox.getSelectionModel() != null && inputValid) + { + BankAccount bankAccount = new BankAccount((BankAccountType) bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), + accountPrimaryID.getText(), + accountSecondaryID.getText(), + accountHolderName.getText(), + (Locale) countryComboBox.getSelectionModel().getSelectedItem()); + user.addBankAccount(bankAccount); + } if (user.getBankAccounts().size() > 0) { @@ -280,7 +330,6 @@ public class SetupController implements Initializable, ChildController, WalletFa } catch (InsufficientMoneyException e1) { log.warn(e1.toString()); - //e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } else @@ -290,9 +339,19 @@ public class SetupController implements Initializable, ChildController, WalletFa } }); - skipButton.setOnAction(e -> { - close(); - }); + skipButton.setOnAction(e -> close()); + } + + private void checkCreateAccountButtonState() + { + boolean enabled = accountHolderName.getText().length() > 0 + && accountPrimaryID.getText().length() > 0 + && accountSecondaryID.getText().length() > 0 + && bankTransferTypeComboBox.getSelectionModel() != null + && bankTransferTypeComboBox.getSelectionModel().getSelectedItem() != null + && countryComboBox.getSelectionModel() != null + && countryComboBox.getSelectionModel().getSelectedItem() != null; + nextButton.setDisable(!enabled); } private void buildStep2() @@ -322,9 +381,7 @@ public class SetupController implements Initializable, ChildController, WalletFa skipButton.setOpacity(0); // handlers - nextButton.setOnAction(e -> { - close(); - }); + nextButton.setOnAction(e -> close()); } // util @@ -336,11 +393,5 @@ public class SetupController implements Initializable, ChildController, WalletFa FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", bankAccount.getAccountSecondaryID(), ++row).setMouseTransparent(true); return row; } - - private void updateCreateAccountButton() - { - boolean funded = walletFacade.getAccountRegistrationBalance().compareTo(BigInteger.ZERO) > 0; - nextButton.setDisable(!funded || depthInBlocks == 0); - } } diff --git a/src/main/java/io/bitsquare/settings/Settings.java b/src/main/java/io/bitsquare/settings/Settings.java index 9270f21723..a5f72e42c3 100644 --- a/src/main/java/io/bitsquare/settings/Settings.java +++ b/src/main/java/io/bitsquare/settings/Settings.java @@ -5,9 +5,8 @@ import io.bitsquare.bank.BankAccountType; import io.bitsquare.storage.Storage; import io.bitsquare.trade.orderbook.OrderBookFilter; -import java.util.ArrayList; -import java.util.Currency; -import java.util.Locale; +import java.util.*; +import java.util.function.Predicate; public class Settings { @@ -98,16 +97,37 @@ public class Settings bankTransferTypes.add("AT"); return bankTransferTypes; } - /* - public ArrayList getAllCountries() + + public ArrayList getAllLocales(String sortField) { - ArrayList result = new ArrayList<>(); - for (Locale locale : Locale.getAvailableLocales()) + ArrayList list = new ArrayList(Arrays.asList(Locale.getAvailableLocales())); + + list.removeIf(new Predicate() { - result.add(locale.getDisplayCountry()); - } - return result; - } */ + @Override + public boolean test(Locale locale) + { + return locale == null || locale.getCountry().equals("") || locale.getLanguage().equals(""); + } + }); + + list.sort(new Comparator() + { + @Override + public int compare(Object o1, Object o2) + { + if (sortField.equals("displayCountry")) + return (((Locale) o1).getDisplayCountry()).compareTo(((Locale) o2).getDisplayCountry()); + else + return 1; + } + }); + Locale defaultLocale = Locale.getDefault(); + list.remove(defaultLocale); + list.add(0, defaultLocale); + + return list; + } /*public ArrayList getAllLanguages() { diff --git a/src/main/java/io/bitsquare/user/User.java b/src/main/java/io/bitsquare/user/User.java index 87f1c5dbc5..703b029e4b 100644 --- a/src/main/java/io/bitsquare/user/User.java +++ b/src/main/java/io/bitsquare/user/User.java @@ -41,8 +41,8 @@ public class User implements Serializable String bankAccountUIDs = ""; for (Iterator> iterator = getBankAccounts().entrySet().iterator(); iterator.hasNext(); ) { - Map.Entry entry = iterator.next(); - bankAccountUIDs += entry.getValue().toString(); + Map.Entry entry = iterator.next(); + bankAccountUIDs += entry.getValue().getStringifiedBankAccount(); if (iterator.hasNext()) bankAccountUIDs += ", "; diff --git a/src/main/resources/bitsquare.properties b/src/main/resources/bitsquare.properties index e69de29bb2..ea1dd6cc6b 100644 --- a/src/main/resources/bitsquare.properties +++ b/src/main/resources/bitsquare.properties @@ -0,0 +1 @@ +com.google.bitcoin = FATAL \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000000..bece05369f --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,27 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n + + + + + + + + + + + + + + + + + +