update listeners

This commit is contained in:
Manfred Karrer 2014-06-18 23:59:13 +02:00
parent a03c24d664
commit 70522383c6
47 changed files with 405 additions and 1231 deletions

View file

@ -5,15 +5,11 @@ import com.google.inject.Injector;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.BitSquareModule;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
@ -21,11 +17,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class BitSquare extends Application
{
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
@ -60,10 +51,6 @@ public class BitSquare extends Application
final Storage storage = injector.getInstance(Storage.class);
user.updateFromStorage((User) storage.read(user.getClass().getName()));
// mock
//initSettings(settings, storage, user);
settings.updateFromStorage((Settings) storage.read(settings.getClass().getName()));
if (ID.length() > 0)
@ -89,46 +76,6 @@ public class BitSquare extends Application
stage.show();
log.debug("Startup: stage displayed");
addMockArbitrator();
}
private void addMockArbitrator()
{
String pubKeyAsHex = walletFacade.getArbitratorPubKeyAsHex();
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey());
List<Locale> languages = new ArrayList<>();
languages.add(LanguageUtil.getDefaultLanguageLocale());
List<Arbitrator.METHODS> arbitrationMethods = new ArrayList<>();
arbitrationMethods.add(Arbitrator.METHODS.TLS_NOTARY);
List<Arbitrator.ID_VERIFICATIONS> idVerifications = new ArrayList<>();
idVerifications.add(Arbitrator.ID_VERIFICATIONS.PASSPORT);
idVerifications.add(Arbitrator.ID_VERIFICATIONS.GOV_ID);
Arbitrator arbitrator = new Arbitrator(pubKeyAsHex,
messagePubKeyAsHex,
"Manfred Karrer",
Arbitrator.ID_TYPE.REAL_LIFE_ID,
languages,
new Reputation(),
1,
0.01,
0.001,
10,
0.1,
arbitrationMethods,
idVerifications,
"http://bitsquare.io/",
"Bla bla..."
);
try
{
messageFacade.addArbitrator(arbitrator);
} catch (IOException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
@Override
@ -144,88 +91,4 @@ public class BitSquare extends Application
{
return stage;
}
/* private void initSettings(Settings settings, Storage storage, User user)
{
Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
if (savedSettings == null)
{
// write default settings
settings.getAcceptedCountries().clear();
// settings.addAcceptedLanguageLocale(Locale.getDefault());
settings.addAcceptedLanguageLocale(MockData.getLocales().get(0));
settings.addAcceptedLanguageLocale(new Locale("en", "US"));
settings.addAcceptedLanguageLocale(new Locale("es", "ES"));
settings.getAcceptedCountries().clear();
//settings.addAcceptedCountry(Locale.getDefault());
settings.addAcceptedCountry(MockData.getLocales().get(0));
settings.addAcceptedCountry(new Locale("en", "US"));
settings.addAcceptedCountry(new Locale("de", "DE"));
settings.addAcceptedCountry(new Locale("es", "ES"));
settings.getAcceptedArbitrators().clear();
settings.addAcceptedArbitrator(new Arbitrator("uid_1", "Charlie Boom", Utils.bytesToHexString(new ECKey().getPubKey()),
getMessagePubKey(), "http://www.arbit.io/Charly_Boom", 10, 50, Utils.toNanoCoins("0.01")));
settings.addAcceptedArbitrator(new Arbitrator("uid_2", "Tom Shang", Utils.bytesToHexString(new ECKey().getPubKey()),
getMessagePubKey(), "http://www.arbit.io/Tom_Shang", 10, 100, Utils.toNanoCoins("0.001")));
settings.addAcceptedArbitrator(new Arbitrator("uid_3", "Edward Snow", Utils.bytesToHexString(new ECKey().getPubKey()),
getMessagePubKey(), "http://www.arbit.io/Edward_Swow", 20, 50, Utils.toNanoCoins("0.05")));
settings.addAcceptedArbitrator(new Arbitrator("uid_4", "Julian Sander", Utils.bytesToHexString(new ECKey().getPubKey()),
getMessagePubKey(), "http://www.arbit.io/Julian_Sander", 10, 20, Utils.toNanoCoins("0.1")));
settings.setMinCollateral(1);
settings.setMaxCollateral(10);
storage.write(settings.getClass().getName(), settings);
//initMockUser(storage, user);
}
} */
/* private String getMessagePubKey()
{
try
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
keyGen.initialize(1024);
KeyPair generatedKeyPair = keyGen.genKeyPair();
PublicKey pubKey = generatedKeyPair.getPublic();
return DSAKeyUtil.getHexStringFromPublicKey(pubKey);
} catch (Exception e2)
{
return null;
}
} */
/* private void initMockUser(Storage storage, User user)
{
user.getBankAccounts().clear();
BankAccount bankAccount1 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.SEPA, "Iban", "Bic"),
MockData.getCurrencies().get(0),
MockData.getLocales().get(0),
"Main EUR account",
"Manfred Karrer",
"564613242346",
"23432432434"
);
user.addBankAccount(bankAccount1);
BankAccount bankAccount2 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.INTERNATIONAL, "Number", "ID"),
MockData.getCurrencies().get(1),
MockData.getLocales().get(2),
"US account",
"Manfred Karrer",
"22312123123123123",
"asdasdasdas"
);
user.addBankAccount(bankAccount2);
user.setAccountID(Utils.bytesToHexString(new ECKey().getPubKey()));
storage.write(user.getClass().getName(), user);
} */
}

View file

@ -4,6 +4,9 @@ import net.tomp2p.p2p.Peer;
import net.tomp2p.p2p.PeerMaker;
import net.tomp2p.peers.Number160;
/**
* Network node for relaying p2p msg
*/
public class RelayNode
{
private static Peer masterPeer = null;

View file

@ -8,7 +8,6 @@ import java.util.Objects;
public class BankAccount implements Serializable
{
private static final long serialVersionUID = 1792577576443221268L;
private BankAccountTypeInfo bankAccountTypeInfo;
@ -18,8 +17,6 @@ public class BankAccount implements Serializable
private Country country;
private Currency currency;
private String uid;
private String accountTitle;
public BankAccount(BankAccountTypeInfo bankAccountTypeInfo,

View file

@ -6,7 +6,6 @@ import java.util.Objects;
public class BankAccountTypeInfo implements Serializable
{
private static final long serialVersionUID = -8772708150197835288L;
public static enum BankAccountType

View file

@ -0,0 +1,57 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.Utils;
import java.beans.Transient;
import java.io.Serializable;
public class AddressInfo implements Serializable
{
private static final long serialVersionUID = 5501603992599920416L;
private ECKey key;
private NetworkParameters params;
private String label;
public AddressInfo(ECKey key, NetworkParameters params, String label)
{
this.key = key;
this.params = params;
this.label = label;
}
public void setLabel(String label)
{
this.label = label;
}
public String getLabel()
{
return label;
}
public String getAddressString()
{
return getAddress().toString();
}
public String getPubKeyAsHexString()
{
return Utils.bytesToHexString(key.getPubKey());
}
@Transient
public ECKey getKey()
{
return key;
}
@Transient
public Address getAddress()
{
return key.toAddress(params);
}
}

View file

@ -1,27 +0,0 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.Address;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
public class BalanceListener
{
private static final Logger log = LoggerFactory.getLogger(BalanceListener.class);
private Address address;
public BalanceListener(Address address)
{
this.address = address;
}
public Address getAddress()
{
return address;
}
public void onBalanceChanged(BigInteger balance)
{
}
}

View file

@ -0,0 +1,150 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.*;
import com.google.bitcoin.kits.WalletAppKit;
import com.google.bitcoin.net.discovery.DnsDiscovery;
import com.google.bitcoin.store.BlockStoreException;
import com.google.bitcoin.store.SPVBlockStore;
import com.google.bitcoin.store.WalletProtobufSerializer;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class BitSquareWalletAppKit extends WalletAppKit
{
public BitSquareWalletAppKit(NetworkParameters params, File directory, String filePrefix)
{
super(params, directory, filePrefix);
}
@Override
protected void startUp() throws Exception
{
// Runs in a separate thread.
if (!directory.exists())
{
if (!directory.mkdir())
{
throw new IOException("Could not create named directory.");
}
}
FileInputStream walletStream = null;
try
{
File chainFile = new File(directory, filePrefix + ".spvchain");
boolean chainFileExists = chainFile.exists();
vWalletFile = new File(directory, filePrefix + ".wallet");
boolean shouldReplayWallet = vWalletFile.exists() && !chainFileExists;
vStore = new SPVBlockStore(params, chainFile);
if (!chainFileExists && checkpoints != null)
{
// Ugly hack! We have to create the wallet once here to learn the earliest key time, and then throw it
// away. The reason is that wallet extensions might need access to peergroups/chains/etc so we have to
// create the wallet later, but we need to know the time early here before we create the BlockChain
// object.
long time = Long.MAX_VALUE;
if (vWalletFile.exists())
{
Wallet wallet = new BitSquareWallet(params);
FileInputStream stream = new FileInputStream(vWalletFile);
new WalletProtobufSerializer().readWallet(WalletProtobufSerializer.parseToProto(stream), wallet);
time = wallet.getEarliestKeyCreationTime();
}
CheckpointManager.checkpoint(params, checkpoints, vStore, time);
}
vChain = new BlockChain(params, vStore);
vPeerGroup = createPeerGroup();
if (this.userAgent != null)
vPeerGroup.setUserAgent(userAgent, version);
if (vWalletFile.exists())
{
walletStream = new FileInputStream(vWalletFile);
vWallet = new BitSquareWallet(params);
addWalletExtensions(); // All extensions must be present before we deserialize
new WalletProtobufSerializer().readWallet(WalletProtobufSerializer.parseToProto(walletStream), vWallet);
if (shouldReplayWallet)
vWallet.clearTransactions(0);
}
else
{
vWallet = new BitSquareWallet(params);
vWallet.addKey(new ECKey());
addWalletExtensions();
}
if (useAutoSave) vWallet.autosaveToFile(vWalletFile, 1, TimeUnit.SECONDS, null);
// Set up peer addresses or discovery first, so if wallet extensions try to broadcast a transaction
// before we're actually connected the broadcast waits for an appropriate number of connections.
if (peerAddresses != null)
{
for (PeerAddress addr : peerAddresses) vPeerGroup.addAddress(addr);
peerAddresses = null;
}
else
{
vPeerGroup.addPeerDiscovery(new DnsDiscovery(params));
}
vChain.addWallet(vWallet);
vPeerGroup.addWallet(vWallet);
onSetupCompleted();
if (blockingStartup)
{
vPeerGroup.startAndWait();
// Make sure we shut down cleanly.
installShutdownHook();
// TODO: Be able to use the provided download listener when doing a blocking startup.
final DownloadListener listener = new DownloadListener();
vPeerGroup.startBlockChainDownload(listener);
listener.await();
}
else
{
Futures.addCallback(vPeerGroup.start(), new FutureCallback<State>()
{
@Override
public void onSuccess(State result)
{
final PeerEventListener l = downloadListener == null ? new DownloadListener() : downloadListener;
vPeerGroup.startBlockChainDownload(l);
}
@Override
public void onFailure(Throwable t)
{
throw new RuntimeException(t);
}
});
}
} catch (BlockStoreException e)
{
throw new IOException(e);
} finally
{
if (walletStream != null) walletStream.close();
}
}
private void installShutdownHook()
{
if (autoStop) Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
try
{
BitSquareWalletAppKit.this.stopAndWait();
} catch (Exception e)
{
throw new RuntimeException(e);
}
}
});
}
}

View file

@ -5,8 +5,6 @@ import io.bitsquare.bank.BankAccount;
/**
* That facade delivers blockchain functionality from the bitcoinJ library
* Code from BitcoinJ must not be used outside that facade.
* That way a change of the library will only affect that class.
*/
public class BlockChainFacade
{

View file

@ -10,6 +10,7 @@ import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.Locale;
// TODO
public class BtcFormatter
{
private static final Logger log = LoggerFactory.getLogger(BtcFormatter.class);

View file

@ -1,28 +0,0 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.TransactionConfidence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConfidenceListener
{
private static final Logger log = LoggerFactory.getLogger(ConfidenceListener.class);
private Address address;
public ConfidenceListener(Address address)
{
this.address = address;
}
public Address getAddress()
{
return address;
}
public void onTransactionConfidenceChanged(TransactionConfidence confidence)
{
}
}

View file

@ -1,34 +0,0 @@
package io.bitsquare.btc;
public class KeyPair
{
//TODO just for mock, remove later
private String pubKey;
private String privKey;
public KeyPair(String pubKey, String privKey)
{
this.pubKey = pubKey;
this.privKey = privKey;
}
public String getPrivKey()
{
return privKey;
}
public void setPrivKey(String privKey)
{
this.privKey = privKey;
}
public String getPubKey()
{
return pubKey;
}
public void setPubKey(String pubKey)
{
this.pubKey = pubKey;
}
}

View file

@ -0,0 +1,23 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.TransactionOutput;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.script.ScriptOpCodes;
import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN;
public class ScriptUtil
{
public static Script getEmptyOP_RETURNScript()
{
return new ScriptBuilder()
.op(OP_RETURN)
.build();
}
public static boolean isOpReturnScript(TransactionOutput transactionOutput)
{
return transactionOutput.getScriptPubKey().getChunks().get(0).equalsOpCode(ScriptOpCodes.OP_RETURN);
}
}

View file

@ -1,21 +0,0 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.kits.WalletAppKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class WalletConfig extends WalletAppKit
{
private static final Logger log = LoggerFactory.getLogger(WalletConfig.class);
public WalletConfig(NetworkParameters params, File directory, String filePrefix)
{
super(params, directory, filePrefix);
}
}

View file

@ -2,12 +2,10 @@ package io.bitsquare.btc;
import com.google.bitcoin.core.*;
import com.google.bitcoin.crypto.TransactionSignature;
import com.google.bitcoin.kits.WalletAppKit;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.RegTestParams;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.script.ScriptOpCodes;
import com.google.bitcoin.utils.Threading;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.FutureCallback;
@ -15,7 +13,10 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject;
import io.bitsquare.BitSquare;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.storage.Storage;
import javafx.application.Platform;
import javafx.util.Pair;
import org.slf4j.Logger;
@ -38,16 +39,15 @@ public class WalletFacade
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
private NetworkParameters params;
private WalletAppKit walletAppKit;
private BitSquareWalletAppKit walletAppKit;
private CryptoFacade cryptoFacade;
private List<DownloadListener> downloadListeners = new ArrayList<>();
private Wallet wallet;
private ECKey arbitratorKey;
private Storage storage;
private BitSquareWallet wallet;
private WalletEventListener walletEventListener;
private List<DownloadListener> downloadListeners = new ArrayList<>();
private List<ConfidenceListener> confidenceListeners = new ArrayList<>();
private List<BalanceListener> balanceListeners = new ArrayList<>();
private List<AddressInfo> addressInfoList = new ArrayList<>();
///////////////////////////////////////////////////////////////////////////////////////////
@ -55,11 +55,12 @@ public class WalletFacade
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public WalletFacade(NetworkParameters params, WalletAppKit walletAppKit, CryptoFacade cryptoFacade)
public WalletFacade(NetworkParameters params, BitSquareWalletAppKit walletAppKit, CryptoFacade cryptoFacade, Storage storage)
{
this.params = params;
this.walletAppKit = walletAppKit;
this.cryptoFacade = cryptoFacade;
this.storage = storage;
}
@ -99,7 +100,7 @@ public class WalletFacade
walletAppKit.startAsync();
walletAppKit.awaitRunning();
wallet = walletAppKit.wallet();
wallet = (BitSquareWallet) walletAppKit.wallet();
wallet.allowSpendingUnconfirmedTransactions();
@ -152,14 +153,33 @@ public class WalletFacade
}
};
wallet.addEventListener(walletEventListener);
List<AddressInfo> savedAddressInfoList = (List<AddressInfo>) storage.read("addressInfoList");
if (savedAddressInfoList != null)
{
addressInfoList = savedAddressInfoList;
}
else
{
addressInfoList.add(getRegistrationAddressInfo());
storage.write("addressInfoList", addressInfoList);
}
}
public void shutDown()
{
wallet.removeEventListener(walletEventListener);
walletAppKit.stopAsync();
walletAppKit.awaitTerminated();
}
public Wallet getWallet()
{
return wallet;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Listener
@ -204,7 +224,7 @@ public class WalletFacade
for (int n = 0; n < transactionOutputs.size(); n++)
{
TransactionOutput transactionOutput = transactionOutputs.get(n);
if (!isOpReturnScript(transactionOutput))
if (!ScriptUtil.isOpReturnScript(transactionOutput))
{
Address address = transactionOutput.getScriptPubKey().getToAddress(params);
if (address.equals(confidenceListener.getAddress()))
@ -216,11 +236,6 @@ public class WalletFacade
}
}
private boolean isOpReturnScript(TransactionOutput transactionOutput)
{
return transactionOutput.getScriptPubKey().getChunks().get(0).equalsOpCode(ScriptOpCodes.OP_RETURN);
}
private void notifyBalanceListeners(Transaction tx)
{
for (int i = 0; i < balanceListeners.size(); i++)
@ -230,7 +245,7 @@ public class WalletFacade
for (int n = 0; n < transactionOutputs.size(); n++)
{
TransactionOutput transactionOutput = transactionOutputs.get(n);
if (!isOpReturnScript(transactionOutput))
if (!ScriptUtil.isOpReturnScript(transactionOutput))
{
Address address = transactionOutput.getScriptPubKey().getToAddress(params);
if (address.equals(balanceListener.getAddress()))
@ -244,45 +259,34 @@ public class WalletFacade
///////////////////////////////////////////////////////////////////////////////////////////
// Key management
// Address management
///////////////////////////////////////////////////////////////////////////////////////////
public boolean isNewWallet()
public List<AddressInfo> getAddressInfoList()
{
// walletAppKit creates first key
return wallet.getKeys().size() == 1;
return addressInfoList;
}
public Address getRegistrationAddress()
public AddressInfo getRegistrationAddressInfo()
{
ECKey key = wallet.getKeys().get(0);
return key.toAddress(params);
ECKey registrationKey = wallet.getKeys().get(0);
return new AddressInfo(registrationKey, params, "Registration");
}
public List<Address> getTradingAddresses()
{
List<Address> addresses = new ArrayList<>();
List<ECKey> keys = wallet.getKeys();
for (int i = 0; i < keys.size(); i++)
{
ECKey key = keys.get(i);
addresses.add(key.toAddress(params));
}
return addresses;
}
public Address createNewAddress()
public AddressInfo getNewAddressInfo(String label)
{
ECKey key = new ECKey();
wallet.addKey(key);
return key.toAddress(params);
AddressInfo addressInfo = new AddressInfo(key, params, label);
addressInfoList.add(addressInfo);
storage.write("addressInfoList", addressInfoList);
return addressInfo;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Address management
///////////////////////////////////////////////////////////////////////////////////////////
public AddressInfo getNewArbitratorAddressInfo()
{
return getNewAddressInfo("Arbitrator deposit");
}
public TransactionConfidence getConfidence(Address address)
{
@ -295,7 +299,7 @@ public class WalletFacade
for (int n = 0; n < transactionOutputs.size(); n++)
{
TransactionOutput transactionOutput = transactionOutputs.get(n);
if (!isOpReturnScript(transactionOutput))
if (!ScriptUtil.isOpReturnScript(transactionOutput))
{
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);
if (addressOutput.equals(address))
@ -319,7 +323,7 @@ public class WalletFacade
BigInteger value = BigInteger.ZERO;
for (TransactionOutput transactionOutput : all)
{
if (!isOpReturnScript(transactionOutput))
if (!ScriptUtil.isOpReturnScript(transactionOutput))
{
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);
if (addressOutput.equals(address))
@ -329,55 +333,31 @@ public class WalletFacade
}
}
return value;
/* Set<Transaction> transactions = wallet.getTransactions(true);
if (transactions != null)
{
for (Transaction tx : transactions)
{
List<TransactionOutput> transactionOutputs = tx.getOutputs();
for (int n = 0; n < transactionOutputs.size(); n++)
{
TransactionOutput transactionOutput = transactionOutputs.get(n);
if (!isOpReturnScript(transactionOutput))
{
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);
if (addressOutput.equals(address))
{
return tx.getValueSentToMe(wallet);
}
}
else
{
return BigInteger.ZERO;
}
}
}
}
return BigInteger.ZERO; */
}
///////////////////////////////////////////////////////////////////////////////////////////
// Trading wallet
///////////////////////////////////////////////////////////////////////////////////////////
public BigInteger getBalance()
public BigInteger getWalletBalance()
{
return wallet.getBalance(Wallet.BalanceType.ESTIMATED);
}
public BigInteger getRegistrationBalance()
{
return getBalance(getRegistrationAddressInfo().getAddress());
}
public ECKey getRegistrationKey()
{
return getRegistrationAddressInfo().getKey();
}
//TODO
public String getTradingAddress()
{
return getTradingKey().toAddress(params).toString();
}
public Wallet getWallet()
{
return wallet;
}
//TODO
public String getPubKeyAsHex()
{
return Utils.bytesToHexString(getTradingKey().getPubKey());
@ -390,21 +370,6 @@ public class WalletFacade
}
///////////////////////////////////////////////////////////////////////////////////////////
// Arbitration key
///////////////////////////////////////////////////////////////////////////////////////////
public String getArbitratorPubKeyAsHex()
{
if (arbitratorKey == null)
{
arbitratorKey = new ECKey();
wallet.addKey(arbitratorKey);
}
return Utils.bytesToHexString(arbitratorKey.getPubKey());
}
//TODO separate wallets
public BigInteger getCollateralBalance()
{
@ -415,17 +380,6 @@ public class WalletFacade
// Account registration
///////////////////////////////////////////////////////////////////////////////////////////
public BigInteger getRegistrationBalance()
{
return getBalance(getRegistrationAddress());
}
public ECKey getRegistrationKey()
{
return wallet.getKeys().get(0);
}
public void publishRegistrationTxWithExtraData(String stringifiedBankAccounts) throws InsufficientMoneyException
{
log.debug("publishRegistrationTxWithExtraData");
@ -471,7 +425,7 @@ public class WalletFacade
{
log.debug("payOfferFee fee=" + Utils.bitcoinValueToFriendlyString(fee));
Transaction tx = new Transaction(params);
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, WalletUtil.getEmptyOP_RETURNScript());
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, ScriptUtil.getEmptyOP_RETURNScript());
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
sendRequest.fee = fee.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(Fees.TX_FEE);

View file

@ -1,55 +0,0 @@
package io.bitsquare.btc;
import com.google.bitcoin.core.Transaction;
import com.google.bitcoin.core.TransactionConfidence;
import com.google.bitcoin.core.Wallet;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptBuilder;
import java.math.BigInteger;
import java.util.Set;
import static com.google.bitcoin.script.ScriptOpCodes.OP_RETURN;
public class WalletUtil
{
// TODO check if that is correct and safe
public static int getConfDepthInBlocks(Wallet wallet)
{
Transaction transaction = WalletUtil.getTransaction(wallet);
if (transaction != null && transaction.getConfidence() != null)
{
if (transaction.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
return wallet.getLastBlockSeenHeight() - transaction.getConfidence().getAppearedAtChainHeight() + 1;
else
return 0;
}
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;
}
public static Script getEmptyOP_RETURNScript()
{
return new ScriptBuilder()
.op(OP_RETURN)
.build();
}
}

View file

@ -8,7 +8,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.security.SignatureException;
import java.util.UUID;
/**
* That facade delivers crypto functionality from the bitcoinJ library
@ -23,10 +22,6 @@ public class CryptoFacade
{
}
public String getRandomID()
{
return UUID.randomUUID().toString();
}
public byte[] getEmbeddedAccountRegistrationData(ECKey registrationKey, String stringifiedBankAccounts)
{

View file

@ -2,7 +2,6 @@ package io.bitsquare.di;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.kits.WalletAppKit;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.RegTestParams;
import com.google.bitcoin.params.TestNet3Params;
@ -11,6 +10,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import io.bitsquare.btc.BitSquareWalletAppKit;
import io.bitsquare.btc.BlockChainFacade;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.crypto.CryptoFacade;
@ -50,23 +50,23 @@ public class BitSquareModule extends AbstractModule
//test net not working yet: http://sourceforge.net/p/bitcoin/mailman/message/32349208/
//bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.TEST_NET);
bind(NetworkParameters.class).toProvider(NetworkParametersProvider.class).asEagerSingleton();
bind(WalletAppKit.class).toProvider(WalletAppKitProvider.class).asEagerSingleton();
bind(BitSquareWalletAppKit.class).toProvider(BitSquareWalletAppKitProvider.class).asEagerSingleton();
}
}
class WalletAppKitProvider implements Provider<WalletAppKit>
class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
{
private NetworkParameters networkParameters;
@Inject
public WalletAppKitProvider(NetworkParameters networkParameters)
public BitSquareWalletAppKitProvider(NetworkParameters networkParameters)
{
this.networkParameters = networkParameters;
}
public WalletAppKit get()
public BitSquareWalletAppKit get()
{
return new WalletAppKit(networkParameters, new File(Utilities.getRootDir()), WalletFacade.WALLET_PREFIX);
return new BitSquareWalletAppKit(networkParameters, new File(Utilities.getRootDir()), WalletFacade.WALLET_PREFIX);
}
}

View file

@ -9,7 +9,6 @@ import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.components.NetworkSyncPane;
import io.bitsquare.gui.market.MarketController;
import io.bitsquare.gui.setup.SetupController;
import io.bitsquare.gui.util.Icons;
import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade;
@ -54,7 +53,6 @@ public class MainController implements Initializable, NavigationController
private ToggleButton prevToggleButton;
private Image prevToggleButtonIcon;
private Pane setupView;
private SetupController setupController;
private NetworkSyncPane networkSyncPane;
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, historyButton, fundsButton, settingsButton;
private Pane msgButtonHolder, buyButtonHolder, sellButtonHolder, ordersButtonButtonHolder;
@ -121,15 +119,6 @@ public class MainController implements Initializable, NavigationController
walletFacade.initWallet();
/*if (user.getAccountID() == null)
{
buildSetupView();
anchorPane.setVisible(false);
setupController.setNetworkSyncPane(networkSyncPane);
rootContainer.getChildren().add(setupView);
}
else
{ */
buildNavigation();
//homeButton.fire();
@ -139,7 +128,6 @@ public class MainController implements Initializable, NavigationController
// ordersButton.fire();
// homeButton.fire();
// msgButton.fire();
// }
AnchorPane.setBottomAnchor(networkSyncPane, 0.0);
AnchorPane.setLeftAnchor(networkSyncPane, 0.0);
@ -212,7 +200,6 @@ public class MainController implements Initializable, NavigationController
anchorPane.setVisible(true);
rootContainer.getChildren().remove(setupView);
setupView = null;
setupController = null;
buildNavigation();
}
@ -240,20 +227,6 @@ public class MainController implements Initializable, NavigationController
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void buildSetupView()
{
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationController.SETUP), Localisation.getResourceBundle());
try
{
setupView = loader.load();
setupController = loader.getController();
setupController.setNavigationController(this);
} catch (IOException e)
{
e.printStackTrace();
}
}
private void buildNavigation()
{
toggleGroup = new ToggleGroup();
@ -342,7 +315,7 @@ public class MainController implements Initializable, NavigationController
balanceTextField.setPrefWidth(90);
balanceTextField.setId("nav-balance-label");
balanceTextField.setText(BtcFormatter.formatSatoshis(walletFacade.getBalance(), false));
balanceTextField.setText(BtcFormatter.formatSatoshis(walletFacade.getWalletBalance(), false));
Label balanceCurrencyLabel = new Label("BTC");
balanceCurrencyLabel.setPadding(new Insets(6, 0, 0, 0));
@ -361,7 +334,7 @@ public class MainController implements Initializable, NavigationController
vBox.getChildren().setAll(hBox, titleLabel);
parent.getChildren().add(vBox);
balanceTextField.setText(Utils.bitcoinValueToFriendlyString(walletFacade.getBalance()));
balanceTextField.setText(Utils.bitcoinValueToFriendlyString(walletFacade.getWalletBalance()));
walletFacade.getWallet().addEventListener(new WalletEventListener()
{
@Override

View file

@ -64,6 +64,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
messageFacade.getArbitrators(LanguageUtil.getDefaultLanguageLocale());
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@ -221,6 +222,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
stage.close();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@ -230,6 +232,5 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
prevButton.setDisable(index < 1);
nextButton.setDisable(index == allArbitrators.size() - 1 || index == -1);
}
}

View file

@ -18,10 +18,8 @@ import java.util.ResourceBundle;
public class ArbitratorProfileController implements Initializable, ChildController
{
private Settings settings;
private Storage storage;
private Arbitrator arbitrator;
private NavigationController navigationController;
@ -33,6 +31,7 @@ public class ArbitratorProfileController implements Initializable, ChildControll
@FXML
private TextArea descriptionTextArea;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -46,12 +45,7 @@ public class ArbitratorProfileController implements Initializable, ChildControll
Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
if (savedSettings != null)
{
settings.updateFromStorage(savedSettings);
}
else
{
}
}
@ -100,6 +94,7 @@ public class ArbitratorProfileController implements Initializable, ChildControll
{
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: ChildController
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -84,6 +84,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
@FXML
private ConfidenceProgressIndicator progressIndicator;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -113,6 +114,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@ -200,6 +202,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
});
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: ChildController
///////////////////////////////////////////////////////////////////////////////////////////
@ -275,7 +278,6 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
methodsTextField.setText(BitSquareFormatter.arbitrationMethodsToString(methodList));
methodsComboBox.getSelectionModel().clearSelection();
}
}
@FXML
@ -302,7 +304,6 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
idVerificationsComboBox.getSelectionModel().clearSelection();
}
@FXML
public void onClearIDVerifications(ActionEvent actionEvent)
{
@ -310,7 +311,6 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
idVerificationsTextField.setText("");
}
@FXML
public void onSaveProfile(ActionEvent actionEvent)
{
@ -345,6 +345,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
//To change body of created methods use File | Settings | File Templates.
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@ -358,7 +359,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
"depending on the overall relation of negative to positive ratings you received after a dispute resolution.\n\n" +
"Please pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC");
String collateralAddress = walletFacade.getRegistrationAddress().toString();
String collateralAddress = walletFacade.getRegistrationAddressInfo().toString();
collateralAddressTextField.setText(collateralAddress);
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
@ -448,7 +449,6 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
languageList = arbitrator.getLanguages();
methodList = arbitrator.getArbitrationMethods();
idVerificationList = arbitrator.getIdVerifications();
}
}
@ -464,7 +464,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
BitSquareValidator.resetTextFields(hasDoubleValueTextFields);
BitSquareValidator.textFieldsHasDoubleValue(hasDoubleValueTextFields);
String pubKeyAsHex = walletFacade.getArbitratorPubKeyAsHex();
String pubKeyAsHex = walletFacade.getNewArbitratorAddressInfo().getPubKeyAsHexString();
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey());
String name = nameTextField.getText();
@ -498,23 +498,6 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
}
}
private boolean isInputValid()
{
String[] stringInputs = {nameTextField.getText(),
descriptionTextArea.getText()
};
boolean result = BitSquareValidator.validateStringsNotEmpty(stringInputs);
String[] doubleInputs = {maxTradeVolumeTextField.getText(),
passiveServiceFeeTextField.getText(),
minPassiveServiceFeeTextField.getText(),
arbitrationFeeTextField.getText(),
minArbitrationFeeTextField.getText()
};
result &= BitSquareValidator.validateStringsAsDouble(doubleInputs);
return result;
}
private void close()
{
Stage stage = (Stage) rootContainer.getScene().getWindow();

View file

@ -5,9 +5,6 @@ import javafx.scene.layout.Pane;
public class HSpacer extends Pane
{
public HSpacer()
{
}
public HSpacer(double width)
{

View file

@ -5,9 +5,6 @@ import javafx.scene.layout.Pane;
public class VSpacer extends Pane
{
public VSpacer()
{
}
public VSpacer(double height)
{

View file

@ -1,84 +0,0 @@
package io.bitsquare.gui.components.processbar;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.util.Utilities;
import javafx.animation.AnimationTimer;
import javafx.scene.control.Button;
import javafx.scene.control.Control;
import javafx.scene.layout.Pane;
import java.util.ArrayList;
import java.util.List;
public class ProcessStepsBuilder
{
protected int index = 0;
private Control previousControl;
private Pane controlHolder;
protected Object controller;
protected List<ProcessStepItem> processStepItems = new ArrayList();
protected ProcessStepBar<String> processStepBar;
public void build(Pane processStepBarHolder, Pane controlHolder, Object controller)
{
this.controlHolder = controlHolder;
this.controller = controller;
fillProcessStepItems();
processStepBar = new ProcessStepBar(processStepItems);
processStepBar.relocate(10, 10);
processStepBarHolder.getChildren().add(processStepBar);
update();
}
public void next()
{
index++;
update();
processStepBar.next();
}
// template
protected void fillProcessStepItems()
{
// to be defined in subclasses
}
protected void update()
{
if (index < processStepItems.size())
{
ProcessStepItem processStepItem = processStepItems.get(index);
if (previousControl != null)
controlHolder.getChildren().remove(previousControl);
if (processStepItem.hasProgressIndicator())
{
final ConfidenceProgressIndicator progressIndicator = new ConfidenceProgressIndicator();
progressIndicator.setProgress(-1.0);
progressIndicator.setPrefSize(30.0, 30.0);
controlHolder.getChildren().add(progressIndicator);
previousControl = progressIndicator;
// TODO
// mock simulate network delay
Utilities.setTimeout(100, (AnimationTimer animationTimer) -> {
next();
return null;
});
}
else
{
final Button button = new Button(processStepItem.getLabel());
button.setOnAction(e -> next());
controlHolder.getChildren().add(button);
previousControl = button;
}
}
}
}

View file

@ -22,7 +22,6 @@ public class AddressListItem
this.isUsed.set(isUsed);
}
// called form table columns
public final StringProperty labelProperty()
{
@ -39,7 +38,6 @@ public class AddressListItem
return this.isUsed;
}
public Address getAddress()
{
return address;

View file

@ -1,14 +1,14 @@
package io.bitsquare.gui.funds;
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.TransactionConfidence;
import com.google.bitcoin.core.Utils;
import com.google.inject.Inject;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bitsquare.btc.BalanceListener;
import io.bitsquare.btc.ConfidenceListener;
import io.bitsquare.btc.AddressInfo;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.ConfidenceListener;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -72,23 +72,16 @@ public class FundsController implements Initializable, ChildController
setCopyColumnCellFactory();
setConfidenceColumnCellFactory();
List<Address> addresses = walletFacade.getTradingAddresses();
List<AddressInfo> addressInfoList = walletFacade.getAddressInfoList();
for (int i = 0; i < addresses.size(); i++)
for (int i = 0; i < addressInfoList.size(); i++)
{
Address address = addresses.get(i);
String label;
if (i == 0)
label = "Registration";
else
label = "Trade " + i;
addressList.add(new AddressListItem(label, address, false));
AddressInfo addressInfo = addressInfoList.get(i);
addressList.add(new AddressListItem(addressInfo.getLabel(), addressInfo.getAddress(), false));
}
addressesTable.setItems(addressList);
addressesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
//Platform.runLater(() -> walletFacade.triggerConfidenceNotificationForAllTransactions());
}
@ -104,7 +97,6 @@ public class FundsController implements Initializable, ChildController
@Override
public void cleanup()
{
}
@ -115,9 +107,8 @@ public class FundsController implements Initializable, ChildController
@FXML
public void onAddNewAddress(ActionEvent actionEvent)
{
Address address = walletFacade.createNewAddress();
addressList.add(new AddressListItem("Trade " + (walletFacade.getTradingAddresses().size() - 1), address, false));
// walletFacade.triggerConfidenceNotificationForAllTransactions();
AddressInfo addressInfo = walletFacade.getNewAddressInfo("New address");
addressList.add(new AddressListItem(addressInfo.getLabel(), addressInfo.getAddress(), false));
}
@ -298,6 +289,5 @@ public class FundsController implements Initializable, ChildController
}
}
}
}

View file

@ -16,7 +16,6 @@ public class HistoryController implements Initializable, ChildController
public void initialize(URL url, ResourceBundle rb)
{
}
@Override

View file

@ -96,7 +96,6 @@ public class HomeController implements Initializable, ChildController, Navigatio
public void onArbitratorRegistration(ActionEvent actionEvent)
{
navigateToView(NavigationController.ARBITRATOR_REGISTRATION, "Registration as Arbitrator");
}
@FXML

View file

@ -243,6 +243,7 @@ public class CreateOfferController implements Initializable, ChildController
navigationController.navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@ -279,6 +280,7 @@ public class CreateOfferController implements Initializable, ChildController
return BtcFormatter.stringValueToSatoshis(amountTextField.getText());
}
//TODO
private boolean inputValid()
{
double priceAsDouble = BitSquareConverter.stringToDouble2(priceTextField.getText());

View file

@ -61,7 +61,6 @@ public class OrderBookController implements Initializable, ChildController
private static final Logger log = LoggerFactory.getLogger(OrderBookController.class);
private NavigationController navigationController;
private OrderBook orderBook;
private SortedList<OrderBookListItem> offerList;
private final OrderBookFilter orderBookFilter;
private User user;
@ -70,7 +69,6 @@ public class OrderBookController implements Initializable, ChildController
private Settings settings;
private Storage storage;
private AnimationTimer pollingTimer;
private Image buyIcon = Icons.getIconImage(Icons.BUY);
private Image sellIcon = Icons.getIconImage(Icons.SELL);
@ -197,7 +195,7 @@ public class OrderBookController implements Initializable, ChildController
try
{
walletFacade.publishRegistrationTxWithExtraData(user.getStringifiedBankAccounts());
user.setAccountID(walletFacade.getRegistrationAddress().toString());
user.setAccountID(walletFacade.getRegistrationAddressInfo().toString());
user.setMessagePubKeyAsHex(DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey()));
storage.write(user.getClass().getName(), user);

View file

@ -54,9 +54,7 @@ public class TakerTradeController implements Initializable, ChildController
private BigInteger requestedAmount;
private boolean offererIsOnline;
private int row;
private List<ProcessStepItem> processStepItems = new ArrayList();
private NavigationController navigationController;
private TextField amountTextField, totalToPayLabel, totalLabel, collateralTextField, isOnlineTextField;
private Label statusTextField, infoLabel;
@ -64,7 +62,7 @@ public class TakerTradeController implements Initializable, ChildController
private ProgressBar progressBar;
private AnimationTimer checkOnlineStatusTimer;
private Pane isOnlineCheckerHolder;
TakerPaymentProtocol takerPaymentProtocol;
private TakerPaymentProtocol takerPaymentProtocol;
private Label headerLabel;
@FXML
@ -448,7 +446,6 @@ public class TakerTradeController implements Initializable, ChildController
}
}
private void applyCollateral()
{
collateralTextField.setText(BtcFormatter.formatSatoshis(getCollateralInSatoshis(), false));

View file

@ -59,7 +59,6 @@ public class OrdersController implements Initializable, ChildController
private Image sellIcon = Icons.getIconImage(Icons.SELL);
private ConfidenceDisplay confidenceDisplay;
@FXML
private VBox rootContainer;
@FXML
@ -179,7 +178,6 @@ public class OrdersController implements Initializable, ChildController
public void close(ActionEvent actionEvent)
{
}

View file

@ -1,19 +1,25 @@
package io.bitsquare.gui.settings;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.Utils;
import com.google.inject.Inject;
import io.bitsquare.BitSquare;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.bank.BankAccountTypeInfo;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.util.BitSquareValidator;
import io.bitsquare.gui.util.Icons;
import io.bitsquare.locale.*;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.Reputation;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
@ -37,14 +43,16 @@ import java.io.IOException;
import java.net.URL;
import java.util.*;
// TODO separate in 2 view/controllers
public class SettingsController implements Initializable, ChildController, NavigationController
{
private User user;
private Settings settings;
private Storage storage;
private WalletFacade walletFacade;
private MessageFacade messageFacade;
private NavigationController navigationController;
private ChildController childController;
private ObservableList<Locale> languageList;
private ObservableList<Country> countryList;
private List<String> regionList;
@ -80,11 +88,13 @@ public class SettingsController implements Initializable, ChildController, Navig
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SettingsController(User user, Settings settings, Storage storage)
public SettingsController(User user, Settings settings, Storage storage, WalletFacade walletFacade, MessageFacade messageFacade)
{
this.user = user;
this.settings = settings;
this.storage = storage;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
if (savedSettings != null)
@ -127,6 +137,46 @@ public class SettingsController implements Initializable, ChildController, Navig
setupGeneralSettingsScreen();
initBankAccountScreen();
addMockArbitrator();
}
private void addMockArbitrator()
{
String pubKeyAsHex = Utils.bytesToHexString(new ECKey().getPubKey());
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey());
List<Locale> languages = new ArrayList<>();
languages.add(LanguageUtil.getDefaultLanguageLocale());
List<Arbitrator.METHODS> arbitrationMethods = new ArrayList<>();
arbitrationMethods.add(Arbitrator.METHODS.TLS_NOTARY);
List<Arbitrator.ID_VERIFICATIONS> idVerifications = new ArrayList<>();
idVerifications.add(Arbitrator.ID_VERIFICATIONS.PASSPORT);
idVerifications.add(Arbitrator.ID_VERIFICATIONS.GOV_ID);
Arbitrator arbitrator = new Arbitrator(pubKeyAsHex,
messagePubKeyAsHex,
"Manfred Karrer",
Arbitrator.ID_TYPE.REAL_LIFE_ID,
languages,
new Reputation(),
1,
0.01,
0.001,
10,
0.1,
arbitrationMethods,
idVerifications,
"http://bitsquare.io/",
"Bla bla..."
);
try
{
messageFacade.addArbitrator(arbitrator);
} catch (IOException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}

View file

@ -1,393 +0,0 @@
package io.bitsquare.gui.setup;
import com.google.bitcoin.core.*;
import com.google.bitcoin.script.Script;
import com.google.inject.Inject;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.bank.BankAccountTypeInfo;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.components.NetworkSyncPane;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.ConfidenceDisplay;
import io.bitsquare.gui.util.Popups;
import io.bitsquare.locale.Country;
import io.bitsquare.locale.CountryUtil;
import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.locale.Localisation;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.storage.Storage;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.layout.AnchorPane;
import javafx.util.StringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.net.URL;
import java.util.Currency;
import java.util.List;
import java.util.ResourceBundle;
public class SetupController implements Initializable, ChildController
{
private static final Logger log = LoggerFactory.getLogger(SetupController.class);
private final User user;
private final WalletFacade walletFacade;
private NavigationController navigationController;
private MessageFacade messageFacade;
private final Storage storage;
private ConfidenceDisplay confidenceDisplay;
@FXML
private AnchorPane rootContainer;
@FXML
private TitledPane payRegistrationFeePane, addBankAccountPane, settingsPane;
@FXML
private Label payRegFeeInfoLabel, addBankAccountInfoLabel, copyIcon, confirmationLabel;
@FXML
private TextField registrationAddressTextField, balanceTextField, accountTitle, accountHolderName, accountPrimaryID, accountSecondaryID;
@FXML
private Button createAccountButton, addBankAccountButton, paymentDoneButton;
@FXML
private Accordion accordion;
@FXML
private ComboBox<Country> countryComboBox;
@FXML
private ComboBox<BankAccountTypeInfo> bankAccountTypesComboBox;
@FXML
private ComboBox<Currency> currencyComboBox;
@FXML
private ConfidenceProgressIndicator progressIndicator;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SetupController(User user, WalletFacade walletFacade, MessageFacade messageFacade, Storage storage)
{
this.user = user;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
this.storage = storage;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
// pass in NetworkSyncPane from parent view
public void setNetworkSyncPane(NetworkSyncPane networkSyncPane)
{
rootContainer.getChildren().add(networkSyncPane);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void initialize(URL url, ResourceBundle rb)
{
setupRegistrationScreen();
setupBankAccountScreen();
setupSettingsScreen();
accordion.setExpandedPane(payRegistrationFeePane);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: ChildController
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void setNavigationController(NavigationController navigationController)
{
this.navigationController = navigationController;
}
@Override
public void cleanup()
{
}
///////////////////////////////////////////////////////////////////////////////////////////
// Button handlers
///////////////////////////////////////////////////////////////////////////////////////////
public void onPaymentDone(ActionEvent actionEvent)
{
accordion.setExpandedPane(addBankAccountPane);
}
public void onSkipPayment(ActionEvent actionEvent)
{
accordion.setExpandedPane(addBankAccountPane);
}
public void onAddBankAccount(ActionEvent actionEvent)
{
addBankAccount();
storage.write(user.getClass().getName(), user);
if (verifyBankAccountData())
{
bankAccountTypesComboBox.getSelectionModel().clearSelection();
accountPrimaryID.setText("");
accountPrimaryID.setPromptText("");
accountSecondaryID.setText("");
accountSecondaryID.setPromptText("");
}
}
public void onCreateAccount(ActionEvent actionEvent)
{
addBankAccount();
if (user.getBankAccounts().size() > 0)
{
try
{
walletFacade.publishRegistrationTxWithExtraData(user.getStringifiedBankAccounts());
user.setAccountID(walletFacade.getRegistrationAddress().toString());
user.setMessagePubKeyAsHex(DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey()));
storage.write(user.getClass().getName(), user);
accordion.setExpandedPane(settingsPane);
} catch (InsufficientMoneyException e1)
{
Popups.openErrorPopup("Not enough money available", "There is not enough money available. Please pay in first to your wallet.");
}
}
}
public void onSkipBankAccountSetup(ActionEvent actionEvent)
{
accordion.setExpandedPane(settingsPane);
}
public void onClose(ActionEvent actionEvent)
{
navigationController.navigateToView(NavigationController.FUNDS);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Screens setup
///////////////////////////////////////////////////////////////////////////////////////////
private void setupRegistrationScreen()
{
payRegFeeInfoLabel.setText("You need to pay 0.01 BTC to the registration address.\n\n" +
"That payment will be used to create a unique account connected with your bank account number.\n" +
"The privacy of your bank account number will be protected and only revealed to your trading partners.\n" +
"The payment will be spent to miners and is needed to store data into the blockchain.\n" +
"Your trading account will be the source for your reputation in the trading platform.\n\n" +
"You need at least 1 confirmation for doing the registration payment.");
String registrationAddress = walletFacade.getRegistrationAddress().toString();
registrationAddressTextField.setText(registrationAddress);
copyIcon.setId("copy-icon");
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard"));
copyIcon.setOnMouseClicked(e -> {
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(registrationAddress);
clipboard.setContent(content);
});
confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, balanceTextField, progressIndicator);
paymentDoneButton.setDisable(walletFacade.getRegistrationBalance().compareTo(BigInteger.ZERO) == 0);
log.debug("getAccountRegistrationBalance " + walletFacade.getRegistrationBalance().toString());
walletFacade.getWallet().addEventListener(new WalletEventListener()
{
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
{
paymentDoneButton.setDisable(newBalance.compareTo(BigInteger.ZERO) == 0);
}
@Override
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
{
}
@Override
public void onCoinsSent(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
{
}
@Override
public void onReorganize(Wallet wallet)
{
}
@Override
public void onWalletChanged(Wallet wallet)
{
}
@Override
public void onKeysAdded(Wallet wallet, List<ECKey> keys)
{
}
@Override
public void onScriptsAdded(Wallet wallet, List<Script> scripts)
{
}
});
}
private void setupBankAccountScreen()
{
addBankAccountInfoLabel.setText("Add at least one Bank account to your trading account.\n" +
"That data will be stored in the blockchain in a way that your privacy is protected.\n" +
"Only your trading partners will be able to read those data, so your privacy will be protected.");
bankAccountTypesComboBox.setItems(FXCollections.observableArrayList(BankAccountTypeInfo.getAllBankAccountTypeInfoObjects()));
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllCurrencies()));
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountries()));
bankAccountTypesComboBox.setConverter(new StringConverter<BankAccountTypeInfo>()
{
@Override
public String toString(BankAccountTypeInfo bankAccountTypeInfo)
{
return Localisation.get(bankAccountTypeInfo.toString());
}
@Override
public BankAccountTypeInfo fromString(String s)
{
return null;
}
});
currencyComboBox.setConverter(new StringConverter<Currency>()
{
@Override
public String toString(Currency currency)
{
return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
}
@Override
public Currency fromString(String s)
{
return null;
}
});
countryComboBox.setConverter(new StringConverter<Country>()
{
@Override
public String toString(Country country)
{
return country.getName();
}
@Override
public Country fromString(String s)
{
return null;
}
});
bankAccountTypesComboBox.valueProperty().addListener((ov, oldValue, newValue) -> {
if (newValue != null && newValue instanceof BankAccountTypeInfo)
{
accountPrimaryID.setText("");
accountPrimaryID.setPromptText(newValue.getPrimaryIDName());
accountSecondaryID.setText("");
accountSecondaryID.setPromptText(newValue.getSecondaryIDName());
checkCreateAccountButtonState();
}
});
currencyComboBox.valueProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
countryComboBox.valueProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
checkCreateAccountButtonState();
// handlers
accountTitle.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
accountHolderName.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
accountPrimaryID.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
accountSecondaryID.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
//todo
bankAccountTypesComboBox.getSelectionModel().select(0);
currencyComboBox.getSelectionModel().select(0);
countryComboBox.getSelectionModel().select(0);
accountTitle.setText("Sepa EUR Account");
accountHolderName.setText("Alice");
accountPrimaryID.setText("123456");
accountSecondaryID.setText("7896541");
}
private void setupSettingsScreen()
{
//TODO
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void addBankAccount()
{
if (verifyBankAccountData())
{
BankAccount bankAccount = new BankAccount(
bankAccountTypesComboBox.getSelectionModel().getSelectedItem(),
currencyComboBox.getSelectionModel().getSelectedItem(),
countryComboBox.getSelectionModel().getSelectedItem(),
accountTitle.getText(),
accountHolderName.getText(),
accountPrimaryID.getText(),
accountSecondaryID.getText());
user.addBankAccount(bankAccount);
}
}
private void checkCreateAccountButtonState()
{
createAccountButton.setDisable(!verifyBankAccountData());
addBankAccountButton.setDisable(!verifyBankAccountData());
}
private boolean verifyBankAccountData()
{
return bankAccountTypesComboBox.getSelectionModel().getSelectedItem() != null
&& countryComboBox.getSelectionModel().getSelectedItem() != null
&& currencyComboBox.getSelectionModel().getSelectedItem() != null
&& accountTitle.getText().length() > 0
&& accountHolderName.getText().length() > 0
&& accountPrimaryID.getText().length() > 0
&& accountSecondaryID.getText().length() > 0;
}
}

View file

@ -1,162 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" fx:controller="io.bitsquare.gui.setup.SetupController" prefWidth="800" prefHeight="600" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label id="headline-label" text="Setup trading account" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="10.0"/>
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<panes>
<TitledPane fx:id="payRegistrationFeePane" text="Pay registration fee">
<content>
<AnchorPane>
<children>
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label fx:id="payRegFeeInfoLabel"/>
<GridPane hgap="5.0" vgap="5.0">
<children>
<Label text="Registration address:"/>
<TextField fx:id="registrationAddressTextField" editable="false" GridPane.columnIndex="1"/>
<Label fx:id="copyIcon" GridPane.columnIndex="2">
<padding>
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
</padding>
<tooltip>
<Tooltip text="Copy address to clipboard"/>
</tooltip>
</Label>
<Label text="Balance:" GridPane.rowIndex="1"/>
<TextField fx:id="balanceTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<ConfidenceProgressIndicator fx:id="progressIndicator" GridPane.columnIndex="2" GridPane.halignment="LEFT"
GridPane.rowIndex="1" GridPane.rowSpan="2" GridPane.valignment="TOP">
<GridPane.margin>
<Insets top="2.0"/>
</GridPane.margin>
</ConfidenceProgressIndicator>
<Label fx:id="confirmationLabel" text="Checking confirmations..." GridPane.columnIndex="3" GridPane.rowIndex="1"/>
<Button fx:id="paymentDoneButton" defaultButton="true" onAction="#onPaymentDone" text="Payment done" disable="true" GridPane.columnIndex="1"
GridPane.rowIndex="2"/>
<Button onAction="#onSkipPayment" text="Skip and pay later" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
</children>
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints hgrow="SOMETIMES" prefWidth="20.0" minWidth="20"/>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
</GridPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="addBankAccountPane" animated="true" text="Add Bank account">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<children>
<Label fx:id="addBankAccountInfoLabel"/>
<GridPane hgap="5.0" vgap="5.0">
<children>
<Label text="Bank account type:"/>
<ComboBox fx:id="bankAccountTypesComboBox" promptText="Select bank account type" GridPane.columnIndex="1"/>
<Label text="Bank account title:" GridPane.rowIndex="1"/>
<TextField fx:id="accountTitle" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label text="Bank account holder name" GridPane.rowIndex="2"/>
<TextField fx:id="accountHolderName" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="Bank account primary ID" GridPane.rowIndex="3"/>
<TextField fx:id="accountPrimaryID" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label text="Bank account secondary ID" GridPane.rowIndex="4"/>
<TextField fx:id="accountSecondaryID" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<Label text="Currency used for bank account:" GridPane.rowIndex="5"/>
<ComboBox fx:id="currencyComboBox" promptText="Select currency" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
<Label text="Country of bank account" GridPane.rowIndex="6"/>
<ComboBox fx:id="countryComboBox" promptText="Select country" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
<Button fx:id="addBankAccountButton" onAction="#onAddBankAccount" text="Add another bank account" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
<Button fx:id="createAccountButton" defaultButton="true" onAction="#onCreateAccount" text="Create account" GridPane.columnIndex="1"
GridPane.rowIndex="8"/>
<Button onAction="#onSkipBankAccountSetup" text="Skip and register later" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
</children>
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="ALWAYS"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
</GridPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="settingsPane" animated="true" text="Set up preferences">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label text="Set up preferences... TODO "/>
<Button defaultButton="true" onAction="#onClose" text="Done" GridPane.columnIndex="1" GridPane.rowIndex="8"/>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</AnchorPane>

View file

@ -7,7 +7,6 @@ public class BitSquareConverter
{
private static final Logger log = LoggerFactory.getLogger(BitSquareConverter.class);
/**
* @param input String to be converted to a double. Both decimal points "." and "," are supported. Thousands separator is not supported.
* @return Returns a double value. Any invalid value returns Double.NEGATIVE_INFINITY.
@ -23,7 +22,6 @@ public class BitSquareConverter
}
}
/**
* @param input String to be converted to a double. Both decimal points "." and "," are supported. Thousands separator is not supported.
* @return Returns a double value. Any invalid value throws an exception.

View file

@ -76,6 +76,7 @@ public class BitSquareValidator
}
}
//TODO
public static void textFieldBankAccountSecondaryIDIsValid(TextField textField, BankAccountTypeInfo bankAccountTypeInfo) throws ValidationException
{
if (!validateStringNotEmpty(textField.getText()))
@ -86,7 +87,6 @@ public class BitSquareValidator
}
}
public static boolean validateStringsAsDouble(String[] inputs)
{
boolean result = true;

View file

@ -13,6 +13,7 @@ import java.util.Currency;
import java.util.List;
import java.util.Locale;
//TODO to be removed
public class FormBuilder
{
public static Label addLabel(GridPane gridPane, String title, String value, int row)

View file

@ -9,8 +9,6 @@ public class Country implements Serializable
private String code;
private String name;
private Region region;
public Country(String code, String name, Region region)
@ -36,7 +34,6 @@ public class Country implements Serializable
return other.getCode().equals(code);
}
public String getCode()
{
return code;

View file

@ -55,7 +55,6 @@ public class CountryUtil
}
}));
return filteredList;
}
@ -83,6 +82,18 @@ public class CountryUtil
return new Country(locale.getCountry(), locale.getDisplayCountry(), region);
}
public static String getRegionName(String regionCode)
{
for (String[] regionName : regionCodeToName)
{
if (regionName[0].equals(regionCode))
{
return regionName[1];
}
}
return regionCode;
}
private static List<Locale> getAllCountryLocales()
{
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
@ -109,7 +120,6 @@ public class CountryUtil
return allLocales;
}
private static String getRegionCode(String countryCode)
{
if (countryCode.length() > 0 && countryCodeList.contains(countryCode))
@ -123,18 +133,6 @@ public class CountryUtil
}
}
public static String getRegionName(String regionCode)
{
for (String[] regionName : regionCodeToName)
{
if (regionName[0].equals(regionCode))
{
return regionName[1];
}
}
return regionCode;
}
private static String[] countryCodes = new String[]{"AE",
"AL",
"AR",

View file

@ -5,7 +5,6 @@ import java.util.*;
public class CurrencyUtil
{
public static List<Currency> getAllCurrencies()
{
ArrayList<Currency> mainCurrencies = new ArrayList<>();

View file

@ -40,6 +40,7 @@ public class Contract implements Serializable
this.takerMessagePubKeyAsHex = takerMessagePubKeyAsHex;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
@ -84,6 +85,11 @@ public class Contract implements Serializable
return takerMessagePubKeyAsHex;
}
public String getOffererMessagePubKeyAsHex()
{
return offererMessagePubKeyAsHex;
}
@Override
public String toString()
{
@ -100,8 +106,5 @@ public class Contract implements Serializable
'}';
}
public String getOffererMessagePubKeyAsHex()
{
return offererMessagePubKeyAsHex;
}
}

View file

@ -61,7 +61,6 @@ public class OrderBook implements OrderBookListener
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public void init()
{
messageFacade.addMessageListener(this);

View file

@ -7,8 +7,6 @@ import java.util.Objects;
public class Arbitrator implements Serializable
{
public enum ID_TYPE
{
REAL_LIFE_ID,
@ -95,8 +93,7 @@ public class Arbitrator implements Serializable
this.webUrl = webUrl;
this.description = description;
//TODO use pubKeyAsHex
UID = name;
UID = pubKeyAsHex;
}

View file

@ -132,20 +132,6 @@ public class Utilities
return obj;
}
/* public static ArrayList<BankAccountTypeInfo.BankAccountType> getAllBankAccountTypeEnums()
{
ArrayList<BankAccountTypeInfo.BankAccountType> bankAccountTypes = new ArrayList<>();
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.SEPA);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.WIRE);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.INTERNATIONAL);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.OK_PAY);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.NET_TELLER);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.PERFECT_MONEY);
bankAccountTypes.add(BankAccountTypeInfo.BankAccountType.OTHER);
return bankAccountTypes;
} */
public static AnimationTimer setTimeout(int delay, Function<AnimationTimer, Void> callback)
{
AnimationTimer animationTimer = new AnimationTimer()

View file

@ -14,6 +14,7 @@ public class BitSquareValidatorTest
assertTrue(BitSquareValidator.validateStringAsDouble("1"));
assertTrue(BitSquareValidator.validateStringAsDouble("0,1"));
assertTrue(BitSquareValidator.validateStringAsDouble("0.01"));
assertFalse(BitSquareValidator.validateStringAsDouble(""));
assertFalse(BitSquareValidator.validateStringAsDouble("a"));
assertFalse(BitSquareValidator.validateStringAsDouble("0.0.1"));
@ -27,6 +28,7 @@ public class BitSquareValidatorTest
{
assertTrue(BitSquareValidator.validateStringNotEmpty("a"));
assertTrue(BitSquareValidator.validateStringNotEmpty("123"));
assertFalse(BitSquareValidator.validateStringNotEmpty(""));
assertFalse(BitSquareValidator.validateStringNotEmpty(" "));
assertFalse(BitSquareValidator.validateStringNotEmpty(null));

View file

@ -1,19 +0,0 @@
package io.bitsquare.util;
import io.bitsquare.locale.CountryUtil;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class LocationUtilsTest
{
@Test
public void testVerifyBankAccountData()
{
CountryUtil.getAllCountries();
assertTrue(true);
//assertTrue(Verification.verifyAccountIDsByBankTransferType(BankAccountType.BankAccountTypeEnum.SEPA, "DE11876543210000123456", "12345678"));
}
}