mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-07 22:52:40 -04:00
fix confirmations, add logback, ui stuff, add country(local) to bankaccount
This commit is contained in:
parent
6509441e8c
commit
8856e31d78
13 changed files with 303 additions and 117 deletions
44
pom.xml
44
pom.xml
|
@ -7,7 +7,6 @@
|
||||||
<groupId>io.bitsquare</groupId>
|
<groupId>io.bitsquare</groupId>
|
||||||
<artifactId>bitsquare</artifactId>
|
<artifactId>bitsquare</artifactId>
|
||||||
<version>0.01-SNAPSHOT</version>
|
<version>0.01-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>BitSquare</name>
|
<name>BitSquare</name>
|
||||||
<description>A P2P Fiat-Bitcoin Exchange</description>
|
<description>A P2P Fiat-Bitcoin Exchange</description>
|
||||||
<url>https://www.bitsquare.io</url>
|
<url>https://www.bitsquare.io</url>
|
||||||
|
@ -21,13 +20,19 @@
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>Apache 2</name>
|
<name>GNU AFFERO GENERAL PUBLIC LICENSE</name>
|
||||||
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
<url>http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
|
<issueManagement>
|
||||||
|
<system>GitHub</system>
|
||||||
|
<url>https://github.com/bitsquare/bitsquare/issues</url>
|
||||||
|
</issueManagement>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
<!-- Public read-only source -->
|
||||||
<url>https://github.com/bitsquare/bitsquare</url>
|
<url>https://github.com/bitsquare/bitsquare</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
@ -56,13 +61,21 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
<!-- TODO Maven build not working yet... -->
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>bitsquare</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/java</directory>
|
<directory>src/main/java</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.fxml</include>
|
||||||
|
<include>**/*.css</include>
|
||||||
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -78,6 +91,7 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -92,17 +106,24 @@
|
||||||
<version>4.11</version>
|
<version>4.11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>1.0.9</version>
|
<version>1.1.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -151,6 +172,17 @@
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<!-- Generate cross-referenced HTML source code listing -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jxr-plugin</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class BitSquare extends Application
|
||||||
@Override
|
@Override
|
||||||
public void stop() throws Exception
|
public void stop() throws Exception
|
||||||
{
|
{
|
||||||
walletFacade.terminateWallet();
|
walletFacade.shutDown();
|
||||||
|
|
||||||
super.stop();
|
super.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
package io.bitsquare.bank;
|
package io.bitsquare.bank;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class BankAccount implements Serializable
|
public class BankAccount implements Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1792577576443221268L;
|
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;
|
private String uid;
|
||||||
|
|
||||||
// TODO just for mock yet
|
// TODO just for mock yet
|
||||||
|
@ -19,14 +23,15 @@ public class BankAccount implements Serializable
|
||||||
this.bankAccountType = bankAccountType;
|
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.bankAccountType = bankAccountType;
|
||||||
this.accountPrimaryID = accountPrimaryID;
|
this.accountPrimaryID = accountPrimaryID;
|
||||||
this.accountSecondaryID = accountSecondaryID;
|
this.accountSecondaryID = accountSecondaryID;
|
||||||
this.accountHolderName = accountHolderName;
|
this.accountHolderName = accountHolderName;
|
||||||
|
this.locale = locale;
|
||||||
|
|
||||||
uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName;
|
uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName + "_" + locale.getISO3Country();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccountPrimaryID()
|
public String getAccountPrimaryID()
|
||||||
|
@ -54,14 +59,16 @@ public class BankAccount implements Serializable
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// Changes of that structure must be reflected in VERSION updates
|
||||||
public String toString()
|
public String getStringifiedBankAccount()
|
||||||
{
|
{
|
||||||
return "BankAccount{" +
|
return "{" +
|
||||||
"bankAccountType=" + bankAccountType +
|
"type=" + bankAccountType +
|
||||||
", accountPrimaryID='" + accountPrimaryID + '\'' +
|
", primaryID='" + accountPrimaryID + '\'' +
|
||||||
", accountSecondaryID='" + accountSecondaryID + '\'' +
|
", secondaryID='" + accountSecondaryID + '\'' +
|
||||||
", accountHolderName='" + accountHolderName + '\'' +
|
", holderName='" + accountHolderName + '\'' +
|
||||||
|
", country='" + locale.getISO3Country() + '\'' +
|
||||||
|
", v='" + VERSION + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN;
|
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
|
public class AccountRegistrationWallet extends Wallet implements WalletEventListener
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(AccountRegistrationWallet.class);
|
private static final Logger log = LoggerFactory.getLogger(AccountRegistrationWallet.class);
|
||||||
|
private final File walletFile;
|
||||||
|
|
||||||
private NetworkParameters networkParameters;
|
private NetworkParameters networkParameters;
|
||||||
|
private BlockChain chain;
|
||||||
|
private PeerGroup peerGroup;
|
||||||
private List<WalletFacade.WalletListener> walletListeners = new ArrayList<>();
|
private List<WalletFacade.WalletListener> walletListeners = new ArrayList<>();
|
||||||
|
|
||||||
AccountRegistrationWallet(NetworkParameters networkParameters, BlockChain chain, PeerGroup peerGroup)
|
AccountRegistrationWallet(NetworkParameters networkParameters, BlockChain chain, PeerGroup peerGroup)
|
||||||
|
@ -34,8 +36,10 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList
|
||||||
super(networkParameters);
|
super(networkParameters);
|
||||||
|
|
||||||
this.networkParameters = 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())
|
if (walletFile.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -60,9 +64,27 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList
|
||||||
|
|
||||||
chain.addWallet(this);
|
chain.addWallet(this);
|
||||||
peerGroup.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);
|
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()
|
Address getAddress()
|
||||||
{
|
{
|
||||||
return getKey().toAddress(networkParameters);
|
return getKey().toAddress(networkParameters);
|
||||||
|
@ -148,7 +170,7 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList
|
||||||
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||||
{
|
{
|
||||||
for (WalletFacade.WalletListener walletListener : walletListeners)
|
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());
|
log.info("onTransactionConfidenceChanged " + tx.getConfidence().toString());
|
||||||
}
|
}
|
||||||
|
@ -185,24 +207,8 @@ public class AccountRegistrationWallet extends Wallet implements WalletEventList
|
||||||
|
|
||||||
int getConfirmationNumBroadcastPeers()
|
int getConfirmationNumBroadcastPeers()
|
||||||
{
|
{
|
||||||
Transaction transaction = getTransaction();
|
Transaction transaction = WalletUtil.getTransaction(this);
|
||||||
return (transaction == null || transaction.getConfidence() == null) ? 0 : transaction.getConfidence().numBroadcastPeers();
|
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<Transaction> transactions = getTransactions(true);
|
|
||||||
if (transactions != null && transactions.size() == 1)
|
|
||||||
{
|
|
||||||
return transactions.iterator().next();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,10 @@ public class WalletFacade implements WalletEventListener
|
||||||
log.info(walletAppKit.wallet().toString());
|
log.info(walletAppKit.wallet().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terminateWallet()
|
public void shutDown()
|
||||||
{
|
{
|
||||||
|
if (accountRegistrationWallet != null)
|
||||||
|
accountRegistrationWallet.shutDown();
|
||||||
walletAppKit.stopAsync();
|
walletAppKit.stopAsync();
|
||||||
walletAppKit.awaitTerminated();
|
walletAppKit.awaitTerminated();
|
||||||
}
|
}
|
||||||
|
@ -176,7 +178,7 @@ public class WalletFacade implements WalletEventListener
|
||||||
|
|
||||||
public int getRegistrationConfirmationDepthInBlocks()
|
public int getRegistrationConfirmationDepthInBlocks()
|
||||||
{
|
{
|
||||||
return getAccountRegistrationWallet().getConfirmationDepthInBlocks();
|
return WalletUtil.getConfirmationDepthInBlocks(getAccountRegistrationWallet());
|
||||||
}
|
}
|
||||||
|
|
||||||
// WalletEventListener
|
// WalletEventListener
|
||||||
|
@ -193,7 +195,7 @@ public class WalletFacade implements WalletEventListener
|
||||||
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||||
{
|
{
|
||||||
for (WalletListener walletListener : walletListeners)
|
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());
|
log.info("onTransactionConfidenceChanged " + tx.getConfidence().toString());
|
||||||
}
|
}
|
||||||
|
@ -271,4 +273,6 @@ public class WalletFacade implements WalletEventListener
|
||||||
|
|
||||||
void onCoinsReceived(BigInteger newBalance);
|
void onCoinsReceived(BigInteger newBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
42
src/main/java/io/bitsquare/btc/WalletUtil.java
Normal file
42
src/main/java/io/bitsquare/btc/WalletUtil.java
Normal file
|
@ -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<Transaction> transactions = wallet.getTransactions(true);
|
||||||
|
if (transactions != null)
|
||||||
|
{
|
||||||
|
for (Transaction transaction : transactions)
|
||||||
|
{
|
||||||
|
if (transaction.getValueSentFromMe(wallet).compareTo(BigInteger.ZERO) == 0)
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,18 +46,18 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
private ToggleGroup toggleGroup;
|
private ToggleGroup toggleGroup;
|
||||||
private ToggleButton prevToggleButton;
|
private ToggleButton prevToggleButton;
|
||||||
private Image prevToggleButtonIcon;
|
private Image prevToggleButtonIcon;
|
||||||
// public ProgressBar networkSyncProgressBar;
|
|
||||||
//public Label networkSyncInfoLabel;
|
|
||||||
private Pane setupView;
|
private Pane setupView;
|
||||||
private SetupController setupController;
|
private SetupController setupController;
|
||||||
|
private NetworkSyncPane networkSyncPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public Pane contentPane;
|
public Pane contentPane;
|
||||||
|
@FXML
|
||||||
public HBox leftNavPane, rightNavPane;
|
public HBox leftNavPane, rightNavPane;
|
||||||
|
@FXML
|
||||||
public StackPane rootContainer;
|
public StackPane rootContainer;
|
||||||
|
@FXML
|
||||||
public AnchorPane anchorPane;
|
public AnchorPane anchorPane;
|
||||||
private NetworkSyncPane networkSyncPane;
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MainController(Settings settings, User user, OrderBookFilter orderBookFilter, WalletFacade walletFacade)
|
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 = new NetworkSyncPane();
|
||||||
networkSyncPane.setSpacing(10);
|
networkSyncPane.setSpacing(10);
|
||||||
networkSyncPane.setPrefHeight(20);
|
networkSyncPane.setPrefHeight(20);
|
||||||
AnchorPane.setBottomAnchor(networkSyncPane, 0.0);
|
|
||||||
AnchorPane.setLeftAnchor(networkSyncPane, 0.0);
|
|
||||||
|
|
||||||
walletFacade.addDownloadListener(this);
|
walletFacade.addDownloadListener(this);
|
||||||
walletFacade.initWallet();
|
walletFacade.initWallet();
|
||||||
|
|
||||||
buildNavigation();
|
buildNavigation();
|
||||||
if (user.getAccountID() != null)
|
if (user.getAccountID() == null)
|
||||||
{
|
|
||||||
anchorPane.getChildren().add(networkSyncPane);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
buildSetupView();
|
buildSetupView();
|
||||||
anchorPane.setOpacity(0);
|
anchorPane.setOpacity(0);
|
||||||
setupController.setNetworkSyncPane(networkSyncPane);
|
setupController.setNetworkSyncPane(networkSyncPane);
|
||||||
rootContainer.getChildren().add(setupView);
|
rootContainer.getChildren().add(setupView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnchorPane.setBottomAnchor(networkSyncPane, 0.0);
|
||||||
|
AnchorPane.setLeftAnchor(networkSyncPane, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<AnchorPane fx:id="anchorPane" id="root-pane" minHeight="300" minWidth="400" prefHeight="600" prefWidth="800">
|
<AnchorPane fx:id="anchorPane" id="root-pane" minHeight="300" minWidth="400" prefHeight="600" prefWidth="800">
|
||||||
<HBox fx:id="leftNavPane" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
|
<HBox fx:id="leftNavPane" spacing="10" AnchorPane.leftAnchor="0" AnchorPane.topAnchor="0"/>
|
||||||
<HBox fx:id="rightNavPane" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/>
|
<HBox fx:id="rightNavPane" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="0"/>
|
||||||
<AnchorPane id="content-pane" fx:id="contentPane" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0"
|
<AnchorPane fx:id="contentPane" id="content-pane" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0"
|
||||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/>
|
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</StackPane>
|
</StackPane>
|
||||||
|
|
|
@ -18,8 +18,6 @@ import io.bitsquare.gui.util.Formatter;
|
||||||
import io.bitsquare.settings.Settings;
|
import io.bitsquare.settings.Settings;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
@ -29,6 +27,7 @@ import javafx.scene.input.Clipboard;
|
||||||
import javafx.scene.input.ClipboardContent;
|
import javafx.scene.input.ClipboardContent;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -47,11 +46,11 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
|
|
||||||
private List<ProcessStepItem> processStepItems = new ArrayList();
|
private List<ProcessStepItem> processStepItems = new ArrayList();
|
||||||
private int depthInBlocks = 0;
|
|
||||||
|
|
||||||
private NavigationController navigationController;
|
private NavigationController navigationController;
|
||||||
private ImageView confirmIconImageView;
|
private ImageView confirmIconImageView;
|
||||||
private TextField balanceLabel, confirmationsLabel;
|
private TextField balanceLabel, confirmationsLabel, accountHolderName, accountPrimaryID, accountSecondaryID;
|
||||||
|
private ComboBox countryComboBox, bankTransferTypeComboBox;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane rootContainer;
|
private AnchorPane rootContainer;
|
||||||
|
@ -102,8 +101,6 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
@Override
|
@Override
|
||||||
public void onConfidenceChanged(int numBroadcastPeers, int depthInBlocks)
|
public void onConfidenceChanged(int numBroadcastPeers, int depthInBlocks)
|
||||||
{
|
{
|
||||||
this.depthInBlocks = depthInBlocks;
|
|
||||||
|
|
||||||
updateCreateAccountButton();
|
updateCreateAccountButton();
|
||||||
confirmIconImageView.setImage(getConfirmIconImage(numBroadcastPeers, depthInBlocks));
|
confirmIconImageView.setImage(getConfirmIconImage(numBroadcastPeers, depthInBlocks));
|
||||||
confirmationsLabel.setText(getConfirmationsText(numBroadcastPeers, depthInBlocks));
|
confirmationsLabel.setText(getConfirmationsText(numBroadcastPeers, depthInBlocks));
|
||||||
|
@ -145,6 +142,12 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
return Icons.getIconImage(Icons.getIconIDForPeersSeenTx(numBroadcastPeers));
|
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
|
// GUI BUILDER
|
||||||
|
@ -202,9 +205,7 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
buildStep1();
|
buildStep1();
|
||||||
});
|
});
|
||||||
|
|
||||||
skipButton.setOnAction(e -> {
|
skipButton.setOnAction(e -> close());
|
||||||
close();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildStep1()
|
private void buildStep1()
|
||||||
|
@ -215,26 +216,43 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
|
|
||||||
formGridPane.getChildren().clear();
|
formGridPane.getChildren().clear();
|
||||||
int gridRow = -1;
|
int gridRow = -1;
|
||||||
ComboBox bankTransferTypes = FormBuilder.addComboBox(formGridPane, "Bank account type:", settings.getAllBankAccountTypes(), ++gridRow);
|
bankTransferTypeComboBox = FormBuilder.addComboBox(formGridPane, "Bank account type:", settings.getAllBankAccountTypes(), ++gridRow);
|
||||||
bankTransferTypes.setPromptText("Select");
|
bankTransferTypeComboBox.setPromptText("Select bank account type");
|
||||||
//TODO dev
|
accountHolderName = FormBuilder.addInputField(formGridPane, "Bank account holder name:", "", ++gridRow);
|
||||||
bankTransferTypes.getSelectionModel().select(1);
|
accountPrimaryID = FormBuilder.addInputField(formGridPane, "Bank account primary ID", "", ++gridRow);
|
||||||
TextField accountHolderName = FormBuilder.addInputField(formGridPane, "Bank account holder name:", "Bob Brown", ++gridRow);
|
accountSecondaryID = FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", "", ++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);
|
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");
|
Button addButton = new Button("Add other Bank account");
|
||||||
formGridPane.add(addButton, 1, ++gridRow);
|
formGridPane.add(addButton, 1, ++gridRow);
|
||||||
|
|
||||||
nextButton.setText("Create account");
|
nextButton.setText("Create account");
|
||||||
nextButton.setDisable(true);
|
checkCreateAccountButtonState();
|
||||||
skipButton.setText("Register later");
|
skipButton.setText("Register later");
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
bankTransferTypes.valueProperty().addListener(new ChangeListener<Object>()
|
accountHolderName.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
|
||||||
{
|
accountPrimaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
|
||||||
@Override
|
accountSecondaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
|
||||||
public void changed(ObservableValue ov, Object oldValue, Object newValue)
|
|
||||||
{
|
bankTransferTypeComboBox.valueProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null && newValue instanceof BankAccountType)
|
if (newValue != null && newValue instanceof BankAccountType)
|
||||||
{
|
{
|
||||||
BankAccountType bankAccountType = (BankAccountType) newValue;
|
BankAccountType bankAccountType = (BankAccountType) newValue;
|
||||||
|
@ -243,17 +261,36 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
accountSecondaryID.setText("");
|
accountSecondaryID.setText("");
|
||||||
accountSecondaryID.setPromptText(bankAccountType.getSecondaryIDName());
|
accountSecondaryID.setPromptText(bankAccountType.getSecondaryIDName());
|
||||||
|
|
||||||
nextButton.setDisable(false);
|
checkCreateAccountButtonState();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
countryComboBox.valueProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
|
if (newValue != null && newValue instanceof BankAccountType)
|
||||||
|
{
|
||||||
|
if (newValue != null)
|
||||||
|
{
|
||||||
|
checkCreateAccountButtonState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton.setOnAction(e -> {
|
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.setText("");
|
||||||
accountPrimaryID.setPromptText("");
|
accountPrimaryID.setPromptText("");
|
||||||
accountSecondaryID.setText("");
|
accountSecondaryID.setText("");
|
||||||
|
@ -262,8 +299,21 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
});
|
});
|
||||||
|
|
||||||
nextButton.setOnAction(e -> {
|
nextButton.setOnAction(e -> {
|
||||||
if (bankTransferTypes.getSelectionModel() != null && verifyBankAccountData(bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText()))
|
boolean inputValid = verifyBankAccountData(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(),
|
||||||
user.addBankAccount(new BankAccount((BankAccountType) bankTransferTypes.getSelectionModel().getSelectedItem(), accountPrimaryID.getText(), accountSecondaryID.getText(), accountHolderName.getText()));
|
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)
|
if (user.getBankAccounts().size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -280,7 +330,6 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
} catch (InsufficientMoneyException e1)
|
} catch (InsufficientMoneyException e1)
|
||||||
{
|
{
|
||||||
log.warn(e1.toString());
|
log.warn(e1.toString());
|
||||||
//e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -290,9 +339,19 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
skipButton.setOnAction(e -> {
|
skipButton.setOnAction(e -> close());
|
||||||
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()
|
private void buildStep2()
|
||||||
|
@ -322,9 +381,7 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
skipButton.setOpacity(0);
|
skipButton.setOpacity(0);
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
nextButton.setOnAction(e -> {
|
nextButton.setOnAction(e -> close());
|
||||||
close();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// util
|
// util
|
||||||
|
@ -336,11 +393,5 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", bankAccount.getAccountSecondaryID(), ++row).setMouseTransparent(true);
|
FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", bankAccount.getAccountSecondaryID(), ++row).setMouseTransparent(true);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCreateAccountButton()
|
|
||||||
{
|
|
||||||
boolean funded = walletFacade.getAccountRegistrationBalance().compareTo(BigInteger.ZERO) > 0;
|
|
||||||
nextButton.setDisable(!funded || depthInBlocks == 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,8 @@ import io.bitsquare.bank.BankAccountType;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Currency;
|
import java.util.function.Predicate;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
|
@ -98,16 +97,37 @@ public class Settings
|
||||||
bankTransferTypes.add("AT");
|
bankTransferTypes.add("AT");
|
||||||
return bankTransferTypes;
|
return bankTransferTypes;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public ArrayList<String> getAllCountries()
|
public ArrayList<Locale> getAllLocales(String sortField)
|
||||||
{
|
{
|
||||||
ArrayList<String> result = new ArrayList<>();
|
ArrayList<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales()));
|
||||||
for (Locale locale : Locale.getAvailableLocales())
|
|
||||||
|
list.removeIf(new Predicate<Locale>()
|
||||||
{
|
{
|
||||||
result.add(locale.getDisplayCountry());
|
@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;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
} */
|
|
||||||
|
|
||||||
/*public ArrayList<String> getAllLanguages()
|
/*public ArrayList<String> getAllLanguages()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class User implements Serializable
|
||||||
String bankAccountUIDs = "";
|
String bankAccountUIDs = "";
|
||||||
for (Iterator<Map.Entry<String, BankAccount>> iterator = getBankAccounts().entrySet().iterator(); iterator.hasNext(); )
|
for (Iterator<Map.Entry<String, BankAccount>> iterator = getBankAccounts().entrySet().iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
Map.Entry entry = iterator.next();
|
Map.Entry<String, BankAccount> entry = iterator.next();
|
||||||
bankAccountUIDs += entry.getValue().toString();
|
bankAccountUIDs += entry.getValue().getStringifiedBankAccount();
|
||||||
|
|
||||||
if (iterator.hasNext())
|
if (iterator.hasNext())
|
||||||
bankAccountUIDs += ", ";
|
bankAccountUIDs += ", ";
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
com.google.bitcoin = FATAL
|
27
src/main/resources/logback.xml
Normal file
27
src/main/resources/logback.xml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<!--
|
||||||
|
-->
|
||||||
|
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="DEBUG">
|
||||||
|
<appender-ref ref="CONSOLE_APPENDER"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<logger name="io.bitsquare" level="DEBUG"/>
|
||||||
|
|
||||||
|
<logger name="com.google.bitcoin" level="WARN"/>
|
||||||
|
|
||||||
|
<logger name="com.google.bitcoin.core.PeerGroup" level="ERROR" additivity="false"/>
|
||||||
|
<logger name="com.google.bitcoin.net.NioClientManager" level="ERROR" additivity="false"/>
|
||||||
|
<logger name="com.google.bitcoin.net.ConnectionHandler" level="ERROR" additivity="false"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
-->
|
||||||
|
|
||||||
|
</configuration>
|
Loading…
Add table
Add a link
Reference in a new issue