mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 15:26:03 -04:00
remove @Nullable/@NotNull annotations (too noisy and better use Optional/Either instead to avoid null pointer exc.)
This commit is contained in:
parent
d9410f91a0
commit
4f26d76746
@ -20,8 +20,6 @@ import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -34,7 +32,7 @@ public class BitSquare extends Application
|
||||
private WalletFacade walletFacade;
|
||||
private MessageFacade messageFacade;
|
||||
|
||||
public static void main(@Nullable String[] args)
|
||||
public static void main(String[] args)
|
||||
{
|
||||
log.debug("Startup: main");
|
||||
if (args != null && args.length > 0)
|
||||
@ -49,13 +47,13 @@ public class BitSquare extends Application
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(@NotNull Stage stage)
|
||||
public void start(Stage stage)
|
||||
{
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||
init(stage);
|
||||
}
|
||||
|
||||
private void init(@NotNull Stage stage)
|
||||
private void init(Stage stage)
|
||||
{
|
||||
BitSquare.stage = stage;
|
||||
|
||||
@ -88,9 +86,9 @@ public class BitSquare extends Application
|
||||
|
||||
try
|
||||
{
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final Parent mainView = loader.load();
|
||||
@NotNull final Scene scene = new Scene(mainView, 800, 600);
|
||||
final Scene scene = new Scene(mainView, 800, 600);
|
||||
stage.setScene(scene);
|
||||
|
||||
final String bitsquare = getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm();
|
||||
|
@ -3,7 +3,6 @@ package io.bitsquare;
|
||||
import net.tomp2p.p2p.Peer;
|
||||
import net.tomp2p.p2p.PeerMaker;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Network node for relaying p2p msg
|
||||
@ -11,10 +10,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
class RelayNode
|
||||
{
|
||||
private static final Number160 ID = Number160.createHash(1);
|
||||
@Nullable
|
||||
|
||||
private static Peer masterPeer = null;
|
||||
|
||||
public static void main(@Nullable String[] args) throws Exception
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
if (args != null && args.length == 1)
|
||||
INSTANCE(new Integer(args[0]));
|
||||
|
@ -4,37 +4,35 @@ import io.bitsquare.locale.Country;
|
||||
import java.io.Serializable;
|
||||
import java.util.Currency;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BankAccount implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1792577576443221268L;
|
||||
|
||||
@NotNull
|
||||
|
||||
private final BankAccountType bankAccountType;
|
||||
@NotNull
|
||||
|
||||
private final String accountPrimaryID;
|
||||
@NotNull
|
||||
|
||||
private final String accountSecondaryID;
|
||||
@NotNull
|
||||
|
||||
private final String accountHolderName;
|
||||
@NotNull
|
||||
|
||||
private final Country country;
|
||||
@NotNull
|
||||
|
||||
private final Currency currency;
|
||||
@NotNull
|
||||
|
||||
private final String uid;
|
||||
@NotNull
|
||||
|
||||
private final String accountTitle;
|
||||
|
||||
public BankAccount(@NotNull BankAccountType bankAccountType,
|
||||
@NotNull Currency currency,
|
||||
@NotNull Country country,
|
||||
@NotNull String accountTitle,
|
||||
@NotNull String accountHolderName,
|
||||
@NotNull String accountPrimaryID,
|
||||
@NotNull String accountSecondaryID)
|
||||
public BankAccount(BankAccountType bankAccountType,
|
||||
Currency currency,
|
||||
Country country,
|
||||
String accountTitle,
|
||||
String accountHolderName,
|
||||
String accountPrimaryID,
|
||||
String accountSecondaryID)
|
||||
{
|
||||
this.bankAccountType = bankAccountType;
|
||||
this.currency = currency;
|
||||
@ -52,7 +50,7 @@ public class BankAccount implements Serializable
|
||||
return Objects.hashCode(uid);
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object obj)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof BankAccount))
|
||||
return false;
|
||||
@ -63,55 +61,55 @@ public class BankAccount implements Serializable
|
||||
return uid.equals(other.getUid());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getAccountPrimaryID()
|
||||
{
|
||||
return accountPrimaryID;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getAccountSecondaryID()
|
||||
{
|
||||
return accountSecondaryID;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getAccountHolderName()
|
||||
{
|
||||
return accountHolderName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public BankAccountType getBankAccountType()
|
||||
{
|
||||
return bankAccountType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Currency getCurrency()
|
||||
{
|
||||
return currency;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Country getCountry()
|
||||
{
|
||||
return country;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getAccountTitle()
|
||||
{
|
||||
return accountTitle;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.bank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum BankAccountType
|
||||
{
|
||||
@ -14,30 +13,30 @@ public enum BankAccountType
|
||||
PERFECT_MONEY("primary ID", "secondary ID"),
|
||||
OTHER("primary ID", "secondary ID");
|
||||
|
||||
@NotNull
|
||||
|
||||
private final String primaryId;
|
||||
@NotNull
|
||||
|
||||
private final String secondaryId;
|
||||
|
||||
BankAccountType(@NotNull String primaryId, @NotNull String secondaryId)
|
||||
BankAccountType(String primaryId, String secondaryId)
|
||||
{
|
||||
this.primaryId = primaryId;
|
||||
this.secondaryId = secondaryId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static ArrayList<BankAccountType> getAllBankAccountTypes()
|
||||
{
|
||||
return new ArrayList<>(Arrays.asList(BankAccountType.values()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getPrimaryId()
|
||||
{
|
||||
return primaryId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getSecondaryId()
|
||||
{
|
||||
return secondaryId;
|
||||
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -44,7 +43,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@VisibleForTesting
|
||||
static void sortOutputs(@NotNull ArrayList<TransactionOutput> outputs)
|
||||
static void sortOutputs(ArrayList<TransactionOutput> outputs)
|
||||
{
|
||||
Collections.sort(outputs, (a, b) -> {
|
||||
int depth1 = 0;
|
||||
@ -71,7 +70,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isInBlockChainOrPending(@NotNull Transaction tx)
|
||||
private static boolean isInBlockChainOrPending(Transaction tx)
|
||||
{
|
||||
// Pick chain-included transactions and transactions that are pending.
|
||||
TransactionConfidence confidence = tx.getConfidence();
|
||||
@ -83,7 +82,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
|
||||
}
|
||||
|
||||
private static boolean isInBlockChain(@NotNull Transaction tx)
|
||||
private static boolean isInBlockChain(Transaction tx)
|
||||
{
|
||||
// Only pick chain-included transactions.
|
||||
TransactionConfidence confidence = tx.getConfidence();
|
||||
@ -94,7 +93,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
/**
|
||||
* Sub-classes can override this to just customize whether transactions are usable, but keep age sorting.
|
||||
*/
|
||||
protected boolean shouldSelect(@NotNull Transaction tx)
|
||||
protected boolean shouldSelect(Transaction tx)
|
||||
{
|
||||
if (includePending)
|
||||
return isInBlockChainOrPending(tx);
|
||||
@ -103,7 +102,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected boolean matchesRequiredAddress(@NotNull TransactionOutput transactionOutput)
|
||||
protected boolean matchesRequiredAddress(TransactionOutput transactionOutput)
|
||||
{
|
||||
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH())
|
||||
{
|
||||
@ -116,14 +115,14 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CoinSelection select(@NotNull BigInteger biTarget, @NotNull LinkedList<TransactionOutput> candidates)
|
||||
|
||||
public CoinSelection select(BigInteger biTarget, LinkedList<TransactionOutput> candidates)
|
||||
{
|
||||
long target = biTarget.longValue();
|
||||
@NotNull HashSet<TransactionOutput> selected = new HashSet<>();
|
||||
HashSet<TransactionOutput> selected = new HashSet<>();
|
||||
// Sort the inputs by age*value so we get the highest "coindays" spent.
|
||||
// TODO: Consider changing the wallets internal format to track just outputs and keep them ordered.
|
||||
@NotNull ArrayList<TransactionOutput> sortedOutputs = new ArrayList<>(candidates);
|
||||
ArrayList<TransactionOutput> sortedOutputs = new ArrayList<>(candidates);
|
||||
// When calculating the wallet balance, we may be asked to select all possible coins, if so, avoid sorting
|
||||
// them in order to improve performance.
|
||||
if (!biTarget.equals(NetworkParameters.MAX_MONEY))
|
||||
@ -133,7 +132,7 @@ class AddressBasedCoinSelector extends DefaultCoinSelector
|
||||
// Now iterate over the sorted outputs until we have got as close to the target as possible or a little
|
||||
// bit over (excessive value will be change).
|
||||
long total = 0;
|
||||
for (@NotNull TransactionOutput output : sortedOutputs)
|
||||
for (TransactionOutput output : sortedOutputs)
|
||||
{
|
||||
if (total >= target) break;
|
||||
// Only pick chain-included transactions, or transactions that are ours and pending.
|
||||
|
@ -5,7 +5,6 @@ import com.google.bitcoin.core.ECKey;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Utils;
|
||||
import java.io.Serializable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AddressEntry implements Serializable
|
||||
{
|
||||
@ -13,7 +12,7 @@ public class AddressEntry implements Serializable
|
||||
private final ECKey key;
|
||||
private final NetworkParameters params;
|
||||
private final AddressContext addressContext;
|
||||
@Nullable
|
||||
|
||||
private String tradeId = null;
|
||||
|
||||
public AddressEntry(ECKey key, NetworkParameters params, AddressContext addressContext)
|
||||
@ -23,13 +22,13 @@ public class AddressEntry implements Serializable
|
||||
this.addressContext = addressContext;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getTradeId()
|
||||
{
|
||||
return tradeId;
|
||||
}
|
||||
|
||||
public void setTradeId(@Nullable String tradeId)
|
||||
public void setTradeId(String tradeId)
|
||||
{
|
||||
this.tradeId = tradeId;
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BitSquareWalletAppKit extends WalletAppKit
|
||||
{
|
||||
@ -34,10 +32,10 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
throw new IOException("Could not create named directory.");
|
||||
}
|
||||
}
|
||||
@Nullable FileInputStream walletStream = null;
|
||||
FileInputStream walletStream = null;
|
||||
try
|
||||
{
|
||||
@NotNull File chainFile = new File(directory, filePrefix + ".spvchain");
|
||||
File chainFile = new File(directory, filePrefix + ".spvchain");
|
||||
boolean chainFileExists = chainFile.exists();
|
||||
vWalletFile = new File(directory, filePrefix + ".wallet");
|
||||
boolean shouldReplayWallet = vWalletFile.exists() && !chainFileExists;
|
||||
@ -52,8 +50,8 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
long time = Long.MAX_VALUE;
|
||||
if (vWalletFile.exists())
|
||||
{
|
||||
@NotNull Wallet wallet = new BitSquareWallet(params);
|
||||
@NotNull FileInputStream stream = new FileInputStream(vWalletFile);
|
||||
Wallet wallet = new BitSquareWallet(params);
|
||||
FileInputStream stream = new FileInputStream(vWalletFile);
|
||||
new WalletProtobufSerializer().readWallet(WalletProtobufSerializer.parseToProto(stream), wallet);
|
||||
time = wallet.getEarliestKeyCreationTime();
|
||||
}
|
||||
@ -104,7 +102,7 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
// Make sure we shut down cleanly.
|
||||
installShutdownHook();
|
||||
// TODO: Be able to use the provided download listener when doing a blocking startup.
|
||||
@NotNull final DownloadListener listener = new DownloadListener();
|
||||
final DownloadListener listener = new DownloadListener();
|
||||
vPeerGroup.startBlockChainDownload(listener);
|
||||
listener.await();
|
||||
}
|
||||
@ -116,12 +114,12 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||
@Override
|
||||
public void onSuccess(State result)
|
||||
{
|
||||
@NotNull final PeerEventListener l = downloadListener == null ? new DownloadListener() : downloadListener;
|
||||
final PeerEventListener l = downloadListener == null ? new DownloadListener() : downloadListener;
|
||||
vPeerGroup.startBlockChainDownload(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.btc;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* That facade delivers blockchain functionality from the bitcoinJ library
|
||||
@ -43,7 +42,7 @@ public class BlockChainFacade
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
private byte[] getDataForTxWithAddress(String address)
|
||||
{
|
||||
// TODO
|
||||
|
@ -5,7 +5,6 @@ import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import java.math.BigInteger;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Locale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -14,7 +13,7 @@ public class BtcFormatter
|
||||
{
|
||||
private static final BigInteger BTC = new BigInteger("100000000");
|
||||
private static final Logger log = LoggerFactory.getLogger(BtcFormatter.class);
|
||||
@NotNull
|
||||
|
||||
public static BigInteger mBTC = new BigInteger("100000");
|
||||
|
||||
|
||||
@ -24,7 +23,7 @@ public class BtcFormatter
|
||||
}
|
||||
|
||||
//TODO
|
||||
public static double satoshiToBTC(@NotNull BigInteger satoshis)
|
||||
public static double satoshiToBTC(BigInteger satoshis)
|
||||
{
|
||||
return satoshis.doubleValue() / BTC.doubleValue();
|
||||
}
|
||||
@ -39,7 +38,7 @@ public class BtcFormatter
|
||||
try
|
||||
{
|
||||
// only "." as decimal sep supported by Utils.toNanoCoins
|
||||
@NotNull DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.ENGLISH);
|
||||
final DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.ENGLISH);
|
||||
decimalFormat.setMaximumFractionDigits(10);
|
||||
decimalFormat.setMinimumFractionDigits(10);
|
||||
String stringValue = decimalFormat.format(value);
|
||||
|
@ -6,7 +6,6 @@ import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
import java.math.BigInteger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BtcValidator
|
||||
{
|
||||
@ -18,9 +17,9 @@ public class BtcValidator
|
||||
BtcValidator.params = params;
|
||||
}
|
||||
|
||||
public static boolean isMinSpendableAmount(@Nullable BigInteger amount)
|
||||
public static boolean isMinSpendableAmount(BigInteger amount)
|
||||
{
|
||||
return amount != null && amount.compareTo(FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT)) > 0;
|
||||
return amount != null && amount.compareTo(FeePolicy.TX_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT)) > 0;
|
||||
}
|
||||
|
||||
public boolean isAddressValid(String addressString)
|
||||
|
@ -2,17 +2,22 @@ package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.*;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.currency.Bitcoin;
|
||||
import java.math.BigInteger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FeePolicy
|
||||
{
|
||||
public static final BigInteger TX_FEE = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
|
||||
public static final BigInteger ACCOUNT_REGISTRATION_FEE = Utils.toNanoCoins("0.01");
|
||||
public static final BigInteger CREATE_OFFER_FEE = Utils.toNanoCoins("0.001");
|
||||
public static final BigInteger TAKE_OFFER_FEE = CREATE_OFFER_FEE;
|
||||
public static final BigInteger TX_FEE_depr = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
|
||||
public static final BigInteger ACCOUNT_REGISTRATION_FEE_depr = Utils.toNanoCoins("0.01");
|
||||
public static final BigInteger CREATE_OFFER_FEE_depr = Utils.toNanoCoins("0.001");
|
||||
public static final BigInteger TAKE_OFFER_FEE_depr = CREATE_OFFER_FEE_depr;
|
||||
|
||||
public static final Bitcoin TX_FEE = new Bitcoin(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE);
|
||||
public static final Bitcoin CREATE_OFFER_FEE = new Bitcoin(Utils.toNanoCoins("0.001"));
|
||||
public static final Bitcoin TAKE_OFFER_FEE = CREATE_OFFER_FEE;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FeePolicy.class);
|
||||
private static final String registrationFeeAddress = "mvkDXt4QmN4Nq9dRUsRigBCaovde9nLkZR";
|
||||
private static final String createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
||||
@ -27,7 +32,7 @@ public class FeePolicy
|
||||
}
|
||||
|
||||
//TODO other users or dev address? use donation option list? (dev, other users, wikileaks, tor, sub projects (bitcoinj, tomp2p,...)...)
|
||||
@Nullable
|
||||
|
||||
public Address getAddressForRegistrationFee()
|
||||
{
|
||||
try
|
||||
@ -41,7 +46,7 @@ public class FeePolicy
|
||||
}
|
||||
|
||||
//TODO get address form arbitrator list
|
||||
@Nullable
|
||||
|
||||
public Address getAddressForCreateOfferFee()
|
||||
{
|
||||
try
|
||||
@ -55,7 +60,7 @@ public class FeePolicy
|
||||
}
|
||||
|
||||
//TODO get address form the intersection of both traders arbitrator lists
|
||||
@Nullable
|
||||
|
||||
public Address getAddressForTakeOfferFee()
|
||||
{
|
||||
try
|
||||
|
@ -27,8 +27,6 @@ import java.util.stream.Collectors;
|
||||
import javafx.application.Platform;
|
||||
import javafx.util.Pair;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -49,7 +47,7 @@ public class WalletFacade
|
||||
|
||||
private final ReentrantLock lock = Threading.lock("lock");
|
||||
|
||||
@NotNull
|
||||
|
||||
private final String saveAddressEntryListId;
|
||||
private final NetworkParameters params;
|
||||
private final BitSquareWalletAppKit walletAppKit;
|
||||
@ -61,7 +59,7 @@ public class WalletFacade
|
||||
private final List<BalanceListener> balanceListeners = new ArrayList<>();
|
||||
private BitSquareWallet wallet;
|
||||
private WalletEventListener walletEventListener;
|
||||
@NotNull
|
||||
|
||||
@GuardedBy("lock")
|
||||
private List<AddressEntry> addressEntryList = new ArrayList<>();
|
||||
|
||||
@ -140,7 +138,7 @@ public class WalletFacade
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, @NotNull Transaction tx)
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||
{
|
||||
notifyConfidenceListeners(tx);
|
||||
}
|
||||
@ -253,23 +251,23 @@ public class WalletFacade
|
||||
return ImmutableList.copyOf(addressEntryList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public AddressEntry getRegistrationAddressInfo()
|
||||
{
|
||||
return getAddressInfoByAddressContext(AddressEntry.AddressContext.REGISTRATION_FEE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public AddressEntry getArbitratorDepositAddressInfo()
|
||||
{
|
||||
@Nullable AddressEntry arbitratorDepositAddressEntry = getAddressInfoByAddressContext(AddressEntry.AddressContext.ARBITRATOR_DEPOSIT);
|
||||
AddressEntry arbitratorDepositAddressEntry = getAddressInfoByAddressContext(AddressEntry.AddressContext.ARBITRATOR_DEPOSIT);
|
||||
if (arbitratorDepositAddressEntry == null)
|
||||
arbitratorDepositAddressEntry = getNewArbitratorDepositAddressEntry();
|
||||
|
||||
return arbitratorDepositAddressEntry;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
AddressEntry getUnusedTradeAddressInfo()
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null)));
|
||||
@ -280,8 +278,8 @@ public class WalletFacade
|
||||
return getNewTradeAddressEntry();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AddressEntry getAddressInfoByAddressContext(@NotNull AddressEntry.AddressContext addressContext)
|
||||
|
||||
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(ImmutableList.copyOf(addressEntryList), addressInfo -> (addressInfo != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext))));
|
||||
|
||||
@ -291,16 +289,16 @@ public class WalletFacade
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public AddressEntry getAddressInfoByTradeID(String tradeId)
|
||||
{
|
||||
for (@NotNull AddressEntry addressEntry : ImmutableList.copyOf(addressEntryList))
|
||||
for (AddressEntry addressEntry : ImmutableList.copyOf(addressEntryList))
|
||||
{
|
||||
if (addressEntry.getTradeId() != null && addressEntry.getTradeId().equals(tradeId))
|
||||
return addressEntry;
|
||||
}
|
||||
|
||||
@Nullable AddressEntry addressEntry = getUnusedTradeAddressInfo();
|
||||
AddressEntry addressEntry = getUnusedTradeAddressInfo();
|
||||
assert addressEntry != null;
|
||||
addressEntry.setTradeId(tradeId);
|
||||
return addressEntry;
|
||||
@ -311,18 +309,18 @@ public class WalletFacade
|
||||
// Create new AddressInfo objects
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public AddressEntry getNewTradeAddressEntry()
|
||||
{
|
||||
return getNewAddressEntry(AddressEntry.AddressContext.TRADE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private AddressEntry getNewAddressEntry(AddressEntry.AddressContext addressContext)
|
||||
{
|
||||
lock.lock();
|
||||
wallet.getLock().lock();
|
||||
@NotNull ECKey key = new ECKey();
|
||||
ECKey key = new ECKey();
|
||||
wallet.addKey(key);
|
||||
wallet.addWatchedAddress(key.toAddress(params));
|
||||
AddressEntry addressEntry = new AddressEntry(key, params, addressContext);
|
||||
@ -333,16 +331,16 @@ public class WalletFacade
|
||||
return addressEntry;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private AddressEntry getNewArbitratorDepositAddressEntry()
|
||||
{
|
||||
return getNewAddressEntry(AddressEntry.AddressContext.ARBITRATOR_DEPOSIT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
private AddressEntry getAddressEntryByAddressString(String address)
|
||||
{
|
||||
for (@NotNull AddressEntry addressEntry : addressEntryList)
|
||||
for (AddressEntry addressEntry : addressEntryList)
|
||||
{
|
||||
if (addressEntry.getAddressString().equals(address))
|
||||
return addressEntry;
|
||||
@ -354,10 +352,10 @@ public class WalletFacade
|
||||
// TransactionConfidence
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
public TransactionConfidence getConfidenceForAddress(@NotNull Address address)
|
||||
|
||||
public TransactionConfidence getConfidenceForAddress(Address address)
|
||||
{
|
||||
@NotNull List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
Set<Transaction> transactions = wallet.getTransactions(true);
|
||||
if (transactions != null)
|
||||
{
|
||||
@ -372,23 +370,23 @@ public class WalletFacade
|
||||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
private void notifyConfidenceListeners(@NotNull Transaction tx)
|
||||
private void notifyConfidenceListeners(Transaction tx)
|
||||
{
|
||||
for (@NotNull ConfidenceListener confidenceListener : confidenceListeners)
|
||||
for (ConfidenceListener confidenceListener : confidenceListeners)
|
||||
{
|
||||
@NotNull List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
transactionConfidenceList.add(getTransactionConfidence(tx, confidenceListener.getAddress()));
|
||||
|
||||
@Nullable TransactionConfidence transactionConfidence = getMostRecentConfidence(transactionConfidenceList);
|
||||
TransactionConfidence transactionConfidence = getMostRecentConfidence(transactionConfidenceList);
|
||||
confidenceListener.onTransactionConfidenceChanged(transactionConfidence);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TransactionConfidence getTransactionConfidence(@NotNull Transaction tx, @NotNull Address address)
|
||||
|
||||
private TransactionConfidence getTransactionConfidence(Transaction tx, Address address)
|
||||
{
|
||||
@NotNull List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
|
||||
@NotNull List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
|
||||
mergedOutputs.stream().filter(transactionOutput -> transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> {
|
||||
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
|
||||
@ -414,32 +412,32 @@ public class WalletFacade
|
||||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<TransactionOutput> getOutputsWithConnectedOutputs(@NotNull Transaction tx)
|
||||
|
||||
private List<TransactionOutput> getOutputsWithConnectedOutputs(Transaction tx)
|
||||
{
|
||||
List<TransactionOutput> transactionOutputs = tx.getOutputs();
|
||||
@NotNull List<TransactionOutput> connectedOutputs = new ArrayList<>();
|
||||
List<TransactionOutput> connectedOutputs = new ArrayList<>();
|
||||
|
||||
// add all connected outputs from any inputs as well
|
||||
List<TransactionInput> transactionInputs = tx.getInputs();
|
||||
for (@NotNull TransactionInput transactionInput : transactionInputs)
|
||||
for (TransactionInput transactionInput : transactionInputs)
|
||||
{
|
||||
@Nullable TransactionOutput transactionOutput = transactionInput.getConnectedOutput();
|
||||
TransactionOutput transactionOutput = transactionInput.getConnectedOutput();
|
||||
if (transactionOutput != null)
|
||||
connectedOutputs.add(transactionOutput);
|
||||
}
|
||||
|
||||
@NotNull List<TransactionOutput> mergedOutputs = new ArrayList<>();
|
||||
List<TransactionOutput> mergedOutputs = new ArrayList<>();
|
||||
mergedOutputs.addAll(transactionOutputs);
|
||||
mergedOutputs.addAll(connectedOutputs);
|
||||
return mergedOutputs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TransactionConfidence getMostRecentConfidence(@NotNull List<TransactionConfidence> transactionConfidenceList)
|
||||
|
||||
private TransactionConfidence getMostRecentConfidence(List<TransactionConfidence> transactionConfidenceList)
|
||||
{
|
||||
@Nullable TransactionConfidence transactionConfidence = null;
|
||||
for (@Nullable TransactionConfidence confidence : transactionConfidenceList)
|
||||
TransactionConfidence transactionConfidence = null;
|
||||
for (TransactionConfidence confidence : transactionConfidenceList)
|
||||
{
|
||||
if (confidence != null)
|
||||
{
|
||||
@ -460,7 +458,7 @@ public class WalletFacade
|
||||
|
||||
public boolean isRegistrationFeeConfirmed()
|
||||
{
|
||||
@Nullable TransactionConfidence transactionConfidence = null;
|
||||
TransactionConfidence transactionConfidence = null;
|
||||
if (getRegistrationAddressInfo() != null)
|
||||
transactionConfidence = getConfidenceForAddress(getRegistrationAddressInfo().getAddress());
|
||||
return transactionConfidence != null && transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING);
|
||||
@ -476,10 +474,10 @@ public class WalletFacade
|
||||
return getBalance(wallet.calculateAllSpendCandidates(true), address);
|
||||
}
|
||||
|
||||
private BigInteger getBalance(@NotNull LinkedList<TransactionOutput> transactionOutputs, Address address)
|
||||
private BigInteger getBalance(LinkedList<TransactionOutput> transactionOutputs, Address address)
|
||||
{
|
||||
BigInteger balance = BigInteger.ZERO;
|
||||
for (@NotNull TransactionOutput transactionOutput : transactionOutputs)
|
||||
for (TransactionOutput transactionOutput : transactionOutputs)
|
||||
{
|
||||
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH())
|
||||
{
|
||||
@ -495,7 +493,7 @@ public class WalletFacade
|
||||
|
||||
private void notifyBalanceListeners()
|
||||
{
|
||||
for (@NotNull BalanceListener balanceListener : balanceListeners)
|
||||
for (BalanceListener balanceListener : balanceListeners)
|
||||
{
|
||||
BigInteger balance;
|
||||
if (balanceListener.getAddress() != null)
|
||||
@ -529,21 +527,21 @@ public class WalletFacade
|
||||
|
||||
public boolean isRegistrationFeeBalanceSufficient()
|
||||
{
|
||||
return getRegistrationBalance().compareTo(FeePolicy.ACCOUNT_REGISTRATION_FEE) >= 0;
|
||||
return getRegistrationBalance().compareTo(FeePolicy.ACCOUNT_REGISTRATION_FEE_depr) >= 0;
|
||||
}
|
||||
|
||||
public boolean isUnusedTradeAddressBalanceAboveCreationFee()
|
||||
{
|
||||
@Nullable AddressEntry unUsedAddressEntry = getUnusedTradeAddressInfo();
|
||||
AddressEntry unUsedAddressEntry = getUnusedTradeAddressInfo();
|
||||
BigInteger unUsedAddressInfoBalance = getBalanceForAddress(unUsedAddressEntry.getAddress());
|
||||
return unUsedAddressInfoBalance.compareTo(FeePolicy.CREATE_OFFER_FEE) > 0;
|
||||
return unUsedAddressInfoBalance.compareTo(FeePolicy.CREATE_OFFER_FEE_depr) > 0;
|
||||
}
|
||||
|
||||
public boolean isUnusedTradeAddressBalanceAboveTakeOfferFee()
|
||||
{
|
||||
@Nullable AddressEntry unUsedAddressEntry = getUnusedTradeAddressInfo();
|
||||
AddressEntry unUsedAddressEntry = getUnusedTradeAddressInfo();
|
||||
BigInteger unUsedAddressInfoBalance = getBalanceForAddress(unUsedAddressEntry.getAddress());
|
||||
return unUsedAddressInfoBalance.compareTo(FeePolicy.TAKE_OFFER_FEE) > 0;
|
||||
return unUsedAddressInfoBalance.compareTo(FeePolicy.TAKE_OFFER_FEE_depr) > 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -565,17 +563,17 @@ public class WalletFacade
|
||||
// Transactions
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void payRegistrationFee(String stringifiedBankAccounts, @NotNull FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
public void payRegistrationFee(String stringifiedBankAccounts, FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
{
|
||||
log.debug("payRegistrationFee");
|
||||
log.trace("stringifiedBankAccounts " + stringifiedBankAccounts);
|
||||
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
Transaction tx = new Transaction(params);
|
||||
|
||||
byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData(getRegistrationAddressInfo().getKey(), stringifiedBankAccounts);
|
||||
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());
|
||||
|
||||
BigInteger fee = FeePolicy.ACCOUNT_REGISTRATION_FEE.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(FeePolicy.TX_FEE);
|
||||
BigInteger fee = FeePolicy.ACCOUNT_REGISTRATION_FEE_depr.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(FeePolicy.TX_FEE_depr);
|
||||
log.trace("fee: " + BtcFormatter.satoshiToString(fee));
|
||||
tx.addOutput(fee, feePolicy.getAddressForRegistrationFee());
|
||||
|
||||
@ -591,10 +589,10 @@ public class WalletFacade
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public String payCreateOfferFee(String offerId, @NotNull FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
public String payCreateOfferFee(String offerId, FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
{
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
BigInteger fee = FeePolicy.CREATE_OFFER_FEE.subtract(FeePolicy.TX_FEE);
|
||||
Transaction tx = new Transaction(params);
|
||||
BigInteger fee = FeePolicy.CREATE_OFFER_FEE_depr.subtract(FeePolicy.TX_FEE_depr);
|
||||
log.trace("fee: " + BtcFormatter.satoshiToString(fee));
|
||||
tx.addOutput(fee, feePolicy.getAddressForCreateOfferFee());
|
||||
|
||||
@ -612,10 +610,10 @@ public class WalletFacade
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public String payTakeOfferFee(String offerId, @NotNull FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
public String payTakeOfferFee(String offerId, FutureCallback<Transaction> callback) throws InsufficientMoneyException
|
||||
{
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
BigInteger fee = FeePolicy.TAKE_OFFER_FEE.subtract(FeePolicy.TX_FEE);
|
||||
Transaction tx = new Transaction(params);
|
||||
BigInteger fee = FeePolicy.TAKE_OFFER_FEE_depr.subtract(FeePolicy.TX_FEE_depr);
|
||||
log.trace("fee: " + BtcFormatter.satoshiToString(fee));
|
||||
tx.addOutput(fee, feePolicy.getAddressForTakeOfferFee());
|
||||
|
||||
@ -641,11 +639,11 @@ public class WalletFacade
|
||||
public String sendFunds(String withdrawFromAddress,
|
||||
String withdrawToAddress,
|
||||
String changeAddress,
|
||||
@NotNull BigInteger amount,
|
||||
@NotNull FutureCallback<Transaction> callback) throws AddressFormatException, InsufficientMoneyException, IllegalArgumentException
|
||||
BigInteger amount,
|
||||
FutureCallback<Transaction> callback) throws AddressFormatException, InsufficientMoneyException, IllegalArgumentException
|
||||
{
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
tx.addOutput(amount.subtract(FeePolicy.TX_FEE), new Address(params, withdrawToAddress));
|
||||
Transaction tx = new Transaction(params);
|
||||
tx.addOutput(amount.subtract(FeePolicy.TX_FEE_depr), new Address(params, withdrawToAddress));
|
||||
|
||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
||||
// we allow spending of unconfirmed tx (double spend risk is low and usability would suffer if we need to wait for 1 confirmation)
|
||||
@ -669,7 +667,7 @@ public class WalletFacade
|
||||
|
||||
// 1. step: deposit tx
|
||||
// Offerer creates the 2of3 multiSig deposit tx with his unsigned input and change output
|
||||
@NotNull
|
||||
|
||||
public Transaction offererCreatesMSTxAndAddPayment(BigInteger offererInputAmount, String offererPubKey, String takerPubKey, String arbitratorPubKey, String tradeId) throws InsufficientMoneyException
|
||||
{
|
||||
log.debug("offererCreatesMSTxAndAddPayment");
|
||||
@ -685,12 +683,12 @@ public class WalletFacade
|
||||
// We don't commit that tx to the wallet as it will be changed later and it's not signed yet.
|
||||
// So it will not change the wallet balance.
|
||||
// The btc tx fee will be included by the completeTx() call, so we don't need to add it manually.
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
Transaction tx = new Transaction(params);
|
||||
Script multiSigOutputScript = getMultiSigScript(offererPubKey, takerPubKey, arbitratorPubKey);
|
||||
tx.addOutput(offererInputAmount, multiSigOutputScript);
|
||||
|
||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
||||
@Nullable AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
||||
AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
||||
addressEntry.setTradeId(tradeId);
|
||||
// we allow spending of unconfirmed tx (double spend risk is low and usability would suffer if we need to wait for 1 confirmation)
|
||||
sendRequest.coinSelector = new AddressBasedCoinSelector(params, addressEntry, true);
|
||||
@ -720,7 +718,7 @@ public class WalletFacade
|
||||
|
||||
// 2. step: deposit tx
|
||||
// Taker adds his input and change output, changes the multiSig amount to the correct value and sign his input
|
||||
@NotNull
|
||||
|
||||
public Transaction takerAddPaymentAndSignTx(BigInteger takerInputAmount,
|
||||
BigInteger msOutputAmount,
|
||||
String offererPubKey,
|
||||
@ -745,12 +743,12 @@ public class WalletFacade
|
||||
// Both traders pay 1 times a fee, so it is equally split between them
|
||||
|
||||
// We do exactly the same as in the 1. step but with the takers input.
|
||||
@NotNull Transaction tempTx = new Transaction(params);
|
||||
Transaction tempTx = new Transaction(params);
|
||||
Script multiSigOutputScript = getMultiSigScript(offererPubKey, takerPubKey, arbitratorPubKey);
|
||||
tempTx.addOutput(takerInputAmount, multiSigOutputScript);
|
||||
|
||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tempTx);
|
||||
@Nullable AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
||||
AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
||||
addressEntry.setTradeId(tradeId);
|
||||
// we allow spending of unconfirmed tx (double spend risk is low and usability would suffer if we need to wait for 1 confirmation)
|
||||
sendRequest.coinSelector = new AddressBasedCoinSelector(params, addressEntry, true);
|
||||
@ -771,7 +769,7 @@ public class WalletFacade
|
||||
|
||||
|
||||
// Now we construct the real 2of3 multiSig tx from the serialized offerers tx
|
||||
@NotNull Transaction tx = new Transaction(params, Utils.parseAsHexOrBase58(offerersPartialDepositTxAsHex));
|
||||
Transaction tx = new Transaction(params, Utils.parseAsHexOrBase58(offerersPartialDepositTxAsHex));
|
||||
log.trace("offerersPartialDepositTx=" + tx);
|
||||
|
||||
// The serialized offerers tx looks like:
|
||||
@ -788,7 +786,7 @@ public class WalletFacade
|
||||
tx.addOutput(tempTx.getOutput(1));
|
||||
|
||||
// We add the btc tx fee to the msOutputAmount and apply the change to the multiSig output
|
||||
msOutputAmount = msOutputAmount.add(FeePolicy.TX_FEE);
|
||||
msOutputAmount = msOutputAmount.add(FeePolicy.TX_FEE_depr);
|
||||
tx.getOutput(0).setValue(msOutputAmount);
|
||||
|
||||
// Now we sign our input
|
||||
@ -797,10 +795,10 @@ public class WalletFacade
|
||||
log.error("input or input.getConnectedOutput() is null: " + input);
|
||||
|
||||
Script scriptPubKey = input.getConnectedOutput().getScriptPubKey();
|
||||
@Nullable ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
|
||||
ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
|
||||
Sha256Hash hash = tx.hashForSignature(1, scriptPubKey, Transaction.SigHash.ALL, false);
|
||||
ECKey.ECDSASignature ecSig = sigKey.sign(hash);
|
||||
@NotNull TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
|
||||
TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
|
||||
if (scriptPubKey.isSentToRawPubKey())
|
||||
input.setScriptSig(ScriptBuilder.createInputScript(txSig));
|
||||
else if (scriptPubKey.isSentToAddress())
|
||||
@ -836,14 +834,14 @@ public class WalletFacade
|
||||
|
||||
// 3. step: deposit tx
|
||||
// Offerer signs tx and publishes it
|
||||
@NotNull
|
||||
|
||||
public Transaction offererSignAndPublishTx(String offerersFirstTxAsHex,
|
||||
String takersSignedTxAsHex,
|
||||
String takersSignedConnOutAsHex,
|
||||
String takersSignedScriptSigAsHex,
|
||||
long offererTxOutIndex,
|
||||
long takerTxOutIndex,
|
||||
@NotNull FutureCallback<Transaction> callback)
|
||||
FutureCallback<Transaction> callback)
|
||||
{
|
||||
log.debug("offererSignAndPublishTx");
|
||||
log.trace("inputs: ");
|
||||
@ -854,32 +852,32 @@ public class WalletFacade
|
||||
log.trace("callback=" + callback);
|
||||
|
||||
// We create an empty tx (did not find a way to manipulate a tx input, otherwise the takers tx could be used directly and add the offerers input and output)
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
Transaction tx = new Transaction(params);
|
||||
|
||||
// offerers first tx
|
||||
@NotNull Transaction offerersFirstTx = new Transaction(params, Utils.parseAsHexOrBase58(offerersFirstTxAsHex));
|
||||
Transaction offerersFirstTx = new Transaction(params, Utils.parseAsHexOrBase58(offerersFirstTxAsHex));
|
||||
|
||||
printInputs("offerersFirstTx", offerersFirstTx);
|
||||
log.trace("offerersFirstTx = " + offerersFirstTx);
|
||||
|
||||
// add input
|
||||
@Nullable Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); // pass that around!
|
||||
@NotNull TransactionOutPoint offerersFirstTxOutPoint = new TransactionOutPoint(params, offererTxOutIndex, offerersFirstTxConnOut);
|
||||
Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); // pass that around!
|
||||
TransactionOutPoint offerersFirstTxOutPoint = new TransactionOutPoint(params, offererTxOutIndex, offerersFirstTxConnOut);
|
||||
//TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, offerersFirstTx.getInput(0).getScriptBytes(), offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array
|
||||
@NotNull TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array
|
||||
TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array
|
||||
offerersFirstTxInput.setParent(tx);
|
||||
tx.addInput(offerersFirstTxInput);
|
||||
|
||||
// takers signed tx
|
||||
@NotNull Transaction takersSignedTx = new Transaction(params, Utils.parseAsHexOrBase58(takersSignedTxAsHex));
|
||||
Transaction takersSignedTx = new Transaction(params, Utils.parseAsHexOrBase58(takersSignedTxAsHex));
|
||||
|
||||
printInputs("takersSignedTxInput", takersSignedTx);
|
||||
log.trace("takersSignedTx = " + takersSignedTx);
|
||||
|
||||
// add input
|
||||
@NotNull Transaction takersSignedTxConnOut = new Transaction(params, Utils.parseAsHexOrBase58(takersSignedConnOutAsHex));
|
||||
@NotNull TransactionOutPoint takersSignedTxOutPoint = new TransactionOutPoint(params, takerTxOutIndex, takersSignedTxConnOut);
|
||||
@NotNull TransactionInput takersSignedTxInput = new TransactionInput(params, tx, Utils.parseAsHexOrBase58(takersSignedScriptSigAsHex), takersSignedTxOutPoint);
|
||||
Transaction takersSignedTxConnOut = new Transaction(params, Utils.parseAsHexOrBase58(takersSignedConnOutAsHex));
|
||||
TransactionOutPoint takersSignedTxOutPoint = new TransactionOutPoint(params, takerTxOutIndex, takersSignedTxConnOut);
|
||||
TransactionInput takersSignedTxInput = new TransactionInput(params, tx, Utils.parseAsHexOrBase58(takersSignedScriptSigAsHex), takersSignedTxOutPoint);
|
||||
takersSignedTxInput.setParent(tx);
|
||||
tx.addInput(takersSignedTxInput);
|
||||
|
||||
@ -901,10 +899,10 @@ public class WalletFacade
|
||||
log.error("input or input.getConnectedOutput() is null: " + input);
|
||||
|
||||
Script scriptPubKey = input.getConnectedOutput().getScriptPubKey();
|
||||
@Nullable ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
|
||||
ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
|
||||
Sha256Hash hash = tx.hashForSignature(0, scriptPubKey, Transaction.SigHash.ALL, false);
|
||||
ECKey.ECDSASignature ecSig = sigKey.sign(hash);
|
||||
@NotNull TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
|
||||
TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
|
||||
if (scriptPubKey.isSentToRawPubKey())
|
||||
input.setScriptSig(ScriptBuilder.createInputScript(txSig));
|
||||
else if (scriptPubKey.isSentToAddress())
|
||||
@ -953,7 +951,7 @@ public class WalletFacade
|
||||
log.trace("takerCommitDepositTx");
|
||||
log.trace("inputs: ");
|
||||
log.trace("depositTxID=" + depositTxAsHex);
|
||||
@NotNull Transaction depositTx = new Transaction(params, Utils.parseAsHexOrBase58(depositTxAsHex));
|
||||
Transaction depositTx = new Transaction(params, Utils.parseAsHexOrBase58(depositTxAsHex));
|
||||
log.trace("depositTx=" + depositTx);
|
||||
// boolean isAlreadyInWallet = wallet.maybeCommitTx(depositTx);
|
||||
//log.trace("isAlreadyInWallet=" + isAlreadyInWallet);
|
||||
@ -973,7 +971,7 @@ public class WalletFacade
|
||||
}
|
||||
|
||||
// 5. step payout tx: Offerer creates payout tx and signs it
|
||||
@NotNull
|
||||
|
||||
public Pair<ECKey.ECDSASignature, String> offererCreatesAndSignsPayoutTx(String depositTxID,
|
||||
BigInteger offererPaybackAmount,
|
||||
BigInteger takerPaybackAmount,
|
||||
@ -988,19 +986,19 @@ public class WalletFacade
|
||||
log.trace("takerAddress=" + takerAddress);
|
||||
|
||||
// Offerer has published depositTx earlier, so he has it in his wallet
|
||||
@Nullable Transaction depositTx = wallet.getTransaction(new Sha256Hash(depositTxID));
|
||||
Transaction depositTx = wallet.getTransaction(new Sha256Hash(depositTxID));
|
||||
String depositTxAsHex = Utils.bytesToHexString(depositTx.bitcoinSerialize());
|
||||
|
||||
// We create the payout tx
|
||||
@NotNull Transaction tx = createPayoutTx(depositTxAsHex, offererPaybackAmount, takerPaybackAmount, getAddressInfoByTradeID(tradeID).getAddressString(), takerAddress);
|
||||
Transaction tx = createPayoutTx(depositTxAsHex, offererPaybackAmount, takerPaybackAmount, getAddressInfoByTradeID(tradeID).getAddressString(), takerAddress);
|
||||
|
||||
// We create the signature for that tx
|
||||
@Nullable TransactionOutput multiSigOutput = tx.getInput(0).getConnectedOutput();
|
||||
TransactionOutput multiSigOutput = tx.getInput(0).getConnectedOutput();
|
||||
Script multiSigScript = multiSigOutput.getScriptPubKey();
|
||||
Sha256Hash sigHash = tx.hashForSignature(0, multiSigScript, Transaction.SigHash.ALL, false);
|
||||
ECKey.ECDSASignature offererSignature = getAddressInfoByTradeID(tradeID).getKey().sign(sigHash);
|
||||
|
||||
@NotNull TransactionSignature offererTxSig = new TransactionSignature(offererSignature, Transaction.SigHash.ALL, false);
|
||||
TransactionSignature offererTxSig = new TransactionSignature(offererSignature, Transaction.SigHash.ALL, false);
|
||||
Script inputScript = ScriptBuilder.createMultiSigInputScript(ImmutableList.of(offererTxSig));
|
||||
tx.getInput(0).setScriptSig(inputScript);
|
||||
|
||||
@ -1010,7 +1008,7 @@ public class WalletFacade
|
||||
|
||||
// 6. step payout tx: Taker signs and publish tx
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
@NotNull
|
||||
|
||||
public Transaction takerSignsAndSendsTx(String depositTxAsHex,
|
||||
String offererSignatureR,
|
||||
String offererSignatureS,
|
||||
@ -1018,7 +1016,7 @@ public class WalletFacade
|
||||
BigInteger takerPaybackAmount,
|
||||
String offererAddress,
|
||||
String tradeID,
|
||||
@NotNull FutureCallback<Transaction> callback) throws AddressFormatException
|
||||
FutureCallback<Transaction> callback) throws AddressFormatException
|
||||
{
|
||||
log.debug("takerSignsAndSendsTx");
|
||||
log.trace("inputs: ");
|
||||
@ -1031,19 +1029,19 @@ public class WalletFacade
|
||||
log.trace("callback=" + callback);
|
||||
|
||||
// We create the payout tx
|
||||
@NotNull Transaction tx = createPayoutTx(depositTxAsHex, offererPaybackAmount, takerPaybackAmount, offererAddress, getAddressInfoByTradeID(tradeID).getAddressString());
|
||||
Transaction tx = createPayoutTx(depositTxAsHex, offererPaybackAmount, takerPaybackAmount, offererAddress, getAddressInfoByTradeID(tradeID).getAddressString());
|
||||
|
||||
// We sign that tx with our key and apply the signature form the offerer
|
||||
@Nullable TransactionOutput multiSigOutput = tx.getInput(0).getConnectedOutput();
|
||||
TransactionOutput multiSigOutput = tx.getInput(0).getConnectedOutput();
|
||||
Script multiSigScript = multiSigOutput.getScriptPubKey();
|
||||
Sha256Hash sigHash = tx.hashForSignature(0, multiSigScript, Transaction.SigHash.ALL, false);
|
||||
log.trace("sigHash=" + sigHash);
|
||||
|
||||
ECKey.ECDSASignature takerSignature = getAddressInfoByTradeID(tradeID).getKey().sign(sigHash);
|
||||
@NotNull TransactionSignature takerTxSig = new TransactionSignature(takerSignature, Transaction.SigHash.ALL, false);
|
||||
TransactionSignature takerTxSig = new TransactionSignature(takerSignature, Transaction.SigHash.ALL, false);
|
||||
|
||||
@NotNull ECKey.ECDSASignature offererSignature = new ECKey.ECDSASignature(new BigInteger(offererSignatureR), new BigInteger(offererSignatureS));
|
||||
@NotNull TransactionSignature offererTxSig = new TransactionSignature(offererSignature, Transaction.SigHash.ALL, false);
|
||||
ECKey.ECDSASignature offererSignature = new ECKey.ECDSASignature(new BigInteger(offererSignatureR), new BigInteger(offererSignatureS));
|
||||
TransactionSignature offererTxSig = new TransactionSignature(offererSignature, Transaction.SigHash.ALL, false);
|
||||
|
||||
Script inputScript = ScriptBuilder.createMultiSigInputScript(ImmutableList.of(offererTxSig, takerTxSig));
|
||||
tx.getInput(0).setScriptSig(inputScript);
|
||||
@ -1087,16 +1085,15 @@ public class WalletFacade
|
||||
|
||||
private Script getMultiSigScript(String offererPubKey, String takerPubKey, String arbitratorPubKey)
|
||||
{
|
||||
@NotNull ECKey offererKey = new ECKey(null, Utils.parseAsHexOrBase58(offererPubKey));
|
||||
@NotNull ECKey takerKey = new ECKey(null, Utils.parseAsHexOrBase58(takerPubKey));
|
||||
@NotNull ECKey arbitratorKey = new ECKey(null, Utils.parseAsHexOrBase58(arbitratorPubKey));
|
||||
ECKey offererKey = new ECKey(null, Utils.parseAsHexOrBase58(offererPubKey));
|
||||
ECKey takerKey = new ECKey(null, Utils.parseAsHexOrBase58(takerPubKey));
|
||||
ECKey arbitratorKey = new ECKey(null, Utils.parseAsHexOrBase58(arbitratorPubKey));
|
||||
|
||||
List<ECKey> keys = ImmutableList.of(offererKey, takerKey, arbitratorKey);
|
||||
return ScriptBuilder.createMultiSigOutputScript(2, keys);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private Transaction createPayoutTx(String depositTxAsHex,
|
||||
BigInteger offererPaybackAmount,
|
||||
BigInteger takerPaybackAmount,
|
||||
@ -1111,9 +1108,9 @@ public class WalletFacade
|
||||
log.trace("offererAddress=" + offererAddress);
|
||||
log.trace("takerAddress=" + takerAddress);
|
||||
|
||||
@NotNull Transaction depositTx = new Transaction(params, Utils.parseAsHexOrBase58(depositTxAsHex));
|
||||
Transaction depositTx = new Transaction(params, Utils.parseAsHexOrBase58(depositTxAsHex));
|
||||
TransactionOutput multiSigOutput = depositTx.getOutput(0);
|
||||
@NotNull Transaction tx = new Transaction(params);
|
||||
Transaction tx = new Transaction(params);
|
||||
tx.addInput(multiSigOutput);
|
||||
tx.addOutput(offererPaybackAmount, new Address(params, offererAddress));
|
||||
tx.addOutput(takerPaybackAmount, new Address(params, takerAddress));
|
||||
@ -1121,9 +1118,9 @@ public class WalletFacade
|
||||
return tx;
|
||||
}
|
||||
|
||||
private void printInputs(String tracePrefix, @NotNull Transaction tx)
|
||||
private void printInputs(String tracePrefix, Transaction tx)
|
||||
{
|
||||
for (@NotNull TransactionInput input : tx.getInputs())
|
||||
for (TransactionInput input : tx.getInputs())
|
||||
if (input.getConnectedOutput() != null)
|
||||
log.trace(tracePrefix + ": " + BtcFormatter.satoshiToString(input.getConnectedOutput().getValue()));
|
||||
else
|
||||
@ -1160,13 +1157,13 @@ public class WalletFacade
|
||||
|
||||
private void onProgressInUserThread(double percent, int blocksSoFar, final Date date)
|
||||
{
|
||||
for (@NotNull DownloadListener downloadListener : downloadListeners)
|
||||
for (DownloadListener downloadListener : downloadListeners)
|
||||
downloadListener.progress(percent);
|
||||
}
|
||||
|
||||
private void onDoneDownloadInUserThread()
|
||||
{
|
||||
for (@NotNull DownloadListener downloadListener : downloadListeners)
|
||||
for (DownloadListener downloadListener : downloadListeners)
|
||||
downloadListener.doneDownload();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.google.bitcoin.core.Utils;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Inject;
|
||||
import java.security.SignatureException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -23,13 +22,13 @@ public class CryptoFacade
|
||||
}
|
||||
|
||||
|
||||
public byte[] getEmbeddedAccountRegistrationData(@NotNull ECKey registrationKey, String stringifiedBankAccounts)
|
||||
public byte[] getEmbeddedAccountRegistrationData(ECKey registrationKey, String stringifiedBankAccounts)
|
||||
{
|
||||
String signedBankAccountIDs = registrationKey.signMessage(stringifiedBankAccounts);
|
||||
return Utils.sha256hash160(concatenateChunks(stringifiedBankAccounts, signedBankAccountIDs).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
public String signContract(@NotNull ECKey key, String contractAsJson)
|
||||
public String signContract(ECKey key, String contractAsJson)
|
||||
{
|
||||
return key.signMessage(contractAsJson);
|
||||
}
|
||||
@ -39,7 +38,7 @@ public class CryptoFacade
|
||||
{
|
||||
try
|
||||
{
|
||||
@NotNull ECKey key = new ECKey(null, pubKey, true);
|
||||
ECKey key = new ECKey(null, pubKey, true);
|
||||
key.verifyMessage(msg, sig);
|
||||
return true;
|
||||
} catch (SignatureException e)
|
||||
@ -56,11 +55,11 @@ public class CryptoFacade
|
||||
|
||||
private byte[] createHash(String msg, String sig)
|
||||
{
|
||||
@NotNull byte[] hashBytes = concatenateChunks(msg, sig).getBytes(Charsets.UTF_8);
|
||||
byte[] hashBytes = concatenateChunks(msg, sig).getBytes(Charsets.UTF_8);
|
||||
return Utils.sha256hash160(hashBytes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private String concatenateChunks(String stringifiedBankAccounts, String signedBankAccountIDs)
|
||||
{
|
||||
return stringifiedBankAccounts + signedBankAccountIDs;
|
||||
|
110
src/main/java/io/bitsquare/currency/Bitcoin.java
Normal file
110
src/main/java/io/bitsquare/currency/Bitcoin.java
Normal file
@ -0,0 +1,110 @@
|
||||
package io.bitsquare.currency;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Random;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Bitcoin extends BigInteger
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Bitcoin.class);
|
||||
private static final long serialVersionUID = 6436341706716520132L;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Bitcoin(BigInteger val)
|
||||
{
|
||||
super(val.toByteArray());
|
||||
}
|
||||
|
||||
public Bitcoin(byte[] val)
|
||||
{
|
||||
super(val);
|
||||
}
|
||||
|
||||
public Bitcoin(int signum, byte[] magnitude)
|
||||
{
|
||||
super(signum, magnitude);
|
||||
}
|
||||
|
||||
public Bitcoin(String val, int radix)
|
||||
{
|
||||
super(val, radix);
|
||||
}
|
||||
|
||||
public Bitcoin(String val)
|
||||
{
|
||||
super(val);
|
||||
}
|
||||
|
||||
public Bitcoin(int numBits, Random rnd)
|
||||
{
|
||||
super(numBits, rnd);
|
||||
}
|
||||
|
||||
public Bitcoin(int bitLength, int certainty, Random rnd)
|
||||
{
|
||||
super(bitLength, certainty, rnd);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public boolean isZero()
|
||||
{
|
||||
|
||||
return this.compareTo(BigInteger.ZERO) == 0;
|
||||
}
|
||||
|
||||
public boolean isMinValue()
|
||||
{
|
||||
|
||||
return this.compareTo(Transaction.MIN_NONDUST_OUTPUT) >= 0;
|
||||
}
|
||||
|
||||
public Bitcoin addBitcoin(Bitcoin other)
|
||||
{
|
||||
return new Bitcoin(this.add(other));
|
||||
}
|
||||
|
||||
public Bitcoin subtractBitcoin(Bitcoin other)
|
||||
{
|
||||
return new Bitcoin(this.subtract(other));
|
||||
}
|
||||
|
||||
public Bitcoin multiplyBitcoin(Bitcoin other)
|
||||
{
|
||||
return new Bitcoin(this.multiply(other));
|
||||
}
|
||||
|
||||
public boolean isLarger(Bitcoin other)
|
||||
{
|
||||
|
||||
return this.compareTo(other) > 0;
|
||||
}
|
||||
|
||||
public boolean isLess(Bitcoin other)
|
||||
{
|
||||
|
||||
return this.compareTo(other) < 0;
|
||||
}
|
||||
|
||||
public boolean isEqual(Bitcoin other)
|
||||
{
|
||||
|
||||
return this.compareTo(other) == 0;
|
||||
}
|
||||
|
||||
public String getFormattedValue()
|
||||
{
|
||||
return BtcFormatter.satoshiToString(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
51
src/main/java/io/bitsquare/currency/Fiat.java
Normal file
51
src/main/java/io/bitsquare/currency/Fiat.java
Normal file
@ -0,0 +1,51 @@
|
||||
package io.bitsquare.currency;
|
||||
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Fiat
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Fiat.class);
|
||||
private double value;
|
||||
private Currency currency;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Fiat(double value)
|
||||
{
|
||||
this.value = value;
|
||||
this.currency = Currency.getInstance(Locale.getDefault());
|
||||
}
|
||||
|
||||
public Fiat(double value, Currency currency)
|
||||
{
|
||||
this.value = value;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getFormattedValue()
|
||||
{
|
||||
return BitSquareFormatter.formatPrice(value);
|
||||
}
|
||||
|
||||
public String getCurrencyCode()
|
||||
{
|
||||
return currency.getCurrencyCode();
|
||||
}
|
||||
|
||||
public Currency getCurrency()
|
||||
{
|
||||
return currency;
|
||||
}
|
||||
}
|
@ -23,8 +23,6 @@ import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BitSquareModule extends AbstractModule
|
||||
{
|
||||
@ -67,7 +65,7 @@ class BitSquareWalletAppKitProvider implements Provider<BitSquareWalletAppKit>
|
||||
this.networkParameters = networkParameters;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public BitSquareWalletAppKit get()
|
||||
{
|
||||
return new BitSquareWalletAppKit(networkParameters, FileUtil.getRootDirectory());
|
||||
@ -84,10 +82,10 @@ class NetworkParametersProvider implements Provider<NetworkParameters>
|
||||
this.networkType = networkType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public NetworkParameters get()
|
||||
{
|
||||
@Nullable NetworkParameters result = null;
|
||||
NetworkParameters result = null;
|
||||
|
||||
switch (networkType)
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ import com.google.inject.Injector;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Guice support for fxml controllers
|
||||
@ -12,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class GuiceFXMLLoader extends FXMLLoader
|
||||
{
|
||||
|
||||
@Nullable
|
||||
|
||||
private static Injector injector = null;
|
||||
|
||||
// not used yet
|
||||
@ -41,7 +40,7 @@ public class GuiceFXMLLoader extends FXMLLoader
|
||||
}
|
||||
|
||||
|
||||
public static void setInjector(@Nullable Injector injector)
|
||||
public static void setInjector(Injector injector)
|
||||
{
|
||||
GuiceFXMLLoader.injector = injector;
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ChildController
|
||||
{
|
||||
void setNavigationController(@NotNull NavigationController navigationController);
|
||||
void setNavigationController(NavigationController navigationController);
|
||||
|
||||
void cleanup();
|
||||
}
|
||||
|
@ -36,8 +36,6 @@ import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -53,7 +51,7 @@ public class MainController implements Initializable, NavigationController
|
||||
private final Storage storage;
|
||||
private final ToggleGroup toggleGroup = new ToggleGroup();
|
||||
|
||||
@Nullable
|
||||
|
||||
private ChildController childController;
|
||||
private ToggleButton prevToggleButton;
|
||||
private Image prevToggleButtonIcon;
|
||||
@ -94,7 +92,7 @@ public class MainController implements Initializable, NavigationController
|
||||
// Static
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public static MainController INSTANCE()
|
||||
{
|
||||
return mainController;
|
||||
@ -116,9 +114,9 @@ public class MainController implements Initializable, NavigationController
|
||||
// Interface implementation: NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
switch (navigationItem)
|
||||
{
|
||||
@ -147,8 +145,8 @@ public class MainController implements Initializable, NavigationController
|
||||
return childController;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ChildController loadView(@NotNull NavigationItem navigationItem)
|
||||
|
||||
private ChildController loadView(NavigationItem navigationItem)
|
||||
{
|
||||
if (childController != null)
|
||||
childController.cleanup();
|
||||
@ -211,7 +209,7 @@ public class MainController implements Initializable, NavigationController
|
||||
}
|
||||
|
||||
|
||||
private void showTakeOfferRequest(@NotNull TradeMessage tradeMessage, @NotNull PeerAddress sender)
|
||||
private void showTakeOfferRequest(TradeMessage tradeMessage, PeerAddress sender)
|
||||
{
|
||||
trading.createOffererPaymentProtocol(tradeMessage, sender);
|
||||
final Button alertButton = new Button("", Icons.getIconImageView(Icons.MSG_ALERT));
|
||||
@ -246,8 +244,8 @@ public class MainController implements Initializable, NavigationController
|
||||
settingsButton = addNavButton(rightNavPane, "Settings", NavigationItem.SETTINGS);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ToggleButton addNavButton(@NotNull Pane parent, @NotNull String title, @NotNull NavigationItem navigationItem)
|
||||
|
||||
private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem)
|
||||
{
|
||||
final Pane pane = new Pane();
|
||||
pane.setPrefSize(50, 50);
|
||||
@ -285,7 +283,7 @@ public class MainController implements Initializable, NavigationController
|
||||
return toggleButton;
|
||||
}
|
||||
|
||||
private void addBalanceInfo(@NotNull Pane parent)
|
||||
private void addBalanceInfo(Pane parent)
|
||||
{
|
||||
final TextField balanceTextField = new TextField();
|
||||
balanceTextField.setEditable(false);
|
||||
@ -320,7 +318,7 @@ public class MainController implements Initializable, NavigationController
|
||||
parent.getChildren().add(vBox);
|
||||
}
|
||||
|
||||
private void addAccountComboBox(@NotNull Pane parent)
|
||||
private void addAccountComboBox(Pane parent)
|
||||
{
|
||||
if (user.getBankAccounts().size() > 1)
|
||||
{
|
||||
@ -330,14 +328,14 @@ public class MainController implements Initializable, NavigationController
|
||||
accountComboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue));
|
||||
accountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull BankAccount bankAccount)
|
||||
public String toString(BankAccount bankAccount)
|
||||
{
|
||||
return bankAccount.getAccountTitle();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public BankAccount fromString(String s)
|
||||
{
|
||||
|
@ -1,10 +1,7 @@
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface NavigationController
|
||||
{
|
||||
@Nullable
|
||||
ChildController navigateToView(@NotNull NavigationItem navigationItem);
|
||||
|
||||
ChildController navigateToView(NavigationItem navigationItem);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public enum NavigationItem
|
||||
|
||||
ORDER_BOOK("/io/bitsquare/gui/market/orderbook/OrderBookView.fxml"),
|
||||
CREATE_OFFER("/io/bitsquare/gui/market/createOffer/CreateOfferView.fxml"),
|
||||
TAKER_TRADE("/io/bitsquare/gui/market/trade/TakerTradeView.fxml"),
|
||||
TAKE_OFFER("/io/bitsquare/gui/market/trade/TakeOfferView.fxml"),
|
||||
//OFFERER_TRADE("/io/bitsquare/gui/orders/OffererTradeView.fxml"),
|
||||
|
||||
OFFER("/io/bitsquare/gui/orders/offer/OfferView.fxml"),
|
||||
|
@ -29,15 +29,13 @@ import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings({"ALL", "UnusedParameters"})
|
||||
public class ArbitratorOverviewController implements Initializable, ChildController, NavigationController, ArbitratorListener
|
||||
{
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
@NotNull
|
||||
|
||||
private final MessageFacade messageFacade;
|
||||
private final List<Arbitrator> allArbitrators = new ArrayList<>();
|
||||
private Arbitrator currentArbitrator;
|
||||
@ -57,7 +55,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorOverviewController(Settings settings, Storage storage, @NotNull MessageFacade messageFacade)
|
||||
public ArbitratorOverviewController(Settings settings, Storage storage, MessageFacade messageFacade)
|
||||
{
|
||||
|
||||
this.settings = settings;
|
||||
@ -86,7 +84,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
@ -102,14 +100,14 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
// Interface implementation: NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
if (arbitratorProfileController != null)
|
||||
arbitratorProfileController.cleanup();
|
||||
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
try
|
||||
{
|
||||
final Node view = loader.load();
|
||||
@ -136,23 +134,23 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArbitratorsReceived(@Nullable Map<Number160, Data> dataMap, boolean success)
|
||||
public void onArbitratorsReceived(Map<Number160, Data> dataMap, boolean success)
|
||||
{
|
||||
if (success && dataMap != null)
|
||||
{
|
||||
allArbitrators.clear();
|
||||
|
||||
for (@NotNull Data arbitratorData : dataMap.values())
|
||||
for (Data arbitratorData : dataMap.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
Object arbitratorDataObject = arbitratorData.getObject();
|
||||
if (arbitratorDataObject instanceof Arbitrator)
|
||||
{
|
||||
@NotNull Arbitrator arbitrator = (Arbitrator) arbitratorDataObject;
|
||||
Arbitrator arbitrator = (Arbitrator) arbitratorDataObject;
|
||||
allArbitrators.add(arbitrator);
|
||||
}
|
||||
} catch (@NotNull ClassNotFoundException | IOException e)
|
||||
} catch (ClassNotFoundException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -216,7 +214,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
@FXML
|
||||
public void onClose(ActionEvent actionEvent)
|
||||
{
|
||||
@NotNull Stage stage = (Stage) rootContainer.getScene().getWindow();
|
||||
Stage stage = (Stage) rootContainer.getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,13 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class ArbitratorProfileController implements Initializable, ChildController
|
||||
{
|
||||
@NotNull
|
||||
|
||||
private final Settings settings;
|
||||
@NotNull
|
||||
|
||||
private final Storage storage;
|
||||
private Arbitrator arbitrator;
|
||||
private NavigationController navigationController;
|
||||
@ -41,12 +39,12 @@ public class ArbitratorProfileController implements Initializable, ChildControll
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorProfileController(@NotNull Settings settings, @NotNull Storage storage)
|
||||
public ArbitratorProfileController(Settings settings, Storage storage)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.storage = storage;
|
||||
|
||||
// @NotNull Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
|
||||
// Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
|
||||
// settings.updateFromStorage(savedSettings);
|
||||
}
|
||||
|
||||
@ -55,11 +53,11 @@ public class ArbitratorProfileController implements Initializable, ChildControll
|
||||
// Public Methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void applyArbitrator(@Nullable Arbitrator arbitrator)
|
||||
public void applyArbitrator(Arbitrator arbitrator)
|
||||
{
|
||||
if (arbitrator != null)
|
||||
{
|
||||
@NotNull String name = "";
|
||||
String name = "";
|
||||
switch (arbitrator.getIdType())
|
||||
{
|
||||
case REAL_LIFE_ID:
|
||||
@ -102,7 +100,7 @@ public class ArbitratorProfileController implements Initializable, ChildControll
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -54,11 +52,11 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
private Arbitrator arbitrator = new Arbitrator();
|
||||
private ArbitratorProfileController arbitratorProfileController;
|
||||
private boolean isEditMode;
|
||||
@NotNull
|
||||
|
||||
private List<Locale> languageList = new ArrayList<>();
|
||||
@NotNull
|
||||
|
||||
private List<Arbitrator.METHOD> methodList = new ArrayList<>();
|
||||
@NotNull
|
||||
|
||||
private List<Arbitrator.ID_VERIFICATION> idVerificationList = new ArrayList<>();
|
||||
private Arbitrator.ID_TYPE idType;
|
||||
private ConfidenceDisplay confidenceDisplay;
|
||||
@ -145,12 +143,12 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
languageComboBox.setConverter(new StringConverter<Locale>()
|
||||
{
|
||||
@Override
|
||||
public String toString(@NotNull Locale locale)
|
||||
public String toString(Locale locale)
|
||||
{
|
||||
return locale.getDisplayLanguage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Locale fromString(String s)
|
||||
{
|
||||
@ -161,14 +159,14 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
idTypeComboBox.setItems(FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator.ID_TYPE.class))));
|
||||
idTypeComboBox.setConverter(new StringConverter<Arbitrator.ID_TYPE>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Arbitrator.ID_TYPE item)
|
||||
public String toString(Arbitrator.ID_TYPE item)
|
||||
{
|
||||
return Localisation.get(item.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Arbitrator.ID_TYPE fromString(String s)
|
||||
{
|
||||
@ -179,14 +177,14 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
methodsComboBox.setItems(FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator.METHOD.class))));
|
||||
methodsComboBox.setConverter(new StringConverter<Arbitrator.METHOD>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Arbitrator.METHOD item)
|
||||
public String toString(Arbitrator.METHOD item)
|
||||
{
|
||||
return Localisation.get(item.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Arbitrator.METHOD fromString(String s)
|
||||
{
|
||||
@ -197,14 +195,14 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
idVerificationsComboBox.setItems(FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator.ID_VERIFICATION.class))));
|
||||
idVerificationsComboBox.setConverter(new StringConverter<Arbitrator.ID_VERIFICATION>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Arbitrator.ID_VERIFICATION item)
|
||||
public String toString(Arbitrator.ID_VERIFICATION item)
|
||||
{
|
||||
return Localisation.get(item.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Arbitrator.ID_VERIFICATION fromString(String s)
|
||||
{
|
||||
@ -219,7 +217,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@ -241,7 +239,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
{
|
||||
idTypeTextField.setText(Localisation.get(idType.toString()));
|
||||
|
||||
@NotNull String name = "";
|
||||
String name = "";
|
||||
switch (idType)
|
||||
{
|
||||
case REAL_LIFE_ID:
|
||||
@ -377,7 +375,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
@NotNull ClipboardContent content = new ClipboardContent();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(collateralAddress);
|
||||
clipboard.setContent(content);
|
||||
});
|
||||
@ -388,7 +386,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
walletFacade.getWallet().addEventListener(new WalletEventListener()
|
||||
{
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, @NotNull BigInteger newBalance)
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||
{
|
||||
paymentDoneButton.setDisable(newBalance.compareTo(BigInteger.ZERO) == 0);
|
||||
}
|
||||
@ -429,7 +427,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
{
|
||||
if (arbitrator != null)
|
||||
{
|
||||
@NotNull String name = "";
|
||||
String name = "";
|
||||
switch (arbitrator.getIdType())
|
||||
{
|
||||
case REAL_LIFE_ID:
|
||||
@ -464,7 +462,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
private Arbitrator getEditedArbitrator()
|
||||
{
|
||||
try
|
||||
@ -508,7 +506,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
|
||||
private void close()
|
||||
{
|
||||
@NotNull Stage stage = (Stage) rootContainer.getScene().getWindow();
|
||||
Stage stage = (Stage) rootContainer.getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,6 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.SingleSelectionModel;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LazyLoadingTabPane extends TabPane
|
||||
{
|
||||
@ -37,7 +35,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
super();
|
||||
}
|
||||
|
||||
public void initialize(@NotNull NavigationController navigationController, @NotNull Storage storage, @NotNull String... tabContentFXMLUrls)
|
||||
public void initialize(NavigationController navigationController, Storage storage, String... tabContentFXMLUrls)
|
||||
{
|
||||
if (tabContentFXMLUrls.length == 0)
|
||||
throw new IllegalArgumentException("No tabContentFXMLUrls defined");
|
||||
@ -65,7 +63,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
childController.cleanup();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public ChildController navigateToView(String fxmlView)
|
||||
{
|
||||
for (int i = 0; i < tabContentFXMLUrls.length; i++)
|
||||
@ -88,7 +86,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
if (childController != null)
|
||||
((Hibernate) childController).sleep();
|
||||
|
||||
@Nullable Node view = null;
|
||||
Node view = null;
|
||||
if (index < views.size())
|
||||
{
|
||||
view = views.get(index);
|
||||
@ -97,7 +95,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
if (view == null)
|
||||
{
|
||||
String fxmlView = tabContentFXMLUrls[index];
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(fxmlView), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(fxmlView), Localisation.getResourceBundle());
|
||||
try
|
||||
{
|
||||
view = loader.load();
|
||||
|
@ -6,13 +6,12 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.util.Duration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NetworkSyncPane extends HBox
|
||||
{
|
||||
@NotNull
|
||||
|
||||
private final ProgressBar networkSyncProgressBar;
|
||||
@NotNull
|
||||
|
||||
private final Label networkSyncInfoLabel;
|
||||
|
||||
public NetworkSyncPane()
|
||||
@ -37,7 +36,7 @@ public class NetworkSyncPane extends HBox
|
||||
networkSyncInfoLabel.setText("Sync with network: Done");
|
||||
networkSyncProgressBar.setProgress(1);
|
||||
|
||||
@NotNull FadeTransition fade = new FadeTransition(Duration.millis(700), this);
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(700), this);
|
||||
fade.setToValue(0.0);
|
||||
fade.setCycleCount(1);
|
||||
fade.setInterpolator(Interpolator.EASE_BOTH);
|
||||
|
@ -34,7 +34,6 @@ import javafx.css.PseudoClass;
|
||||
import javafx.css.StyleableProperty;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
@ -177,14 +176,14 @@ public class ConfidenceProgressIndicator extends Control
|
||||
pseudoClassStateChanged(PSEUDO_CLASS_DETERMINATE, !active);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Object getBean()
|
||||
{
|
||||
return ConfidenceProgressIndicator.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@ -233,14 +232,14 @@ public class ConfidenceProgressIndicator extends Control
|
||||
setIndeterminate(getProgress() < 0.0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Object getBean()
|
||||
{
|
||||
return ConfidenceProgressIndicator.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@ -254,7 +253,7 @@ public class ConfidenceProgressIndicator extends Control
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin()
|
||||
{
|
||||
|
@ -59,8 +59,6 @@ import javafx.scene.shape.ArcType;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.util.Duration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "SameReturnValue"})
|
||||
public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<ConfidenceProgressIndicator, ConfidenceProgressIndicatorBehavior<ConfidenceProgressIndicator>>
|
||||
@ -84,12 +82,12 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
doneText.getStyleClass().add("text");
|
||||
} */
|
||||
|
||||
@Nullable
|
||||
|
||||
private IndeterminateSpinner spinner;
|
||||
/**
|
||||
* The number of segments in the spinner.
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
private final IntegerProperty indeterminateSegmentCount =
|
||||
new StyleableIntegerProperty(8)
|
||||
{
|
||||
@ -100,21 +98,21 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
if (spinner != null) spinner.rebuild();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Object getBean()
|
||||
{
|
||||
return ConfidenceProgressIndicatorSkin.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "indeterminateSegmentCount";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public CssMetaData<ConfidenceProgressIndicator, Number> getCssMetaData()
|
||||
{
|
||||
@ -124,7 +122,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
/**
|
||||
* True if the progress indicator should rotate as well as animate opacity.
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
private final BooleanProperty spinEnabled = new StyleableBooleanProperty(false)
|
||||
{
|
||||
@Override
|
||||
@ -133,33 +131,33 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
if (spinner != null) spinner.setSpinEnabled(get());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public CssMetaData<ConfidenceProgressIndicator, Boolean> getCssMetaData()
|
||||
{
|
||||
return StyleableProperties.SPIN_ENABLED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Object getBean()
|
||||
{
|
||||
return ConfidenceProgressIndicatorSkin.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "spinEnabled";
|
||||
}
|
||||
};
|
||||
@Nullable
|
||||
|
||||
private DeterminateIndicator determinateIndicator;
|
||||
/**
|
||||
* The colour of the progress segment.
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
private final ObjectProperty<Paint> progressColor =
|
||||
new StyleableObjectProperty<Paint>(null)
|
||||
{
|
||||
@ -167,7 +165,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
@Override
|
||||
public void set(Paint newProgressColor)
|
||||
{
|
||||
@Nullable final Paint color = (newProgressColor instanceof Color)
|
||||
final Paint color = (newProgressColor instanceof Color)
|
||||
? newProgressColor
|
||||
: null;
|
||||
super.set(color);
|
||||
@ -180,21 +178,21 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
if (determinateIndicator != null) determinateIndicator.setFillOverride(get());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Object getBean()
|
||||
{
|
||||
return ConfidenceProgressIndicatorSkin.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "progressColorProperty";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public CssMetaData<ConfidenceProgressIndicator, Paint> getCssMetaData()
|
||||
{
|
||||
@ -211,14 +209,14 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
* ************************************************************************
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public ConfidenceProgressIndicatorSkin(@NotNull ConfidenceProgressIndicator control)
|
||||
public ConfidenceProgressIndicatorSkin(ConfidenceProgressIndicator control)
|
||||
{
|
||||
super(control, new ConfidenceProgressIndicatorBehavior<>(control));
|
||||
|
||||
@NotNull InvalidationListener indeterminateListener = valueModel -> initialize();
|
||||
InvalidationListener indeterminateListener = valueModel -> initialize();
|
||||
control.indeterminateProperty().addListener(indeterminateListener);
|
||||
|
||||
@NotNull InvalidationListener visibilityListener = new InvalidationListener()
|
||||
InvalidationListener visibilityListener = new InvalidationListener()
|
||||
{
|
||||
@Override
|
||||
public void invalidated(Observable valueModel)
|
||||
@ -249,7 +247,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
control.visibleProperty().addListener(visibilityListener);
|
||||
control.parentProperty().addListener(visibilityListener);
|
||||
|
||||
@NotNull InvalidationListener sceneListener = new InvalidationListener()
|
||||
InvalidationListener sceneListener = new InvalidationListener()
|
||||
{
|
||||
@Override
|
||||
public void invalidated(Observable valueModel)
|
||||
@ -384,25 +382,25 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
//private double textGap = 2.0F;
|
||||
|
||||
@NotNull
|
||||
|
||||
private final ConfidenceProgressIndicator control;
|
||||
//private Text text;
|
||||
@NotNull
|
||||
|
||||
private final StackPane indicator;
|
||||
@NotNull
|
||||
|
||||
private final StackPane progress;
|
||||
@NotNull
|
||||
|
||||
private final StackPane tick;
|
||||
@NotNull
|
||||
|
||||
private final Arc arcShape;
|
||||
@NotNull
|
||||
|
||||
private final Circle indicatorCircle;
|
||||
// only update progress text on whole percentages
|
||||
private int intProgress;
|
||||
// only update pie arc to nearest degree
|
||||
private int degProgress;
|
||||
|
||||
public DeterminateIndicator(@NotNull ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, Paint fillOverride)
|
||||
public DeterminateIndicator(ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, Paint fillOverride)
|
||||
{
|
||||
this.control = control;
|
||||
|
||||
@ -411,7 +409,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
intProgress = (int) Math.round(control.getProgress() * 100.0);
|
||||
degProgress = (int) (360 * control.getProgress());
|
||||
|
||||
@NotNull InvalidationListener progressListener = valueModel -> updateProgress();
|
||||
InvalidationListener progressListener = valueModel -> updateProgress();
|
||||
control.progressProperty().addListener(progressListener);
|
||||
|
||||
getChildren().clear();
|
||||
@ -454,7 +452,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
if (fillOverride instanceof Color)
|
||||
{
|
||||
@NotNull Color c = (Color) fillOverride;
|
||||
Color c = (Color) fillOverride;
|
||||
progress.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + c.getOpacity() + ");");
|
||||
}
|
||||
else
|
||||
@ -631,16 +629,16 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
private final ConfidenceProgressIndicator control;
|
||||
private final ConfidenceProgressIndicatorSkin skin;
|
||||
@NotNull
|
||||
|
||||
private final IndicatorPaths pathsG;
|
||||
@NotNull
|
||||
|
||||
private final Timeline indeterminateTimeline;
|
||||
private final List<Double> opacities = new ArrayList<>();
|
||||
private boolean spinEnabled = false;
|
||||
@Nullable
|
||||
|
||||
private Paint fillOverride = null;
|
||||
|
||||
public IndeterminateSpinner(ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, boolean spinEnabled, @Nullable Paint fillOverride)
|
||||
public IndeterminateSpinner(ConfidenceProgressIndicator control, ConfidenceProgressIndicatorSkin s, boolean spinEnabled, Paint fillOverride)
|
||||
{
|
||||
this.control = control;
|
||||
this.skin = s;
|
||||
@ -660,7 +658,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public void setFillOverride(@Nullable Paint fillOverride)
|
||||
public void setFillOverride(Paint fillOverride)
|
||||
{
|
||||
this.fillOverride = fillOverride;
|
||||
rebuild();
|
||||
@ -732,13 +730,13 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
final double step = 0.8 / (segments - 1);
|
||||
for (int i = 0; i < segments; i++)
|
||||
{
|
||||
@NotNull Region region = new Region();
|
||||
Region region = new Region();
|
||||
region.setScaleShape(false);
|
||||
region.setCenterShape(false);
|
||||
region.getStyleClass().addAll("segment", "segment" + i);
|
||||
if (fillOverride instanceof Color)
|
||||
{
|
||||
@NotNull Color c = (Color) fillOverride;
|
||||
Color c = (Color) fillOverride;
|
||||
region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + c.getOpacity() + ");");
|
||||
}
|
||||
else
|
||||
@ -770,7 +768,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
super();
|
||||
piSkin = pi;
|
||||
@NotNull InvalidationListener treeVisibilityListener = valueModel -> {
|
||||
InvalidationListener treeVisibilityListener = valueModel -> {
|
||||
if (piSkin.skin.getSkinnable().impl_isTreeVisible())
|
||||
{
|
||||
piSkin.pauseIndicator(false);
|
||||
@ -791,7 +789,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
if (child instanceof Region)
|
||||
{
|
||||
@NotNull Region region = (Region) child;
|
||||
Region region = (Region) child;
|
||||
if (region.getShape() != null)
|
||||
{
|
||||
w = Math.max(w, region.getShape().getLayoutBounds().getMaxX());
|
||||
@ -813,7 +811,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
{
|
||||
if (child instanceof Region)
|
||||
{
|
||||
@NotNull Region region = (Region) child;
|
||||
Region region = (Region) child;
|
||||
if (region.getShape() != null)
|
||||
{
|
||||
h = Math.max(h, region.getShape().getLayoutBounds().getMaxY());
|
||||
@ -833,7 +831,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
// calculate scale
|
||||
double scale = getWidth() / computePrefWidth(-1);
|
||||
getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
|
||||
@NotNull Region region = (Region) child;
|
||||
Region region = (Region) child;
|
||||
if (region.getShape() != null)
|
||||
{
|
||||
region.resize(
|
||||
@ -858,82 +856,82 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
|
||||
private static class StyleableProperties
|
||||
{
|
||||
public static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
||||
@Nullable
|
||||
|
||||
private static final CssMetaData<ConfidenceProgressIndicator, Paint> PROGRESS_COLOR =
|
||||
new CssMetaData<ConfidenceProgressIndicator, Paint>("-fx-progress-color",
|
||||
PaintConverter.getInstance(), null)
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isSettable(@NotNull ConfidenceProgressIndicator n)
|
||||
public boolean isSettable(ConfidenceProgressIndicator n)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
return skin.progressColor == null ||
|
||||
!skin.progressColor.isBound();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Paint> getStyleableProperty(@NotNull ConfidenceProgressIndicator n)
|
||||
public StyleableProperty<Paint> getStyleableProperty(ConfidenceProgressIndicator n)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
return (StyleableProperty<Paint>) skin.progressColor;
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
|
||||
private static final CssMetaData<ConfidenceProgressIndicator, Number> INDETERMINATE_SEGMENT_COUNT =
|
||||
new CssMetaData<ConfidenceProgressIndicator, Number>("-fx-indeterminate-segment-count",
|
||||
SizeConverter.getInstance(), 8)
|
||||
{
|
||||
|
||||
@Override
|
||||
public void set(ConfidenceProgressIndicator node, @NotNull Number value, StyleOrigin origin)
|
||||
public void set(ConfidenceProgressIndicator node, Number value, StyleOrigin origin)
|
||||
{
|
||||
super.set(node, value.intValue(), origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSettable(@NotNull ConfidenceProgressIndicator n)
|
||||
public boolean isSettable(ConfidenceProgressIndicator n)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
return skin.indeterminateSegmentCount == null ||
|
||||
!skin.indeterminateSegmentCount.isBound();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Number> getStyleableProperty(@NotNull ConfidenceProgressIndicator n)
|
||||
public StyleableProperty<Number> getStyleableProperty(ConfidenceProgressIndicator n)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin();
|
||||
return (StyleableProperty<Number>) skin.indeterminateSegmentCount;
|
||||
}
|
||||
};
|
||||
@Nullable
|
||||
|
||||
private static final CssMetaData<ConfidenceProgressIndicator, Boolean> SPIN_ENABLED =
|
||||
new CssMetaData<ConfidenceProgressIndicator, Boolean>("-fx-spin-enabled",
|
||||
BooleanConverter.getInstance(), Boolean.FALSE)
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isSettable(@NotNull ConfidenceProgressIndicator node)
|
||||
public boolean isSettable(ConfidenceProgressIndicator node)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin();
|
||||
return skin.spinEnabled == null || !skin.spinEnabled.isBound();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Boolean> getStyleableProperty(@NotNull ConfidenceProgressIndicator node)
|
||||
public StyleableProperty<Boolean> getStyleableProperty(ConfidenceProgressIndicator node)
|
||||
{
|
||||
@NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin();
|
||||
final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin();
|
||||
return (StyleableProperty<Boolean>) skin.spinEnabled;
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
{
|
||||
@NotNull final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(SkinBase.getClassCssMetaData());
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(SkinBase.getClassCssMetaData());
|
||||
styleables.add(PROGRESS_COLOR);
|
||||
styleables.add(INDETERMINATE_SEGMENT_COUNT);
|
||||
styleables.add(SPIN_ENABLED);
|
||||
|
@ -3,14 +3,11 @@ package io.bitsquare.gui.components.processbar;
|
||||
import java.util.List;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ProcessStepBar<T> extends Control
|
||||
{
|
||||
|
||||
|
||||
@Nullable
|
||||
private List<ProcessStepItem> processStepItems = null;
|
||||
|
||||
public ProcessStepBar()
|
||||
@ -18,25 +15,25 @@ public class ProcessStepBar<T> extends Control
|
||||
}
|
||||
|
||||
|
||||
public ProcessStepBar(@Nullable List<ProcessStepItem> processStepItems)
|
||||
public ProcessStepBar(List<ProcessStepItem> processStepItems)
|
||||
{
|
||||
this.processStepItems = processStepItems;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin()
|
||||
{
|
||||
return new ProcessStepBarSkin<>(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
List<ProcessStepItem> getProcessStepItems()
|
||||
{
|
||||
return processStepItems;
|
||||
}
|
||||
|
||||
public void setProcessStepItems(@Nullable List<ProcessStepItem> processStepItems)
|
||||
public void setProcessStepItems(List<ProcessStepItem> processStepItems)
|
||||
{
|
||||
this.processStepItems = processStepItems;
|
||||
if (getSkin() != null)
|
||||
|
@ -16,7 +16,6 @@ import javafx.scene.layout.BorderStrokeStyle;
|
||||
import javafx.scene.layout.BorderWidths;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, BehaviorBase<ProcessStepBar<T>>>
|
||||
{
|
||||
@ -47,9 +46,9 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
int i = 0;
|
||||
labelWithBorders = new ArrayList<>();
|
||||
int size = controller.getProcessStepItems().size();
|
||||
for (@NotNull ProcessStepItem processStepItem : controller.getProcessStepItems())
|
||||
for (ProcessStepItem processStepItem : controller.getProcessStepItems())
|
||||
{
|
||||
@NotNull LabelWithBorder labelWithBorder = new LabelWithBorder(processStepItem, i == 0, i == size - 1);
|
||||
LabelWithBorder labelWithBorder = new LabelWithBorder(processStepItem, i == 0, i == size - 1);
|
||||
getChildren().add(labelWithBorder);
|
||||
labelWithBorders.add(labelWithBorder);
|
||||
if (i == 0)
|
||||
@ -106,12 +105,12 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
final double borderWidth = 1;
|
||||
private final double arrowWidth = 10;
|
||||
private final double arrowHeight = 30;
|
||||
@NotNull
|
||||
|
||||
private final ProcessStepItem processStepItem;
|
||||
private final boolean isFirst;
|
||||
private final boolean isLast;
|
||||
|
||||
public LabelWithBorder(@NotNull ProcessStepItem processStepItem, boolean isFirst, boolean isLast)
|
||||
public LabelWithBorder(ProcessStepItem processStepItem, boolean isFirst, boolean isLast)
|
||||
{
|
||||
super(processStepItem.getLabel());
|
||||
this.processStepItem = processStepItem;
|
||||
@ -125,14 +124,14 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
|
||||
this.setShape(createButtonShape());
|
||||
|
||||
@NotNull BorderStroke borderStroke = new BorderStroke(Color.LIGHTGRAY, BorderStrokeStyle.SOLID, null,
|
||||
BorderStroke borderStroke = new BorderStroke(Color.LIGHTGRAY, BorderStrokeStyle.SOLID, null,
|
||||
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
|
||||
this.setBorder(new Border(borderStroke));
|
||||
}
|
||||
|
||||
public void select()
|
||||
{
|
||||
@NotNull BorderStroke borderStroke = new BorderStroke(processStepItem.getColor(), BorderStrokeStyle.SOLID, null,
|
||||
BorderStroke borderStroke = new BorderStroke(processStepItem.getColor(), BorderStrokeStyle.SOLID, null,
|
||||
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
|
||||
this.setBorder(new Border(borderStroke));
|
||||
setTextFill(processStepItem.getColor());
|
||||
@ -152,7 +151,7 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
return arrowWidth;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private Path createButtonShape()
|
||||
{
|
||||
// build the following shape (or home without left arrow)
|
||||
@ -161,14 +160,14 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
// \ \
|
||||
// / /
|
||||
// --------
|
||||
@NotNull Path path = new Path();
|
||||
Path path = new Path();
|
||||
|
||||
// begin in the upper left corner
|
||||
@NotNull MoveTo e1 = new MoveTo(0, 0);
|
||||
MoveTo e1 = new MoveTo(0, 0);
|
||||
path.getElements().add(e1);
|
||||
|
||||
// draw a horizontal line that defines the width of the shape
|
||||
@NotNull HLineTo e2 = new HLineTo();
|
||||
HLineTo e2 = new HLineTo();
|
||||
// bind the width of the shape to the width of the button
|
||||
e2.xProperty().bind(this.widthProperty().subtract(arrowWidth));
|
||||
path.getElements().add(e2);
|
||||
@ -176,7 +175,7 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
if (!isLast)
|
||||
{
|
||||
// draw upper part of right arrow
|
||||
@NotNull LineTo e3 = new LineTo();
|
||||
LineTo e3 = new LineTo();
|
||||
// the x endpoint of this line depends on the x property of line e2
|
||||
e3.xProperty().bind(e2.xProperty().add(arrowWidth));
|
||||
e3.setY(arrowHeight / 2.0);
|
||||
@ -185,24 +184,24 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
|
||||
|
||||
|
||||
// draw lower part of right arrow
|
||||
@NotNull LineTo e4 = new LineTo();
|
||||
LineTo e4 = new LineTo();
|
||||
// the x endpoint of this line depends on the x property of line e2
|
||||
e4.xProperty().bind(e2.xProperty());
|
||||
e4.setY(arrowHeight);
|
||||
path.getElements().add(e4);
|
||||
|
||||
// draw lower horizontal line
|
||||
@NotNull HLineTo e5 = new HLineTo(0);
|
||||
HLineTo e5 = new HLineTo(0);
|
||||
path.getElements().add(e5);
|
||||
|
||||
if (!isFirst)
|
||||
{
|
||||
@NotNull LineTo e6 = new LineTo(arrowWidth, arrowHeight / 2.0);
|
||||
LineTo e6 = new LineTo(arrowWidth, arrowHeight / 2.0);
|
||||
path.getElements().add(e6);
|
||||
}
|
||||
|
||||
// close path
|
||||
@NotNull ClosePath e7 = new ClosePath();
|
||||
ClosePath e7 = new ClosePath();
|
||||
path.getElements().add(e7);
|
||||
// this is a dummy color to fill the shape, it won't be visible
|
||||
path.setFill(Color.BLACK);
|
||||
|
@ -10,7 +10,6 @@ import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -50,7 +49,7 @@ public class FundsController implements Initializable, ChildController, Navigati
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ public class FundsController implements Initializable, ChildController, Navigati
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
return tabPane.navigateToView(navigationItem.getFxmlUrl());
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.util.Callback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -74,14 +72,14 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
for (@NotNull DepositListItem anAddressList : addressList)
|
||||
for (DepositListItem anAddressList : addressList)
|
||||
{
|
||||
anAddressList.cleanup();
|
||||
}
|
||||
@ -134,17 +132,17 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
labelColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column)
|
||||
{
|
||||
return new TableCell<String, DepositListItem>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
Hyperlink hyperlink;
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final DepositListItem item, boolean empty)
|
||||
public void updateItem(final DepositListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -154,7 +152,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
hyperlink.setId("id-link");
|
||||
if (item.getAddressEntry().getTradeId() != null)
|
||||
{
|
||||
@NotNull Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
|
||||
Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
|
||||
Tooltip.install(hyperlink, tooltip);
|
||||
|
||||
hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
|
||||
@ -177,14 +175,14 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
balanceColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column)
|
||||
{
|
||||
return new TableCell<String, DepositListItem>()
|
||||
{
|
||||
@Override
|
||||
public void updateItem(@Nullable final DepositListItem item, boolean empty)
|
||||
public void updateItem(final DepositListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -207,7 +205,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
copyColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column)
|
||||
{
|
||||
@ -222,7 +220,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final DepositListItem item, boolean empty)
|
||||
public void updateItem(final DepositListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -231,7 +229,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
setGraphic(copyIcon);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
@NotNull ClipboardContent content = new ClipboardContent();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(item.addressStringProperty().get());
|
||||
clipboard.setContent(content);
|
||||
});
|
||||
@ -252,7 +250,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
confidenceColumn.setCellFactory(new Callback<TableColumn<String, DepositListItem>, TableCell<String, DepositListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, DepositListItem> call(TableColumn<String, DepositListItem> column)
|
||||
{
|
||||
@ -260,7 +258,7 @@ public class DepositController implements Initializable, ChildController, Hibern
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final DepositListItem item, boolean empty)
|
||||
public void updateItem(final DepositListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
|
@ -3,11 +3,10 @@ package io.bitsquare.gui.funds.deposit;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.funds.withdrawal.WithdrawalListItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DepositListItem extends WithdrawalListItem
|
||||
{
|
||||
public DepositListItem(@NotNull AddressEntry addressEntry, @NotNull WalletFacade walletFacade)
|
||||
public DepositListItem(AddressEntry addressEntry, WalletFacade walletFacade)
|
||||
{
|
||||
super(addressEntry, walletFacade);
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.util.Callback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -68,14 +66,14 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
for (@NotNull TransactionsListItem transactionsListItem : transactionsListItems)
|
||||
for (TransactionsListItem transactionsListItem : transactionsListItems)
|
||||
{
|
||||
transactionsListItem.cleanup();
|
||||
}
|
||||
@ -122,7 +120,7 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
addressColumn.setCellFactory(new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, TransactionsListItem> call(TableColumn<String, TransactionsListItem> column)
|
||||
{
|
||||
@ -131,7 +129,7 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
Hyperlink hyperlink;
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final TransactionsListItem item, boolean empty)
|
||||
public void updateItem(final TransactionsListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -158,7 +156,7 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
confidenceColumn.setCellFactory(new Callback<TableColumn<String, TransactionsListItem>, TableCell<String, TransactionsListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, TransactionsListItem> call(TableColumn<String, TransactionsListItem> column)
|
||||
{
|
||||
@ -166,7 +164,7 @@ public class TransactionsController implements Initializable, ChildController, H
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final TransactionsListItem item, boolean empty)
|
||||
public void updateItem(final TransactionsListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
|
@ -13,8 +13,6 @@ import java.math.BigInteger;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -24,27 +22,27 @@ public class TransactionsListItem
|
||||
private final StringProperty date = new SimpleStringProperty();
|
||||
private final StringProperty amount = new SimpleStringProperty();
|
||||
private final StringProperty type = new SimpleStringProperty();
|
||||
@NotNull
|
||||
|
||||
private final WalletFacade walletFacade;
|
||||
@NotNull
|
||||
|
||||
private final ConfidenceProgressIndicator progressIndicator;
|
||||
@NotNull
|
||||
|
||||
private final Tooltip tooltip;
|
||||
private String addressString;
|
||||
private ConfidenceListener confidenceListener;
|
||||
|
||||
public TransactionsListItem(@NotNull Transaction transaction, @NotNull WalletFacade walletFacade)
|
||||
public TransactionsListItem(Transaction transaction, WalletFacade walletFacade)
|
||||
{
|
||||
this.walletFacade = walletFacade;
|
||||
|
||||
BigInteger valueSentToMe = transaction.getValueSentToMe(walletFacade.getWallet());
|
||||
BigInteger valueSentFromMe = transaction.getValueSentFromMe(walletFacade.getWallet());
|
||||
@Nullable Address address = null;
|
||||
Address address = null;
|
||||
if (valueSentToMe.compareTo(BigInteger.ZERO) == 0)
|
||||
{
|
||||
amount.set("-" + BtcFormatter.satoshiToString(valueSentFromMe));
|
||||
|
||||
for (@NotNull TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
for (TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
{
|
||||
if (!transactionOutput.isMine(walletFacade.getWallet()))
|
||||
{
|
||||
@ -67,7 +65,7 @@ public class TransactionsListItem
|
||||
amount.set(BtcFormatter.satoshiToString(valueSentToMe));
|
||||
type.set("Received with");
|
||||
|
||||
for (@NotNull TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
for (TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
{
|
||||
if (transactionOutput.isMine(walletFacade.getWallet()))
|
||||
{
|
||||
@ -88,7 +86,7 @@ public class TransactionsListItem
|
||||
amount.set(BtcFormatter.satoshiToString(valueSentToMe.subtract(valueSentFromMe)));
|
||||
|
||||
boolean outgoing = false;
|
||||
for (@NotNull TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
for (TransactionOutput transactionOutput : transaction.getOutputs())
|
||||
{
|
||||
if (!transactionOutput.isMine(walletFacade.getWallet()))
|
||||
{
|
||||
@ -148,7 +146,7 @@ public class TransactionsListItem
|
||||
walletFacade.removeConfidenceListener(confidenceListener);
|
||||
}
|
||||
|
||||
private void updateConfidence(@Nullable TransactionConfidence confidence)
|
||||
private void updateConfidence(TransactionConfidence confidence)
|
||||
{
|
||||
if (confidence != null)
|
||||
{
|
||||
@ -178,25 +176,24 @@ public class TransactionsListItem
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public ConfidenceProgressIndicator getProgressIndicator()
|
||||
{
|
||||
return progressIndicator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty dateProperty()
|
||||
{
|
||||
return this.date;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty amountProperty()
|
||||
{
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty typeProperty()
|
||||
{
|
||||
return this.type;
|
||||
|
@ -29,8 +29,6 @@ import javafx.scene.input.ClipboardContent;
|
||||
import javafx.util.Callback;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -106,14 +104,14 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
for (@NotNull WithdrawalListItem anAddressList : addressList)
|
||||
for (WithdrawalListItem anAddressList : addressList)
|
||||
{
|
||||
anAddressList.cleanup();
|
||||
}
|
||||
@ -156,7 +154,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
BigInteger amount = BtcFormatter.stringValueToSatoshis(amountTextField.getText());
|
||||
if (BtcValidator.isMinSpendableAmount(amount))
|
||||
{
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(@javax.annotation.Nullable Transaction transaction)
|
||||
@ -166,7 +164,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.debug("onWithdraw onFailure");
|
||||
}
|
||||
@ -176,8 +174,8 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
"Amount: " + amountTextField.getText() + " BTC\n" +
|
||||
"Sending address: " + withdrawFromTextField.getText() + "\n" +
|
||||
"Receiving address: " + withdrawToTextField.getText() + "\n" +
|
||||
"Transaction fee: " + BtcFormatter.satoshiToString(FeePolicy.TX_FEE) + "\n" +
|
||||
"You receive in total: " + BtcFormatter.satoshiToString(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" +
|
||||
"Transaction fee: " + BtcFormatter.satoshiToString(FeePolicy.TX_FEE_depr) + "\n" +
|
||||
"You receive in total: " + BtcFormatter.satoshiToString(amount.subtract(FeePolicy.TX_FEE_depr)) + " BTC\n\n" +
|
||||
"Are you sure you withdraw that amount?");
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
@ -224,17 +222,17 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
labelColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
labelColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column)
|
||||
{
|
||||
return new TableCell<String, WithdrawalListItem>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
Hyperlink hyperlink;
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final WithdrawalListItem item, boolean empty)
|
||||
public void updateItem(final WithdrawalListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -244,7 +242,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
hyperlink.setId("id-link");
|
||||
if (item.getAddressEntry().getTradeId() != null)
|
||||
{
|
||||
@NotNull Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
|
||||
Tooltip tooltip = new Tooltip(item.getAddressEntry().getTradeId());
|
||||
Tooltip.install(hyperlink, tooltip);
|
||||
|
||||
hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry().getTradeId()));
|
||||
@ -267,14 +265,14 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
balanceColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column)
|
||||
{
|
||||
return new TableCell<String, WithdrawalListItem>()
|
||||
{
|
||||
@Override
|
||||
public void updateItem(@Nullable final WithdrawalListItem item, boolean empty)
|
||||
public void updateItem(final WithdrawalListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
setGraphic((item != null && !empty) ? item.getBalanceLabel() : null);
|
||||
@ -289,7 +287,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
copyColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column)
|
||||
{
|
||||
@ -304,7 +302,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final WithdrawalListItem item, boolean empty)
|
||||
public void updateItem(final WithdrawalListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -313,7 +311,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
setGraphic(copyIcon);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
@NotNull ClipboardContent content = new ClipboardContent();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(item.addressStringProperty().get());
|
||||
clipboard.setContent(content);
|
||||
});
|
||||
@ -334,7 +332,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue()));
|
||||
confidenceColumn.setCellFactory(new Callback<TableColumn<String, WithdrawalListItem>, TableCell<String, WithdrawalListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, WithdrawalListItem> call(TableColumn<String, WithdrawalListItem> column)
|
||||
{
|
||||
@ -342,7 +340,7 @@ public class WithdrawalController implements Initializable, ChildController, Hib
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final WithdrawalListItem item, boolean empty)
|
||||
public void updateItem(final WithdrawalListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
|
@ -13,28 +13,26 @@ import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WithdrawalListItem
|
||||
{
|
||||
private final StringProperty addressString = new SimpleStringProperty();
|
||||
private final BalanceListener balanceListener;
|
||||
@NotNull
|
||||
|
||||
private final Label balanceLabel;
|
||||
@NotNull
|
||||
|
||||
private final AddressEntry addressEntry;
|
||||
@NotNull
|
||||
|
||||
private final WalletFacade walletFacade;
|
||||
private final ConfidenceListener confidenceListener;
|
||||
@NotNull
|
||||
|
||||
private final ConfidenceProgressIndicator progressIndicator;
|
||||
@NotNull
|
||||
|
||||
private final Tooltip tooltip;
|
||||
@Nullable
|
||||
|
||||
private BigInteger balance;
|
||||
|
||||
public WithdrawalListItem(@NotNull AddressEntry addressEntry, @NotNull WalletFacade walletFacade)
|
||||
public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade)
|
||||
{
|
||||
this.addressEntry = addressEntry;
|
||||
this.walletFacade = walletFacade;
|
||||
@ -81,7 +79,7 @@ public class WithdrawalListItem
|
||||
walletFacade.removeBalanceListener(balanceListener);
|
||||
}
|
||||
|
||||
private void updateBalance(@Nullable BigInteger balance)
|
||||
private void updateBalance(BigInteger balance)
|
||||
{
|
||||
this.balance = balance;
|
||||
if (balance != null)
|
||||
@ -90,7 +88,7 @@ public class WithdrawalListItem
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfidence(@Nullable TransactionConfidence confidence)
|
||||
private void updateConfidence(TransactionConfidence confidence)
|
||||
{
|
||||
if (confidence != null)
|
||||
{
|
||||
@ -119,7 +117,7 @@ public class WithdrawalListItem
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public final String getLabel()
|
||||
{
|
||||
switch (addressEntry.getAddressContext())
|
||||
@ -137,7 +135,7 @@ public class WithdrawalListItem
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty addressStringProperty()
|
||||
{
|
||||
return this.addressString;
|
||||
@ -148,25 +146,25 @@ public class WithdrawalListItem
|
||||
return addressEntry.getAddress();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public AddressEntry getAddressEntry()
|
||||
{
|
||||
return addressEntry;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public ConfidenceProgressIndicator getProgressIndicator()
|
||||
{
|
||||
return progressIndicator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Label getBalanceLabel()
|
||||
{
|
||||
return balanceLabel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public BigInteger getBalance()
|
||||
{
|
||||
return balance;
|
||||
|
@ -18,8 +18,6 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class HomeController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
@ -34,7 +32,7 @@ public class HomeController implements Initializable, ChildController, Navigatio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,14 +45,14 @@ public class HomeController implements Initializable, ChildController, Navigatio
|
||||
// Interface implementation: NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
if (arbitratorRegistrationController != null)
|
||||
arbitratorRegistrationController.cleanup();
|
||||
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
try
|
||||
{
|
||||
final Node view = loader.load();
|
||||
@ -62,7 +60,7 @@ public class HomeController implements Initializable, ChildController, Navigatio
|
||||
arbitratorRegistrationController.setNavigationController(this);
|
||||
|
||||
final Stage rootStage = BitSquare.getStage();
|
||||
@NotNull final Stage stage = new Stage();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator");
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(400);
|
||||
@ -72,7 +70,7 @@ public class HomeController implements Initializable, ChildController, Navigatio
|
||||
stage.setY(rootStage.getY() + 50);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(rootStage);
|
||||
@NotNull Scene scene = new Scene((Parent) view, 800, 600);
|
||||
Scene scene = new Scene((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
|
@ -15,13 +15,11 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MarketController implements Initializable, NavigationController, ChildController
|
||||
{
|
||||
private boolean orderbookCreated;
|
||||
@Nullable
|
||||
|
||||
private OrderBookController orderBookController;
|
||||
|
||||
@FXML
|
||||
@ -36,6 +34,8 @@ public class MarketController implements Initializable, NavigationController, Ch
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
navigateToView(NavigationItem.ORDER_BOOK);
|
||||
|
||||
navigateToView(NavigationItem.TAKE_OFFER);
|
||||
}
|
||||
|
||||
|
||||
@ -43,9 +43,9 @@ public class MarketController implements Initializable, NavigationController, Ch
|
||||
// Interface implementation: NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
|
||||
if (navigationItem == NavigationItem.ORDER_BOOK && orderbookCreated)
|
||||
@ -54,17 +54,30 @@ public class MarketController implements Initializable, NavigationController, Ch
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
try
|
||||
{
|
||||
Pane view = loader.load();
|
||||
final Pane view = loader.load();
|
||||
ChildController childController = loader.getController();
|
||||
childController.setNavigationController(this);
|
||||
|
||||
if (childController instanceof OrderBookController)
|
||||
orderBookController = (OrderBookController) childController;
|
||||
|
||||
@NotNull Tab tab = new Tab("Orderbook");
|
||||
String tabLabel;
|
||||
switch (navigationItem)
|
||||
{
|
||||
case CREATE_OFFER:
|
||||
tabLabel = "Create offer";
|
||||
break;
|
||||
case TAKE_OFFER:
|
||||
tabLabel = "Take offer";
|
||||
break;
|
||||
default:
|
||||
tabLabel = "Orderbook";
|
||||
break;
|
||||
}
|
||||
final Tab tab = new Tab(tabLabel);
|
||||
tab.setContent(view);
|
||||
tabPane.getTabs().add(tab);
|
||||
|
||||
@ -90,7 +103,7 @@ public class MarketController implements Initializable, NavigationController, Ch
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -36,20 +36,19 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CreateOfferController implements Initializable, ChildController, Hibernate
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferController.class);
|
||||
@NotNull
|
||||
|
||||
private final Trading trading;
|
||||
@NotNull
|
||||
|
||||
private final WalletFacade walletFacade;
|
||||
@NotNull
|
||||
|
||||
private final Settings settings;
|
||||
@NotNull
|
||||
|
||||
private final User user;
|
||||
private NavigationController navigationController;
|
||||
private Direction direction;
|
||||
@ -75,7 +74,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private CreateOfferController(@NotNull Trading trading, @NotNull WalletFacade walletFacade, @NotNull Settings settings, @NotNull User user)
|
||||
private CreateOfferController(Trading trading, WalletFacade walletFacade, Settings settings, User user)
|
||||
{
|
||||
this.trading = trading;
|
||||
this.walletFacade = walletFacade;
|
||||
@ -88,7 +87,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setOrderBookFilter(@NotNull OrderBookFilter orderBookFilter)
|
||||
public void setOrderBookFilter(OrderBookFilter orderBookFilter)
|
||||
{
|
||||
direction = orderBookFilter.getDirection();
|
||||
amountTextField.setText(BitSquareFormatter.formatPrice(orderBookFilter.getAmount()));
|
||||
@ -128,7 +127,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
}
|
||||
acceptedCountriesTextField.setText(BitSquareFormatter.countryLocalesToString(settings.getAcceptedCountries()));
|
||||
acceptedLanguagesTextField.setText(BitSquareFormatter.languageLocalesToString(settings.getAcceptedLanguageLocales()));
|
||||
feeLabel.setText(BtcFormatter.satoshiToString(FeePolicy.CREATE_OFFER_FEE));
|
||||
feeLabel.setText(BtcFormatter.satoshiToString(FeePolicy.CREATE_OFFER_FEE_depr));
|
||||
}
|
||||
|
||||
|
||||
@ -137,7 +136,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
@ -203,7 +202,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
settings.getAcceptedLanguageLocales());
|
||||
|
||||
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(@javax.annotation.Nullable Transaction transaction)
|
||||
@ -226,7 +225,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.warn("sendResult onFailure:" + t);
|
||||
Popups.openErrorPopup("Fee payment failed", "Fee payment failed. " + t);
|
||||
@ -247,7 +246,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
|
||||
public void onClose()
|
||||
{
|
||||
@NotNull TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
||||
|
||||
navigationController.navigateToView(NavigationItem.ORDER_BOOK);
|
||||
@ -258,7 +257,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupSuccessScreen(@NotNull Transaction newTransaction)
|
||||
private void setupSuccessScreen(Transaction newTransaction)
|
||||
{
|
||||
placeOfferButton.setVisible(false);
|
||||
|
||||
|
@ -54,8 +54,6 @@ import javafx.util.Callback;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.Dialogs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -85,7 +83,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
public Button createOfferButton;
|
||||
private NavigationController navigationController;
|
||||
private SortedList<OrderBookListItem> offerList;
|
||||
@Nullable
|
||||
|
||||
private AnimationTimer pollingTimer;
|
||||
@FXML
|
||||
private TableColumn<String, OrderBookListItem> directionColumn, countryColumn, bankAccountTypeColumn;
|
||||
@ -156,7 +154,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
@ -231,7 +229,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
else
|
||||
{
|
||||
Action response = Popups.openErrorPopup("Missing registration fee", "You have not funded the full registration fee of " + BtcFormatter.satoshiToString(FeePolicy.ACCOUNT_REGISTRATION_FEE) + " BTC.");
|
||||
Action response = Popups.openErrorPopup("Missing registration fee", "You have not funded the full registration fee of " + BtcFormatter.satoshiToString(FeePolicy.ACCOUNT_REGISTRATION_FEE_depr) + " BTC.");
|
||||
if (response == Dialog.Actions.OK)
|
||||
{
|
||||
MainController.INSTANCE().navigateToView(NavigationItem.FUNDS);
|
||||
@ -250,10 +248,10 @@ public class OrderBookController implements Initializable, ChildController
|
||||
|
||||
if (selectedIndex >= 0)
|
||||
{
|
||||
@NotNull Dialogs.CommandLink settingsCommandLink = new Dialogs.CommandLink("Open settings", "You need to configure your settings before you can actively trade.");
|
||||
@NotNull Dialogs.CommandLink depositFeeCommandLink = new Dialogs.CommandLink("Deposit funds", "You need to pay the registration fee before you can actively trade. That is needed as prevention against fraud.");
|
||||
@NotNull Dialogs.CommandLink sendRegistrationCommandLink = new Dialogs.CommandLink("Publish registration", "When settings are configured and the fee deposit is done your registration transaction will be published to the Bitcoin \nnetwork.");
|
||||
@NotNull List<Dialogs.CommandLink> commandLinks = Arrays.asList(settingsCommandLink, depositFeeCommandLink, sendRegistrationCommandLink);
|
||||
Dialogs.CommandLink settingsCommandLink = new Dialogs.CommandLink("Open settings", "You need to configure your settings before you can actively trade.");
|
||||
Dialogs.CommandLink depositFeeCommandLink = new Dialogs.CommandLink("Deposit funds", "You need to pay the registration fee before you can actively trade. That is needed as prevention against fraud.");
|
||||
Dialogs.CommandLink sendRegistrationCommandLink = new Dialogs.CommandLink("Publish registration", "When settings are configured and the fee deposit is done your registration transaction will be published to the Bitcoin \nnetwork.");
|
||||
List<Dialogs.CommandLink> commandLinks = Arrays.asList(settingsCommandLink, depositFeeCommandLink, sendRegistrationCommandLink);
|
||||
Action registrationMissingAction = Popups.openRegistrationMissingPopup("Not registered yet", "Please follow these steps:", "You need to register before you can place an offer.", commandLinks, selectedIndex);
|
||||
if (registrationMissingAction == settingsCommandLink)
|
||||
{
|
||||
@ -272,7 +270,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
|
||||
private void payRegistrationFee()
|
||||
{
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(@javax.annotation.Nullable Transaction transaction)
|
||||
@ -282,7 +280,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.debug("payRegistrationFee onFailure");
|
||||
}
|
||||
@ -327,15 +325,17 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
}
|
||||
|
||||
private void takeOffer(@NotNull Offer offer)
|
||||
private void takeOffer(Offer offer)
|
||||
{
|
||||
if (isRegistered())
|
||||
{
|
||||
@Nullable TakerTradeController takerTradeController = (TakerTradeController) navigationController.navigateToView(NavigationItem.TAKER_TRADE);
|
||||
TakerTradeController takerTradeController = (TakerTradeController) navigationController.navigateToView(NavigationItem.TAKE_OFFER);
|
||||
|
||||
BigInteger requestedAmount = offer.getAmount();
|
||||
BigInteger requestedAmount;
|
||||
if (!"".equals(amount.getText()))
|
||||
requestedAmount = BtcFormatter.stringValueToSatoshis(amount.getText());
|
||||
else
|
||||
requestedAmount = offer.getAmount();
|
||||
|
||||
if (takerTradeController != null)
|
||||
takerTradeController.initWithData(offer, requestedAmount);
|
||||
@ -346,7 +346,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
}
|
||||
|
||||
private void removeOffer(@NotNull Offer offer)
|
||||
private void removeOffer(Offer offer)
|
||||
{
|
||||
orderBook.removeOffer(offer);
|
||||
}
|
||||
@ -385,7 +385,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||
directionColumn.setCellFactory(new Callback<TableColumn<String, OrderBookListItem>, TableCell<String, OrderBookListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, OrderBookListItem> call(TableColumn<String, OrderBookListItem> directionColumn)
|
||||
{
|
||||
@ -400,7 +400,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final OrderBookListItem orderBookListItem, boolean empty)
|
||||
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
|
||||
{
|
||||
super.updateItem(orderBookListItem, empty);
|
||||
|
||||
@ -408,7 +408,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
{
|
||||
String title;
|
||||
Image icon;
|
||||
@NotNull Offer offer = orderBookListItem.getOffer();
|
||||
Offer offer = orderBookListItem.getOffer();
|
||||
|
||||
if (offer.getMessagePubKeyAsHex().equals(user.getMessagePubKeyAsHex()))
|
||||
{
|
||||
@ -453,7 +453,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
countryColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||
countryColumn.setCellFactory(new Callback<TableColumn<String, OrderBookListItem>, TableCell<String, OrderBookListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, OrderBookListItem> call(TableColumn<String, OrderBookListItem> directionColumn)
|
||||
{
|
||||
@ -468,7 +468,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final OrderBookListItem orderBookListItem, boolean empty)
|
||||
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
|
||||
{
|
||||
super.updateItem(orderBookListItem, empty);
|
||||
|
||||
@ -497,14 +497,14 @@ public class OrderBookController implements Initializable, ChildController
|
||||
bankAccountTypeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||
bankAccountTypeColumn.setCellFactory(new Callback<TableColumn<String, OrderBookListItem>, TableCell<String, OrderBookListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, OrderBookListItem> call(TableColumn<String, OrderBookListItem> directionColumn)
|
||||
{
|
||||
return new TableCell<String, OrderBookListItem>()
|
||||
{
|
||||
@Override
|
||||
public void updateItem(@Nullable final OrderBookListItem orderBookListItem, boolean empty)
|
||||
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
|
||||
{
|
||||
super.updateItem(orderBookListItem, empty);
|
||||
|
||||
@ -528,7 +528,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
// Utils
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private double textInputToNumber(String oldValue, @NotNull String newValue)
|
||||
private double textInputToNumber(String oldValue, String newValue)
|
||||
{
|
||||
//TODO use regex.... or custom textfield component
|
||||
double d = 0.0;
|
||||
@ -536,7 +536,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
{
|
||||
try
|
||||
{
|
||||
@NotNull DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.getDefault());
|
||||
DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.getDefault());
|
||||
d = decimalFormat.parse(newValue).doubleValue();
|
||||
} catch (ParseException e)
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OrderBookListItem
|
||||
{
|
||||
@ -13,11 +12,11 @@ public class OrderBookListItem
|
||||
private final StringProperty amount = new SimpleStringProperty();
|
||||
private final StringProperty volume = new SimpleStringProperty();
|
||||
|
||||
@NotNull
|
||||
|
||||
private final Offer offer;
|
||||
|
||||
|
||||
public OrderBookListItem(@NotNull Offer offer)
|
||||
public OrderBookListItem(Offer offer)
|
||||
{
|
||||
this.offer = offer;
|
||||
this.price.set(BitSquareFormatter.formatPrice(offer.getPrice()));
|
||||
@ -29,26 +28,26 @@ public class OrderBookListItem
|
||||
this.volume.set(BitSquareFormatter.formatVolumeWithMinVolume(offer.getVolume(), offer.getMinVolume()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Offer getOffer()
|
||||
{
|
||||
return offer;
|
||||
}
|
||||
|
||||
// called form table columns
|
||||
@NotNull
|
||||
|
||||
public final StringProperty priceProperty()
|
||||
{
|
||||
return this.price;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty amountProperty()
|
||||
{
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty volumeProperty()
|
||||
{
|
||||
return this.volume;
|
||||
|
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:id="rootContainer"
|
||||
fx:controller="io.bitsquare.gui.market.trade.TakerOfferController">
|
||||
<Accordion fx:id="accordion" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
|
||||
<panes>
|
||||
|
||||
<TitledPane fx:id="profileTitledPane" text="Offer details">
|
||||
<ScrollPane fitToWidth="true">
|
||||
<GridPane hgap="5.0" vgap="5.0">
|
||||
<padding>
|
||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||
</padding>
|
||||
|
||||
<Label text="Take offer:" id="headline-label"/>
|
||||
|
||||
<Label text="Amount (BTC):" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="amountTextField" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Price (EUR/BTC):" GridPane.rowIndex="2"/>
|
||||
<TextField fx:id="priceTextField" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Volume (EUR):" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="volumeTextField" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Collateral (BTC):" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="collateralTextField" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Fee (BTC):" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="feeTextField" GridPane.rowIndex="5" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Total (BTC):" GridPane.rowIndex="6"/>
|
||||
<TextField fx:id="totalTextField" GridPane.rowIndex="6" GridPane.columnIndex="1"/>
|
||||
|
||||
|
||||
<Button text="Take offer and pay" onAction="#onTakeOffer" defaultButton="true" GridPane.rowIndex="7" GridPane.columnIndex="1"/>
|
||||
|
||||
|
||||
<Label text="Offer details:" id="headline-label" GridPane.rowIndex="8"/>
|
||||
|
||||
<Label text="Bank account type:" GridPane.rowIndex="9"/>
|
||||
<TextField fx:id="bankAccountTypeTextField" GridPane.rowIndex="9" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Country:" GridPane.rowIndex="10"/>
|
||||
<TextField fx:id="countryTextField" GridPane.rowIndex="10" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Arbitrators:" GridPane.rowIndex="11"/>
|
||||
<TextField fx:id="arbitratorsTextField" GridPane.rowIndex="11" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Supported languages:" GridPane.rowIndex="12"/>
|
||||
<TextField fx:id="supportedLanguagesTextField" GridPane.rowIndex="12" GridPane.columnIndex="1"/>
|
||||
|
||||
<Label text="Supported countries:" GridPane.rowIndex="13"/>
|
||||
<TextField fx:id="supportedCountriesTextField" GridPane.rowIndex="13" GridPane.columnIndex="1"/>
|
||||
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"/>
|
||||
</columnConstraints>
|
||||
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
|
||||
</GridPane>
|
||||
</ScrollPane>
|
||||
</TitledPane>
|
||||
|
||||
<TitledPane fx:id="payCollateralTitledPane" text="Wait for bank transfer">
|
||||
</TitledPane>
|
||||
|
||||
<TitledPane fx:id="payCollateralTitledPane" text="Summary">
|
||||
</TitledPane>
|
||||
|
||||
</panes>
|
||||
</Accordion>
|
||||
</AnchorPane>
|
@ -0,0 +1,221 @@
|
||||
package io.bitsquare.gui.market.trade;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.btc.BtcFormatter;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.currency.Bitcoin;
|
||||
import io.bitsquare.currency.Fiat;
|
||||
import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.util.BitSquareConverter;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.Currency;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Accordion;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TitledPane;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public class TakerOfferController implements Initializable, ChildController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerOfferController.class);
|
||||
|
||||
private final Trading trading;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private NavigationController navigationController;
|
||||
private Offer offer;
|
||||
private Bitcoin requestedAmount;
|
||||
|
||||
@FXML
|
||||
private Accordion accordion;
|
||||
@FXML
|
||||
private TitledPane profileTitledPane;
|
||||
@FXML
|
||||
private TextField amountTextField, priceTextField, volumeTextField, collateralTextField, feeTextField, totalTextField, bankAccountTypeTextField, countryTextField,
|
||||
arbitratorsTextField, supportedLanguagesTextField, supportedCountriesTextField;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TakerOfferController(Trading trading, WalletFacade walletFacade, MessageFacade messageFacade)
|
||||
{
|
||||
this.trading = trading;
|
||||
this.walletFacade = walletFacade;
|
||||
this.messageFacade = messageFacade;
|
||||
|
||||
|
||||
Offer offer = new Offer("m",
|
||||
Direction.BUY,
|
||||
111,
|
||||
new BigInteger("100000000"),
|
||||
new BigInteger("10000000"),
|
||||
BankAccountType.OK_PAY,
|
||||
Currency.getInstance("EUR"),
|
||||
CountryUtil.getDefaultCountry(),
|
||||
"baid",
|
||||
new Arbitrator(),
|
||||
10,
|
||||
CountryUtil.getAllCountriesFor(CountryUtil.getAllRegions().get(0)),
|
||||
LanguageUtil.getAllLanguageLocales());
|
||||
|
||||
initWithData(offer, new Bitcoin("50000000"));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initWithData(Offer offer, Bitcoin requestedAmount)
|
||||
{
|
||||
this.offer = offer;
|
||||
this.requestedAmount = requestedAmount.isZero() ? new Bitcoin(offer.getAmount()) : requestedAmount;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface implementation: Initializable
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
accordion.setExpandedPane(profileTitledPane);
|
||||
|
||||
if (offer != null && requestedAmount != null)
|
||||
{
|
||||
amountTextField.setText(requestedAmount.getFormattedValue());
|
||||
amountTextField.setPromptText(new Bitcoin(offer.getMinAmount()).getFormattedValue() + " - " + new Bitcoin(offer.getAmount()).getFormattedValue());
|
||||
priceTextField.setText(new Fiat(offer.getPrice()).getFormattedValue());
|
||||
applyVolume();
|
||||
applyCollateral();
|
||||
applyTotal();
|
||||
feeTextField.setText(getFee().getFormattedValue());
|
||||
totalTextField.setText(getFormattedTotal());
|
||||
|
||||
bankAccountTypeTextField.setText(offer.getBankAccountType().toString());
|
||||
countryTextField.setText(offer.getBankAccountCountry().getName());
|
||||
|
||||
//todo list
|
||||
// arbitratorsTextField.setText(offer.getArbitrator().getName());
|
||||
|
||||
supportedLanguagesTextField.setText(BitSquareFormatter.languageLocalesToString(offer.getAcceptedLanguageLocales()));
|
||||
supportedCountriesTextField.setText(BitSquareFormatter.countryLocalesToString(offer.getAcceptedCountries()));
|
||||
|
||||
amountTextField.textProperty().addListener(e -> {
|
||||
applyVolume();
|
||||
applyCollateral();
|
||||
applyTotal();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface implementation: ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GUI handlers
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onTakeOffer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void applyCollateral()
|
||||
{
|
||||
collateralTextField.setText(getFormattedCollateral());
|
||||
}
|
||||
|
||||
private void applyVolume()
|
||||
{
|
||||
volumeTextField.setText(getFormattedVolume());
|
||||
}
|
||||
|
||||
private void applyTotal()
|
||||
{
|
||||
totalTextField.setText(getFormattedTotal());
|
||||
}
|
||||
|
||||
// formatted
|
||||
private String getFormattedVolume()
|
||||
{
|
||||
return BitSquareFormatter.formatVolume(getVolume());
|
||||
}
|
||||
|
||||
private String getFormattedTotal()
|
||||
{
|
||||
return BitSquareFormatter.formatVolume(getTotal());
|
||||
}
|
||||
|
||||
private String getFormattedCollateral()
|
||||
{
|
||||
return BtcFormatter.satoshiToString(getCollateralInSatoshis());
|
||||
}
|
||||
|
||||
// values
|
||||
private double getAmountAsDouble()
|
||||
{
|
||||
return BitSquareConverter.stringToDouble2(amountTextField.getText());
|
||||
}
|
||||
|
||||
private double getVolume()
|
||||
{
|
||||
return offer.getPrice() * getAmountAsDouble();
|
||||
}
|
||||
|
||||
private Bitcoin getFee()
|
||||
{
|
||||
return FeePolicy.TAKE_OFFER_FEE.addBitcoin(FeePolicy.TX_FEE);
|
||||
}
|
||||
|
||||
private double getTotal()
|
||||
{
|
||||
return getFee().doubleValue() + getVolume();
|
||||
}
|
||||
|
||||
private BigInteger getCollateralInSatoshis()
|
||||
{
|
||||
double amount = BitSquareConverter.stringToDouble2(amountTextField.getText());
|
||||
double resultDouble = amount * (double) offer.getCollateral() / 100.0;
|
||||
return BtcFormatter.doubleValueToSatoshis(resultDouble);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -60,7 +58,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
private Label infoLabel;
|
||||
private Button nextButton;
|
||||
private ProgressBar progressBar;
|
||||
@Nullable
|
||||
|
||||
private AnimationTimer checkOnlineStatusTimer;
|
||||
private Pane isOnlineCheckerHolder;
|
||||
private Label headerLabel;
|
||||
@ -90,15 +88,11 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initWithData(@NotNull Offer offer, @NotNull BigInteger requestedAmount)
|
||||
public void initWithData(Offer offer, BigInteger requestedAmount)
|
||||
{
|
||||
this.offer = offer;
|
||||
this.requestedAmount = requestedAmount.compareTo(BigInteger.ZERO) > 0 ? requestedAmount : offer.getAmount();
|
||||
|
||||
// trade = trading.createTrade(offer);
|
||||
//trade.setTradeAmount(requestedAmount);
|
||||
//contract = trading.createContract(trade);
|
||||
|
||||
processStepItems.add(new ProcessStepItem(takerIsSelling() ? "Sell BTC" : "Buy BTC"));
|
||||
processStepItems.add(new ProcessStepItem("Bank transfer"));
|
||||
processStepItems.add(new ProcessStepItem("Completed"));
|
||||
@ -123,7 +117,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
@ -162,18 +156,18 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
totalToPayLabel.setText(getTotalToPayAsString());
|
||||
|
||||
});
|
||||
@NotNull Label amountRangeLabel = new Label("(" + BtcFormatter.satoshiToString(offer.getMinAmount()) + " - " + BtcFormatter.satoshiToString(offer.getAmount()) + ")");
|
||||
Label amountRangeLabel = new Label("(" + BtcFormatter.satoshiToString(offer.getMinAmount()) + " - " + BtcFormatter.satoshiToString(offer.getAmount()) + ")");
|
||||
gridPane.add(amountRangeLabel, 2, row);
|
||||
|
||||
FormBuilder.addTextField(gridPane, "Price (" + offer.getCurrency() + "/BTC):", BitSquareFormatter.formatPrice(offer.getPrice()), ++row);
|
||||
totalLabel = FormBuilder.addTextField(gridPane, "Total (" + offer.getCurrency() + "):", BitSquareFormatter.formatVolume(getVolume()), ++row);
|
||||
collateralTextField = FormBuilder.addTextField(gridPane, "Collateral (BTC):", "", ++row);
|
||||
applyCollateral();
|
||||
FormBuilder.addTextField(gridPane, "Offer fee (BTC):", BtcFormatter.satoshiToString(FeePolicy.TAKE_OFFER_FEE.add(FeePolicy.TX_FEE)), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Offer fee (BTC):", BtcFormatter.satoshiToString(FeePolicy.TAKE_OFFER_FEE_depr.add(FeePolicy.TX_FEE_depr)), ++row);
|
||||
totalToPayLabel = FormBuilder.addTextField(gridPane, "Total to pay (BTC):", getTotalToPayAsString(), ++row);
|
||||
|
||||
isOnlineTextField = FormBuilder.addTextField(gridPane, "Online status:", "Checking offerers online status...", ++row);
|
||||
@NotNull ConfidenceProgressIndicator isOnlineChecker = new ConfidenceProgressIndicator();
|
||||
ConfidenceProgressIndicator isOnlineChecker = new ConfidenceProgressIndicator();
|
||||
isOnlineChecker.setPrefSize(20, 20);
|
||||
isOnlineChecker.setLayoutY(3);
|
||||
isOnlineCheckerHolder = new Pane();
|
||||
@ -198,7 +192,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
FormBuilder.addTextField(gridPane, "Bank account type:", offer.getBankAccountType().toString(), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Country:", offer.getBankAccountCountry().getName(), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Arbitrator:", offer.getArbitrator().getName(), ++row);
|
||||
@NotNull Label arbitratorLink = new Label(offer.getArbitrator().getWebUrl());
|
||||
Label arbitratorLink = new Label(offer.getArbitrator().getWebUrl());
|
||||
arbitratorLink.setId("label-url");
|
||||
gridPane.add(arbitratorLink, 2, row);
|
||||
arbitratorLink.setOnMouseClicked(e -> {
|
||||
@ -226,7 +220,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
|
||||
// offerId = tradeId
|
||||
// we don't want to create the trade before the balance check
|
||||
@Nullable AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
|
||||
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
|
||||
// log.debug("balance " + walletFacade.getBalanceForAddress(addressEntry.getAddress()).toString());
|
||||
if (getTotalToPay().compareTo(walletFacade.getBalanceForAddress(addressEntry != null ? addressEntry.getAddress() : null)) > 0)
|
||||
{
|
||||
@ -268,10 +262,10 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
gridPane.add(progressBar, 1, row);
|
||||
|
||||
FormBuilder.addLabel(gridPane, "Status:", "", ++row);
|
||||
@NotNull ConfidenceProgressIndicator progressIndicator = new ConfidenceProgressIndicator();
|
||||
ConfidenceProgressIndicator progressIndicator = new ConfidenceProgressIndicator();
|
||||
progressIndicator.setPrefSize(20, 20);
|
||||
progressIndicator.setLayoutY(2);
|
||||
@NotNull Pane progressIndicatorHolder = new Pane();
|
||||
Pane progressIndicatorHolder = new Pane();
|
||||
progressIndicatorHolder.getChildren().addAll(progressIndicator);
|
||||
gridPane.add(progressIndicatorHolder, 1, row);
|
||||
|
||||
@ -318,7 +312,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBankTransferInited(@NotNull TradeMessage tradeMessage)
|
||||
public void onBankTransferInited(TradeMessage tradeMessage)
|
||||
{
|
||||
buildBankTransferInitedScreen(tradeMessage);
|
||||
}
|
||||
@ -353,7 +347,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
// confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator);
|
||||
}
|
||||
|
||||
private void buildBankTransferInitedScreen(@NotNull TradeMessage tradeMessage)
|
||||
private void buildBankTransferInitedScreen(TradeMessage tradeMessage)
|
||||
{
|
||||
processStepBar.next();
|
||||
|
||||
@ -364,7 +358,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
nextButton.setOnAction(e -> releaseBTC(tradeMessage));
|
||||
}
|
||||
|
||||
private void releaseBTC(@NotNull TradeMessage tradeMessage)
|
||||
private void releaseBTC(TradeMessage tradeMessage)
|
||||
{
|
||||
processStepBar.next();
|
||||
trading.releaseBTC(trade.getId(), tradeMessage);
|
||||
@ -382,7 +376,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
if (takerIsSelling())
|
||||
{
|
||||
FormBuilder.addTextField(gridPane, "You have received (" + offer.getCurrency() + "):\"", fiatReceived, ++row);
|
||||
FormBuilder.addTextField(gridPane, "Total fees (take offer fee + tx fee):", BtcFormatter.satoshiToString(FeePolicy.TAKE_OFFER_FEE.add(FeePolicy.TX_FEE)), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Total fees (take offer fee + tx fee):", BtcFormatter.satoshiToString(FeePolicy.TAKE_OFFER_FEE_depr.add(FeePolicy.TX_FEE_depr)), ++row);
|
||||
FormBuilder.addTextField(gridPane, "Refunded collateral:", BtcFormatter.satoshiToString(trade.getCollateralAmount()), ++row);
|
||||
}
|
||||
else
|
||||
@ -404,7 +398,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
|
||||
private void close()
|
||||
{
|
||||
@NotNull TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
||||
|
||||
navigationController.navigateToView(NavigationItem.ORDER_BOOK);
|
||||
@ -466,11 +460,11 @@ public class TakerTradeController implements Initializable, ChildController
|
||||
{
|
||||
if (takerIsSelling())
|
||||
{
|
||||
return getAmountInSatoshis().add(FeePolicy.TAKE_OFFER_FEE).add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE).add(getCollateralInSatoshis());
|
||||
return getAmountInSatoshis().add(FeePolicy.TAKE_OFFER_FEE_depr).add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE_depr).add(getCollateralInSatoshis());
|
||||
}
|
||||
else
|
||||
{
|
||||
return FeePolicy.TAKE_OFFER_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE).add(getCollateralInSatoshis());
|
||||
return FeePolicy.TAKE_OFFER_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT).add(FeePolicy.TX_FEE_depr).add(getCollateralInSatoshis());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -40,7 +39,7 @@ public class MsgController implements Initializable, ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -50,7 +49,7 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
return tabPane.navigateToView(navigationItem.getFxmlUrl());
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import io.bitsquare.gui.NavigationController;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.Initializable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -41,7 +40,7 @@ public class ClosedTradeController implements Initializable, ChildController, Hi
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
log.debug("setNavigationController" + this);
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Callback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -68,7 +66,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
// Interface implementation: ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
log.debug("setNavigationController" + this);
|
||||
}
|
||||
@ -95,7 +93,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
{
|
||||
offerListItems = FXCollections.observableArrayList();
|
||||
Map<String, Offer> offerMap = trading.getOffers();
|
||||
@NotNull List<Offer> offerList = new ArrayList<>(offerMap.values());
|
||||
List<Offer> offerList = new ArrayList<>(offerMap.values());
|
||||
offerListItems.addAll(offerList.stream().map(OfferListItem::new).collect(Collectors.toList()));
|
||||
offerTable.setItems(offerListItems);
|
||||
}
|
||||
@ -111,7 +109,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
private void removeOffer(@NotNull OfferListItem offerListItem)
|
||||
private void removeOffer(OfferListItem offerListItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -138,7 +136,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
offerIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue()));
|
||||
offerIdColumn.setCellFactory(new Callback<TableColumn<String, OfferListItem>, TableCell<String, OfferListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, OfferListItem> call(TableColumn<String, OfferListItem> column)
|
||||
{
|
||||
@ -147,7 +145,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
Hyperlink hyperlink;
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final OfferListItem item, boolean empty)
|
||||
public void updateItem(final OfferListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
@ -155,7 +153,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
{
|
||||
hyperlink = new Hyperlink(item.getOfferId());
|
||||
//hyperlink.getStyleClass().setAll("aaa");
|
||||
@NotNull Tooltip tooltip = new Tooltip(item.getOfferId());
|
||||
Tooltip tooltip = new Tooltip(item.getOfferId());
|
||||
Tooltip.install(hyperlink, tooltip);
|
||||
hyperlink.setOnAction(event -> openOfferDetails(item));
|
||||
setGraphic(hyperlink);
|
||||
@ -176,7 +174,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
removeColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue()));
|
||||
removeColumn.setCellFactory(new Callback<TableColumn<String, OfferListItem>, TableCell<String, OfferListItem>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public TableCell<String, OfferListItem> call(TableColumn<String, OfferListItem> directionColumn)
|
||||
{
|
||||
@ -192,7 +190,7 @@ public class OfferController implements Initializable, ChildController, Hibernat
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final OfferListItem offerListItem, boolean empty)
|
||||
public void updateItem(final OfferListItem offerListItem, boolean empty)
|
||||
{
|
||||
super.updateItem(offerListItem, empty);
|
||||
|
||||
|
@ -5,7 +5,6 @@ import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OfferListItem
|
||||
{
|
||||
@ -13,11 +12,11 @@ public class OfferListItem
|
||||
private final StringProperty amount = new SimpleStringProperty();
|
||||
private final StringProperty date = new SimpleStringProperty();
|
||||
private final StringProperty volume = new SimpleStringProperty();
|
||||
@NotNull
|
||||
|
||||
private final Offer offer;
|
||||
private final String offerId;
|
||||
|
||||
public OfferListItem(@NotNull Offer offer)
|
||||
public OfferListItem(Offer offer)
|
||||
{
|
||||
this.offer = offer;
|
||||
|
||||
@ -32,7 +31,7 @@ public class OfferListItem
|
||||
this.offerId = offer.getId();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Offer getOffer()
|
||||
{
|
||||
return offer;
|
||||
@ -40,25 +39,25 @@ public class OfferListItem
|
||||
|
||||
// called form table columns
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty dateProperty()
|
||||
{
|
||||
return this.date;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty priceProperty()
|
||||
{
|
||||
return this.price;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty amountProperty()
|
||||
{
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty volumeProperty()
|
||||
{
|
||||
return this.volume;
|
||||
|
@ -330,7 +330,7 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||
|
||||
bankAccountTypeTextField.setText(BtcFormatter.satoshiToString(trade.getTradeAmount()));
|
||||
holderNameTextField.setText(fiatPayed);
|
||||
primaryBankAccountIDTextField.setText(BtcFormatter.satoshiToString(FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE)));
|
||||
primaryBankAccountIDTextField.setText(BtcFormatter.satoshiToString(FeePolicy.CREATE_OFFER_FEE_depr.add(FeePolicy.TX_FEE_depr)));
|
||||
secondaryBankAccountIDTextField.setText(BtcFormatter.satoshiToString(trade.getCollateralAmount()));
|
||||
|
||||
holderNameCopyIcon.setVisible(false);
|
||||
|
@ -5,9 +5,10 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<VBox fx:id="rootContainer" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" spacing="10" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0"
|
||||
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1">
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1" fx:id="rootContainer" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" spacing="10" AnchorPane.bottomAnchor="0"
|
||||
AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns="http://javafx.com/javafx/8">
|
||||
<TableView id="orderbook-table" fx:id="openTradesTable" prefHeight="150.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="amountColumn" minWidth="120" text="Amount (Min.)">
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.gui.orders.pending;
|
||||
|
||||
import io.bitsquare.gui.market.orderbook.OrderBookListItem;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -10,16 +9,16 @@ public class PendingTradesListItem extends OrderBookListItem
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PendingTradesListItem.class);
|
||||
|
||||
@NotNull
|
||||
|
||||
private final Trade trade;
|
||||
|
||||
public PendingTradesListItem(@NotNull Trade trade)
|
||||
public PendingTradesListItem(Trade trade)
|
||||
{
|
||||
super(trade.getOffer());
|
||||
this.trade = trade;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Trade getTrade()
|
||||
{
|
||||
return trade;
|
||||
|
@ -9,7 +9,6 @@ import javafx.application.Platform;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.Dialogs;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings({"SameParameterValue", "WeakerAccess"})
|
||||
public class Popups
|
||||
@ -39,7 +38,7 @@ public class Popups
|
||||
|
||||
public static Action openConfirmPopup(String title, String message, String masthead)
|
||||
{
|
||||
@NotNull List<Action> actions = new ArrayList<>();
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(Dialog.Actions.OK);
|
||||
actions.add(Dialog.Actions.CANCEL);
|
||||
return Dialogs.create()
|
||||
@ -116,12 +115,12 @@ public class Popups
|
||||
|
||||
// Support handling of uncaught exception from any thread (also non gui thread)
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
|
||||
public static void handleUncaughtExceptions(@NotNull Throwable throwable)
|
||||
public static void handleUncaughtExceptions(Throwable throwable)
|
||||
{
|
||||
// while dev
|
||||
throwable.printStackTrace();
|
||||
|
||||
@NotNull Runnable runnable = () ->
|
||||
Runnable runnable = () ->
|
||||
{
|
||||
if (Throwables.getRootCause(throwable) instanceof BlockStoreException)
|
||||
{
|
||||
@ -151,7 +150,7 @@ public class Popups
|
||||
openWarningPopup("Not enough money available", "There is not enough money available. Please pay in first to your wallet.", null);
|
||||
}
|
||||
|
||||
public static Action openRegistrationMissingPopup(String title, String message, String masthead, @NotNull List<Dialogs.CommandLink> commandLinks, int selectedIndex)
|
||||
public static Action openRegistrationMissingPopup(String title, String message, String masthead, List<Dialogs.CommandLink> commandLinks, int selectedIndex)
|
||||
{
|
||||
return Dialogs.create()
|
||||
.owner(BitSquare.getStage())
|
||||
|
@ -38,16 +38,14 @@ import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
// TODO separate in 2 view/controllers
|
||||
public class SettingsController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private final User user;
|
||||
@NotNull
|
||||
|
||||
private final Settings settings;
|
||||
@NotNull
|
||||
|
||||
private final Storage storage;
|
||||
private final MessageFacade messageFacade;
|
||||
private final ObservableList<Locale> languageList;
|
||||
@ -85,7 +83,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SettingsController(User user, @NotNull Settings settings, @NotNull Storage storage, MessageFacade messageFacade)
|
||||
public SettingsController(User user, Settings settings, Storage storage, MessageFacade messageFacade)
|
||||
{
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
@ -142,15 +140,15 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
String pubKeyAsHex = Utils.bytesToHexString(new ECKey().getPubKey());
|
||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(messageFacade.getPubKey());
|
||||
@NotNull List<Locale> languages = new ArrayList<>();
|
||||
List<Locale> languages = new ArrayList<>();
|
||||
languages.add(LanguageUtil.getDefaultLanguageLocale());
|
||||
@NotNull List<Arbitrator.METHOD> arbitrationMethods = new ArrayList<>();
|
||||
List<Arbitrator.METHOD> arbitrationMethods = new ArrayList<>();
|
||||
arbitrationMethods.add(Arbitrator.METHOD.TLS_NOTARY);
|
||||
@NotNull List<Arbitrator.ID_VERIFICATION> idVerifications = new ArrayList<>();
|
||||
List<Arbitrator.ID_VERIFICATION> idVerifications = new ArrayList<>();
|
||||
idVerifications.add(Arbitrator.ID_VERIFICATION.PASSPORT);
|
||||
idVerifications.add(Arbitrator.ID_VERIFICATION.GOV_ID);
|
||||
|
||||
@NotNull Arbitrator arbitrator = new Arbitrator(pubKeyAsHex,
|
||||
Arbitrator arbitrator = new Arbitrator(pubKeyAsHex,
|
||||
messagePubKeyAsHex,
|
||||
"Manfred Karrer",
|
||||
Arbitrator.ID_TYPE.REAL_LIFE_ID,
|
||||
@ -187,7 +185,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
||||
public void setNavigationController(NavigationController navigationController)
|
||||
{
|
||||
|
||||
}
|
||||
@ -203,15 +201,15 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
// Interface implementation: NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ChildController navigateToView(@NotNull NavigationItem navigationItem)
|
||||
public ChildController navigateToView(NavigationItem navigationItem)
|
||||
{
|
||||
|
||||
if (childController != null)
|
||||
childController.cleanup();
|
||||
|
||||
@NotNull final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), Localisation.getResourceBundle());
|
||||
try
|
||||
{
|
||||
final Node view = loader.load();
|
||||
@ -219,7 +217,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
childController.setNavigationController(this);
|
||||
|
||||
final Stage rootStage = BitSquare.getStage();
|
||||
@NotNull final Stage stage = new Stage();
|
||||
final Stage stage = new Stage();
|
||||
stage.setTitle("Arbitrator selection");
|
||||
stage.setMinWidth(800);
|
||||
stage.setMinHeight(500);
|
||||
@ -229,7 +227,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
stage.setY(rootStage.getY() + 50);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(rootStage);
|
||||
@NotNull Scene scene = new Scene((Parent) view, 800, 600);
|
||||
Scene scene = new Scene((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.setOnHidden(windowEvent -> {
|
||||
if (navigationItem == NavigationItem.ARBITRATOR_OVERVIEW)
|
||||
@ -354,7 +352,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
languagesListView.setCellFactory(new Callback<ListView<Locale>, ListCell<Locale>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ListCell<Locale> call(ListView<Locale> list)
|
||||
{
|
||||
@ -379,7 +377,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final Locale item, boolean empty)
|
||||
public void updateItem(final Locale item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
@ -405,12 +403,12 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
languageComboBox.setConverter(new StringConverter<Locale>()
|
||||
{
|
||||
@Override
|
||||
public String toString(@NotNull Locale locale)
|
||||
public String toString(Locale locale)
|
||||
{
|
||||
return locale.getDisplayLanguage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Locale fromString(String s)
|
||||
{
|
||||
@ -425,12 +423,12 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
regionComboBox.setConverter(new StringConverter<Region>()
|
||||
{
|
||||
@Override
|
||||
public String toString(@NotNull Region region)
|
||||
public String toString(Region region)
|
||||
{
|
||||
return region.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Region fromString(String s)
|
||||
{
|
||||
@ -440,7 +438,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
countriesListView.setCellFactory(new Callback<ListView<Country>, ListCell<Country>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ListCell<Country> call(ListView<Country> list)
|
||||
{
|
||||
@ -466,7 +464,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final Country item, boolean empty)
|
||||
public void updateItem(final Country item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
@ -490,14 +488,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
countryComboBox.setConverter(new StringConverter<Country>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Country country)
|
||||
public String toString(Country country)
|
||||
{
|
||||
return country.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Country fromString(String s)
|
||||
{
|
||||
@ -511,7 +509,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
arbitratorsListView.setCellFactory(new Callback<ListView<Arbitrator>, ListCell<Arbitrator>>()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public ListCell<Arbitrator> call(ListView<Arbitrator> list)
|
||||
{
|
||||
@ -537,7 +535,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
|
||||
@Override
|
||||
public void updateItem(@Nullable final Arbitrator item, boolean empty)
|
||||
public void updateItem(final Arbitrator item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
@ -560,7 +558,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
arbitratorsListView.setItems(arbitratorList);
|
||||
}
|
||||
|
||||
private void addLanguage(@Nullable Locale item)
|
||||
private void addLanguage(Locale item)
|
||||
{
|
||||
if (!languageList.contains(item) && item != null)
|
||||
{
|
||||
@ -570,14 +568,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLanguage(@NotNull Locale item)
|
||||
private void removeLanguage(Locale item)
|
||||
{
|
||||
languageList.remove(item);
|
||||
settings.removeAcceptedLanguageLocale(item);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private void addCountry(@Nullable Country item)
|
||||
private void addCountry(Country item)
|
||||
{
|
||||
if (!countryList.contains(item) && item != null)
|
||||
{
|
||||
@ -587,14 +585,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCountry(@NotNull Country item)
|
||||
private void removeCountry(Country item)
|
||||
{
|
||||
countryList.remove(item);
|
||||
settings.removeAcceptedCountry(item);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private void removeArbitrator(@NotNull Arbitrator item)
|
||||
private void removeArbitrator(Arbitrator item)
|
||||
{
|
||||
arbitratorList.remove(item);
|
||||
settings.removeAcceptedArbitrator(item);
|
||||
@ -677,14 +675,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
bankAccountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts()));
|
||||
bankAccountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull BankAccount bankAccount)
|
||||
public String toString(BankAccount bankAccount)
|
||||
{
|
||||
return bankAccount.getAccountTitle();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public BankAccount fromString(String s)
|
||||
{
|
||||
@ -705,14 +703,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
bankAccountTypesComboBox.setItems(FXCollections.observableArrayList(BankAccountType.getAllBankAccountTypes()));
|
||||
bankAccountTypesComboBox.setConverter(new StringConverter<BankAccountType>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull BankAccountType bankAccountTypeInfo)
|
||||
public String toString(BankAccountType bankAccountTypeInfo)
|
||||
{
|
||||
return Localisation.get(bankAccountTypeInfo.toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public BankAccountType fromString(String s)
|
||||
{
|
||||
@ -733,14 +731,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
bankAccountCurrencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllCurrencies()));
|
||||
bankAccountCurrencyComboBox.setConverter(new StringConverter<Currency>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Currency currency)
|
||||
public String toString(Currency currency)
|
||||
{
|
||||
return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Currency fromString(String s)
|
||||
{
|
||||
@ -763,12 +761,12 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
bankAccountRegionComboBox.setConverter(new StringConverter<Region>()
|
||||
{
|
||||
@Override
|
||||
public String toString(@NotNull Region region)
|
||||
public String toString(Region region)
|
||||
{
|
||||
return region.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Region fromString(String s)
|
||||
{
|
||||
@ -778,14 +776,14 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
bankAccountCountryComboBox.setConverter(new StringConverter<Country>()
|
||||
{
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString(@NotNull Country country)
|
||||
public String toString(Country country)
|
||||
{
|
||||
return country.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Country fromString(String s)
|
||||
{
|
||||
@ -811,7 +809,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
{
|
||||
if (verifyBankAccountData())
|
||||
{
|
||||
@NotNull BankAccount bankAccount = new BankAccount(
|
||||
BankAccount bankAccount = new BankAccount(
|
||||
bankAccountTypesComboBox.getSelectionModel().getSelectedItem(),
|
||||
bankAccountCurrencyComboBox.getSelectionModel().getSelectedItem(),
|
||||
bankAccountCountryComboBox.getSelectionModel().getSelectedItem(),
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -17,7 +16,7 @@ public class BitSquareConverter
|
||||
try
|
||||
{
|
||||
return stringToDouble2(input);
|
||||
} catch (@NotNull NumberFormatException | NullPointerException e)
|
||||
} catch (NumberFormatException | NullPointerException e)
|
||||
{
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class BitSquareFormatter
|
||||
@ -20,34 +19,34 @@ public class BitSquareFormatter
|
||||
return formatDouble(price);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String formatPriceWithCurrencyPair(double price, @NotNull Currency currency)
|
||||
|
||||
public static String formatPriceWithCurrencyPair(double price, Currency currency)
|
||||
{
|
||||
return formatDouble(price) + " " + currency + "/BTC";
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
|
||||
public static String formatAmount(double amount, boolean useBTC, boolean exact)
|
||||
{
|
||||
return formatDouble(amount, (exact ? 4 : 2)) + (useBTC ? " BTC" : "");
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
|
||||
public static String formatAmount(double amount, boolean useBTC)
|
||||
{
|
||||
return formatAmount(amount, useBTC, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatAmount(double amount)
|
||||
{
|
||||
return formatAmount(amount, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
|
||||
public static String formatAmountWithMinAmount(double amount, double minAmount, boolean useBTC)
|
||||
{
|
||||
if (useBTC)
|
||||
@ -56,7 +55,7 @@ public class BitSquareFormatter
|
||||
return formatDouble(amount) + " (" + formatDouble(minAmount) + ")";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatAmountWithMinAmount(double amount, double minAmount)
|
||||
{
|
||||
return formatAmountWithMinAmount(amount, minAmount, false);
|
||||
@ -67,41 +66,41 @@ public class BitSquareFormatter
|
||||
return formatDouble(volume);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String formatVolume(double volume, @NotNull Currency currency)
|
||||
|
||||
public static String formatVolume(double volume, Currency currency)
|
||||
{
|
||||
return formatDouble(volume) + " " + currency;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String formatVolumeWithMinVolume(double volume, double minVolume, @NotNull Currency currency)
|
||||
|
||||
public static String formatVolumeWithMinVolume(double volume, double minVolume, Currency currency)
|
||||
{
|
||||
return formatDouble(volume) + " " + currency + " (" + formatDouble(minVolume) + " " + currency + ")";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatVolumeWithMinVolume(double volume, double minVolume)
|
||||
{
|
||||
return formatDouble(volume) + " (" + formatDouble(minVolume) + ")";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatCollateral(double collateral, double amount)
|
||||
{
|
||||
return formatPercent(collateral) + " (" + formatDouble(collateral * amount, 4) + " BTC)";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatDirection(Direction direction, boolean allUpperCase)
|
||||
{
|
||||
@NotNull String result = (direction == Direction.BUY) ? "Buy" : "Sell";
|
||||
String result = (direction == Direction.BUY) ? "Buy" : "Sell";
|
||||
if (allUpperCase)
|
||||
result = result.toUpperCase();
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String formatList(@NotNull List<String> list)
|
||||
|
||||
public static String formatList(List<String> list)
|
||||
{
|
||||
String s = list.toString();
|
||||
return s.substring(1, s.length() - 1);
|
||||
@ -114,32 +113,32 @@ public class BitSquareFormatter
|
||||
|
||||
public static String formatDouble(double value, int fractionDigits)
|
||||
{
|
||||
@NotNull DecimalFormat decimalFormat = getDecimalFormat(fractionDigits);
|
||||
DecimalFormat decimalFormat = getDecimalFormat(fractionDigits);
|
||||
return decimalFormat.format(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static DecimalFormat getDecimalFormat(int fractionDigits)
|
||||
{
|
||||
@NotNull DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.getDefault());
|
||||
DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.getDefault());
|
||||
decimalFormat.setMinimumFractionDigits(fractionDigits);
|
||||
decimalFormat.setMaximumFractionDigits(fractionDigits);
|
||||
decimalFormat.setGroupingUsed(false);
|
||||
return decimalFormat;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private static String formatPercent(double value)
|
||||
{
|
||||
return value * 100 + "%";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String countryLocalesToString(@NotNull List<Country> countries)
|
||||
|
||||
public static String countryLocalesToString(List<Country> countries)
|
||||
{
|
||||
String result = "";
|
||||
int i = 0;
|
||||
for (@NotNull Country country : countries)
|
||||
for (Country country : countries)
|
||||
{
|
||||
result += country.getName();
|
||||
i++;
|
||||
@ -149,11 +148,11 @@ public class BitSquareFormatter
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String languageLocalesToString(@NotNull List<Locale> languageLocales)
|
||||
public static String languageLocalesToString(List<Locale> languageLocales)
|
||||
{
|
||||
String result = "";
|
||||
int i = 0;
|
||||
for (@NotNull Locale locale : languageLocales)
|
||||
for (Locale locale : languageLocales)
|
||||
{
|
||||
result += locale.getDisplayLanguage();
|
||||
i++;
|
||||
@ -163,12 +162,12 @@ public class BitSquareFormatter
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String arbitrationMethodsToString(@NotNull List<Arbitrator.METHOD> items)
|
||||
|
||||
public static String arbitrationMethodsToString(List<Arbitrator.METHOD> items)
|
||||
{
|
||||
String result = "";
|
||||
int i = 0;
|
||||
for (@NotNull Arbitrator.METHOD item : items)
|
||||
for (Arbitrator.METHOD item : items)
|
||||
{
|
||||
result += Localisation.get(item.toString());
|
||||
i++;
|
||||
@ -178,12 +177,12 @@ public class BitSquareFormatter
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String arbitrationIDVerificationsToString(@NotNull List<Arbitrator.ID_VERIFICATION> items)
|
||||
|
||||
public static String arbitrationIDVerificationsToString(List<Arbitrator.ID_VERIFICATION> items)
|
||||
{
|
||||
String result = "";
|
||||
int i = 0;
|
||||
for (@NotNull Arbitrator.ID_VERIFICATION item : items)
|
||||
for (Arbitrator.ID_VERIFICATION item : items)
|
||||
{
|
||||
result += Localisation.get(item.toString());
|
||||
i++;
|
||||
@ -193,7 +192,7 @@ public class BitSquareFormatter
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static String formatDateTime(Date date)
|
||||
{
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.getDefault());
|
||||
|
@ -6,8 +6,6 @@ import javafx.scene.effect.BlurType;
|
||||
import javafx.scene.effect.DropShadow;
|
||||
import javafx.scene.effect.Effect;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class BitSquareValidator
|
||||
@ -21,24 +19,24 @@ public class BitSquareValidator
|
||||
textFieldsNotEmpty(textFields);
|
||||
}
|
||||
|
||||
public static void resetTextFields(@NotNull TextField... textFields)
|
||||
public static void resetTextFields(TextField... textFields)
|
||||
{
|
||||
for (@NotNull TextField textField : textFields)
|
||||
for (TextField textField : textFields)
|
||||
{
|
||||
textField.setStyle("-fx-border-color: null");
|
||||
textField.setEffect(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void textFieldsNotEmpty(@NotNull TextField... textFields) throws ValidationException
|
||||
public static void textFieldsNotEmpty(TextField... textFields) throws ValidationException
|
||||
{
|
||||
for (@NotNull TextField textField : textFields)
|
||||
for (TextField textField : textFields)
|
||||
{
|
||||
textFieldNotEmpty(textField);
|
||||
}
|
||||
}
|
||||
|
||||
public static void textFieldNotEmpty(@NotNull TextField textField) throws ValidationException
|
||||
public static void textFieldNotEmpty(TextField textField) throws ValidationException
|
||||
{
|
||||
if (!validateStringNotEmpty(textField.getText()))
|
||||
{
|
||||
@ -54,15 +52,15 @@ public class BitSquareValidator
|
||||
textFieldsHasDoubleValue(textFields);
|
||||
}
|
||||
|
||||
public static void textFieldsHasDoubleValue(@NotNull TextField... textFields) throws ValidationException
|
||||
public static void textFieldsHasDoubleValue(TextField... textFields) throws ValidationException
|
||||
{
|
||||
for (@NotNull TextField textField : textFields)
|
||||
for (TextField textField : textFields)
|
||||
{
|
||||
textFieldHasDoubleValue(textField);
|
||||
}
|
||||
}
|
||||
|
||||
public static void textFieldHasDoubleValue(@NotNull TextField textField) throws ValidationException
|
||||
public static void textFieldHasDoubleValue(TextField textField) throws ValidationException
|
||||
{
|
||||
if (!validateStringAsDouble(textField.getText()))
|
||||
{
|
||||
@ -74,7 +72,7 @@ public class BitSquareValidator
|
||||
|
||||
//TODO
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public static void textFieldBankAccountPrimaryIDIsValid(@NotNull TextField textField, BankAccountType bankAccountType) throws ValidationException
|
||||
public static void textFieldBankAccountPrimaryIDIsValid(TextField textField, BankAccountType bankAccountType) throws ValidationException
|
||||
{
|
||||
if (!validateStringNotEmpty(textField.getText()))
|
||||
{
|
||||
@ -86,7 +84,7 @@ public class BitSquareValidator
|
||||
|
||||
//TODO
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public static void textFieldBankAccountSecondaryIDIsValid(@NotNull TextField textField, BankAccountType bankAccountType) throws ValidationException
|
||||
public static void textFieldBankAccountSecondaryIDIsValid(TextField textField, BankAccountType bankAccountType) throws ValidationException
|
||||
{
|
||||
if (!validateStringNotEmpty(textField.getText()))
|
||||
{
|
||||
@ -96,7 +94,7 @@ public class BitSquareValidator
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean validateStringsAsDouble(@NotNull String... inputs)
|
||||
public static boolean validateStringsAsDouble(String... inputs)
|
||||
{
|
||||
boolean result = true;
|
||||
for (String input : inputs)
|
||||
@ -114,13 +112,13 @@ public class BitSquareValidator
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
Double.parseDouble(input);
|
||||
return true;
|
||||
} catch (@NotNull NumberFormatException | NullPointerException e)
|
||||
} catch (NumberFormatException | NullPointerException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean validateStringsNotEmpty(@NotNull String... inputs)
|
||||
public static boolean validateStringsNotEmpty(String... inputs)
|
||||
{
|
||||
boolean result = true;
|
||||
for (String input : inputs)
|
||||
@ -130,7 +128,7 @@ public class BitSquareValidator
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean validateStringNotEmpty(@Nullable String input)
|
||||
public static boolean validateStringNotEmpty(String input)
|
||||
{
|
||||
return input != null && !input.isEmpty() && !" ".equals(input);
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -18,20 +16,20 @@ import org.slf4j.LoggerFactory;
|
||||
public class ConfidenceDisplay
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class);
|
||||
@Nullable
|
||||
|
||||
private WalletEventListener walletEventListener;
|
||||
|
||||
@NotNull
|
||||
|
||||
private Wallet wallet;
|
||||
@NotNull
|
||||
|
||||
private Label confirmationLabel;
|
||||
@Nullable
|
||||
|
||||
private TextField balanceTextField;
|
||||
private Transaction transaction;
|
||||
@NotNull
|
||||
|
||||
private ConfidenceProgressIndicator progressIndicator;
|
||||
|
||||
public ConfidenceDisplay(@NotNull Wallet wallet, @NotNull Label confirmationLabel, @NotNull TextField balanceTextField, @NotNull ConfidenceProgressIndicator progressIndicator)
|
||||
public ConfidenceDisplay(Wallet wallet, Label confirmationLabel, TextField balanceTextField, ConfidenceProgressIndicator progressIndicator)
|
||||
{
|
||||
this.wallet = wallet;
|
||||
this.confirmationLabel = confirmationLabel;
|
||||
@ -47,21 +45,21 @@ public class ConfidenceDisplay
|
||||
walletEventListener = new WalletEventListener()
|
||||
{
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, @NotNull BigInteger newBalance)
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||
{
|
||||
updateBalance(newBalance);
|
||||
// log.debug("onCoinsReceived " + newBalance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, @NotNull Transaction tx)
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||
{
|
||||
updateConfidence(tx);
|
||||
// log.debug("onTransactionConfidenceChanged tx " + tx.getHashAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCoinsSent(Wallet wallet, Transaction tx, BigInteger prevBalance, @NotNull BigInteger newBalance)
|
||||
public void onCoinsSent(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||
{
|
||||
updateBalance(newBalance);
|
||||
}
|
||||
@ -89,7 +87,7 @@ public class ConfidenceDisplay
|
||||
wallet.addEventListener(walletEventListener);
|
||||
}
|
||||
|
||||
public ConfidenceDisplay(@NotNull Wallet wallet, @NotNull Label confirmationLabel, @NotNull final Transaction transaction, @NotNull ConfidenceProgressIndicator progressIndicator)
|
||||
public ConfidenceDisplay(Wallet wallet, Label confirmationLabel, final Transaction transaction, ConfidenceProgressIndicator progressIndicator)
|
||||
{
|
||||
this.wallet = wallet;
|
||||
this.confirmationLabel = confirmationLabel;
|
||||
@ -106,7 +104,7 @@ public class ConfidenceDisplay
|
||||
walletEventListener = new WalletEventListener()
|
||||
{
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, @NotNull Transaction tx, BigInteger prevBalance, @NotNull BigInteger newBalance)
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||
{
|
||||
if (tx.getHashAsString().equals(transaction.getHashAsString()))
|
||||
updateBalance(newBalance);
|
||||
@ -114,7 +112,7 @@ public class ConfidenceDisplay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, @NotNull Transaction tx)
|
||||
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||
{
|
||||
if (tx.getHashAsString().equals(transaction.getHashAsString()))
|
||||
updateConfidence(transaction);
|
||||
@ -122,7 +120,7 @@ public class ConfidenceDisplay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCoinsSent(Wallet wallet, @NotNull Transaction tx, BigInteger prevBalance, @NotNull BigInteger newBalance)
|
||||
public void onCoinsSent(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||
{
|
||||
if (tx.getHashAsString().equals(transaction.getHashAsString()))
|
||||
updateBalance(newBalance);
|
||||
@ -160,7 +158,7 @@ public class ConfidenceDisplay
|
||||
balanceTextField.setText("");
|
||||
}
|
||||
|
||||
private void updateBalance(@NotNull BigInteger balance)
|
||||
private void updateBalance(BigInteger balance)
|
||||
{
|
||||
if (balance.compareTo(BigInteger.ZERO) > 0)
|
||||
{
|
||||
@ -169,8 +167,8 @@ public class ConfidenceDisplay
|
||||
progressIndicator.setProgress(-1);
|
||||
|
||||
Set<Transaction> transactions = wallet.getTransactions(false);
|
||||
@Nullable Transaction latestTransaction = null;
|
||||
for (@NotNull Transaction transaction : transactions)
|
||||
Transaction latestTransaction = null;
|
||||
for (Transaction transaction : transactions)
|
||||
{
|
||||
if (latestTransaction != null)
|
||||
{
|
||||
@ -192,7 +190,7 @@ public class ConfidenceDisplay
|
||||
balanceTextField.setText(BtcFormatter.satoshiToString(balance));
|
||||
}
|
||||
|
||||
private void updateConfidence(@NotNull Transaction tx)
|
||||
private void updateConfidence(Transaction tx)
|
||||
{
|
||||
TransactionConfidence confidence = tx.getConfidence();
|
||||
double progressIndicatorSize = 50;
|
||||
|
@ -6,48 +6,46 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
//TODO to be removed
|
||||
@SuppressWarnings({"SameParameterValue", "UnusedReturnValue"})
|
||||
public class FormBuilder
|
||||
{
|
||||
@NotNull
|
||||
public static Label addLabel(@NotNull GridPane gridPane, String title, String value, int row)
|
||||
|
||||
public static Label addLabel(GridPane gridPane, String title, String value, int row)
|
||||
{
|
||||
gridPane.add(new Label(title), 0, row);
|
||||
@NotNull Label valueLabel = new Label(value);
|
||||
Label valueLabel = new Label(value);
|
||||
gridPane.add(valueLabel, 1, row);
|
||||
return valueLabel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Label addHeaderLabel(@NotNull GridPane gridPane, String title, int row, int column)
|
||||
|
||||
public static Label addHeaderLabel(GridPane gridPane, String title, int row, int column)
|
||||
{
|
||||
@NotNull Label headerLabel = new Label(title);
|
||||
Label headerLabel = new Label(title);
|
||||
headerLabel.setId("form-header-text");
|
||||
gridPane.add(headerLabel, column, row);
|
||||
return headerLabel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Label addHeaderLabel(@NotNull GridPane gridPane, String title, int row)
|
||||
|
||||
public static Label addHeaderLabel(GridPane gridPane, String title, int row)
|
||||
{
|
||||
return addHeaderLabel(gridPane, title, row, 0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TextField addTextField(@NotNull GridPane gridPane, String title, String value, int row)
|
||||
|
||||
public static TextField addTextField(GridPane gridPane, String title, String value, int row)
|
||||
{
|
||||
return addTextField(gridPane, title, value, row, false, false);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static TextField addTextField(@NotNull GridPane gridPane, String title, String value, int row, boolean editable, boolean selectable)
|
||||
public static TextField addTextField(GridPane gridPane, String title, String value, int row, boolean editable, boolean selectable)
|
||||
{
|
||||
gridPane.add(new Label(title), 0, row);
|
||||
@NotNull TextField textField = new TextField(value);
|
||||
TextField textField = new TextField(value);
|
||||
gridPane.add(textField, 1, row);
|
||||
textField.setMouseTransparent(!selectable && !editable);
|
||||
textField.setEditable(editable);
|
||||
@ -55,15 +53,15 @@ public class FormBuilder
|
||||
return textField;
|
||||
}
|
||||
|
||||
public static void addVSpacer(@NotNull GridPane gridPane, int row)
|
||||
public static void addVSpacer(GridPane gridPane, int row)
|
||||
{
|
||||
gridPane.add(new VSpacer(10), 0, row);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Button addButton(@NotNull GridPane gridPane, String title, int row)
|
||||
|
||||
public static Button addButton(GridPane gridPane, String title, int row)
|
||||
{
|
||||
@NotNull Button button = new Button(title);
|
||||
Button button = new Button(title);
|
||||
gridPane.add(button, 1, row);
|
||||
return button;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.gui.util;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Icons
|
||||
{
|
||||
@ -27,13 +26,13 @@ public class Icons
|
||||
public static final String SELL = "/images/sell.png";
|
||||
public static final String REMOVE = "/images/removeOffer.png";
|
||||
|
||||
@NotNull
|
||||
|
||||
public static Image getIconImage(String iconName)
|
||||
{
|
||||
return new Image(Icons.class.getResourceAsStream(iconName));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static ImageView getIconImageView(String iconName)
|
||||
{
|
||||
return new ImageView(new Image(Icons.class.getResourceAsStream(iconName)));
|
||||
|
@ -6,7 +6,6 @@ import javafx.scene.Node;
|
||||
import javafx.scene.effect.GaussianBlur;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.util.Duration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
@ -24,16 +23,16 @@ public class Transitions
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public static void fadeIn(Node ui, int time)
|
||||
{
|
||||
@NotNull FadeTransition ft = new FadeTransition(Duration.millis(time), ui);
|
||||
FadeTransition ft = new FadeTransition(Duration.millis(time), ui);
|
||||
ft.setFromValue(0.0);
|
||||
ft.setToValue(1.0);
|
||||
ft.play();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Animation fadeOut(@NotNull Node ui)
|
||||
|
||||
public static Animation fadeOut(Node ui)
|
||||
{
|
||||
@NotNull FadeTransition ft = new FadeTransition(Duration.millis(UI_ANIMATION_TIME), ui);
|
||||
FadeTransition ft = new FadeTransition(Duration.millis(UI_ANIMATION_TIME), ui);
|
||||
ft.setFromValue(ui.getOpacity());
|
||||
ft.setToValue(0.0);
|
||||
ft.play();
|
||||
@ -41,37 +40,37 @@ public class Transitions
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
@NotNull
|
||||
public static Animation fadeOutAndRemove(@NotNull Node ui)
|
||||
|
||||
public static Animation fadeOutAndRemove(Node ui)
|
||||
{
|
||||
@NotNull Animation animation = fadeOut(ui);
|
||||
Animation animation = fadeOut(ui);
|
||||
animation.setOnFinished(actionEvent -> ((Pane) (ui.getParent())).getChildren().remove(ui));
|
||||
return animation;
|
||||
}
|
||||
|
||||
public static void blurOut(@NotNull Node node)
|
||||
public static void blurOut(Node node)
|
||||
{
|
||||
blurOut(node, UI_ANIMATION_TIME);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public static void blurOut(@NotNull Node node, int time)
|
||||
public static void blurOut(Node node, int time)
|
||||
{
|
||||
@NotNull GaussianBlur blur = new GaussianBlur(0.0);
|
||||
GaussianBlur blur = new GaussianBlur(0.0);
|
||||
node.setEffect(blur);
|
||||
@NotNull Timeline timeline = new Timeline();
|
||||
@NotNull KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
|
||||
@NotNull KeyFrame kf = new KeyFrame(Duration.millis(time), kv);
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
|
||||
KeyFrame kf = new KeyFrame(Duration.millis(time), kv);
|
||||
timeline.getKeyFrames().add(kf);
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
public static void blurIn(@NotNull Node node)
|
||||
public static void blurIn(Node node)
|
||||
{
|
||||
@NotNull GaussianBlur blur = (GaussianBlur) node.getEffect();
|
||||
@NotNull Timeline timeline = new Timeline();
|
||||
@NotNull KeyValue kv = new KeyValue(blur.radiusProperty(), 0.0);
|
||||
@NotNull KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME), kv);
|
||||
GaussianBlur blur = (GaussianBlur) node.getEffect();
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue kv = new KeyValue(blur.radiusProperty(), 0.0);
|
||||
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME), kv);
|
||||
timeline.getKeyFrames().add(kf);
|
||||
timeline.setOnFinished(actionEvent -> node.setEffect(null));
|
||||
timeline.play();
|
||||
|
@ -2,21 +2,19 @@ package io.bitsquare.locale;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Country implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5930294199097793187L;
|
||||
|
||||
@NotNull
|
||||
|
||||
private final String code;
|
||||
@NotNull
|
||||
|
||||
private final String name;
|
||||
@NotNull
|
||||
|
||||
private final Region region;
|
||||
|
||||
public Country(@NotNull String code, @NotNull String name, @NotNull Region region)
|
||||
public Country(String code, String name, Region region)
|
||||
{
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
@ -28,7 +26,7 @@ public class Country implements Serializable
|
||||
return Objects.hashCode(code);
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object obj)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof Country))
|
||||
return false;
|
||||
@ -39,26 +37,25 @@ public class Country implements Serializable
|
||||
return code.equals(other.getCode());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Region getRegion()
|
||||
{
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -4,8 +4,6 @@ import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CountryUtil
|
||||
{
|
||||
@ -215,13 +213,13 @@ public class CountryUtil
|
||||
{"OC", "Oceania"}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
|
||||
public static List<Region> getAllRegions()
|
||||
{
|
||||
final List<Region> allRegions = new ArrayList<>();
|
||||
|
||||
@NotNull String regionCode = "NA";
|
||||
@NotNull Region region = new Region(regionCode, getRegionName(regionCode));
|
||||
String regionCode = "NA";
|
||||
Region region = new Region(regionCode, getRegionName(regionCode));
|
||||
allRegions.add(region);
|
||||
|
||||
regionCode = "SA";
|
||||
@ -247,12 +245,12 @@ public class CountryUtil
|
||||
return allRegions;
|
||||
}
|
||||
|
||||
public static List<Country> getAllCountriesFor(@Nullable Region selectedRegion)
|
||||
public static List<Country> getAllCountriesFor(Region selectedRegion)
|
||||
{
|
||||
return Lists.newArrayList(Collections2.filter(getAllCountries(), country -> selectedRegion != null && country != null && selectedRegion.equals(country.getRegion())));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private static List<Country> getAllCountries()
|
||||
{
|
||||
final List<Country> allCountries = new ArrayList<>();
|
||||
@ -266,7 +264,7 @@ public class CountryUtil
|
||||
return allCountries;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static Country getDefaultCountry()
|
||||
{
|
||||
final Locale locale = new Locale("", Locale.getDefault().getCountry());
|
||||
@ -275,8 +273,8 @@ public class CountryUtil
|
||||
return new Country(locale.getCountry(), locale.getDisplayCountry(), region);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getRegionName(@NotNull final String regionCode)
|
||||
|
||||
private static String getRegionName(final String regionCode)
|
||||
{
|
||||
for (final String[] regionName : regionCodeToName)
|
||||
{
|
||||
@ -286,10 +284,10 @@ public class CountryUtil
|
||||
return regionCode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private static List<Locale> getAllCountryLocales()
|
||||
{
|
||||
@NotNull List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
|
||||
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
|
||||
Set<Locale> allLocalesAsSet = allLocales.stream().filter(locale -> !"".equals(locale.getCountry())).map(locale -> new Locale("", locale.getCountry(), "")).collect(Collectors.toSet());
|
||||
/*
|
||||
same as:
|
||||
@ -308,8 +306,8 @@ public class CountryUtil
|
||||
return allLocales;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getRegionCode(@NotNull String countryCode)
|
||||
|
||||
private static String getRegionCode(String countryCode)
|
||||
{
|
||||
if (!countryCode.isEmpty() && countryCodeList.contains(countryCode))
|
||||
return regionCodeList.get(countryCodeList.indexOf(countryCode));
|
||||
|
@ -2,11 +2,10 @@ package io.bitsquare.locale;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CurrencyUtil
|
||||
{
|
||||
@NotNull
|
||||
|
||||
public static List<Currency> getAllCurrencies()
|
||||
{
|
||||
final ArrayList<Currency> mainCurrencies = new ArrayList<>();
|
||||
@ -37,7 +36,7 @@ public class CurrencyUtil
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static Currency getDefaultCurrency()
|
||||
{
|
||||
return NumberFormat.getNumberInstance(Locale.getDefault()).getCurrency();
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.locale;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LanguageUtil
|
||||
{
|
||||
@ -23,10 +22,10 @@ public class LanguageUtil
|
||||
return list;
|
||||
} */
|
||||
|
||||
@NotNull
|
||||
|
||||
public static List<Locale> getAllLanguageLocales()
|
||||
{
|
||||
@NotNull List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
|
||||
List<Locale> allLocales = Arrays.asList(Locale.getAvailableLocales());
|
||||
final Set<Locale> allLocalesAsSet = allLocales.stream().filter(locale -> !"".equals(locale.getLanguage())).map(locale -> new Locale(locale.getLanguage(), "")).collect(Collectors.toSet());
|
||||
allLocales = new ArrayList<>();
|
||||
allLocales.addAll(allLocalesAsSet);
|
||||
@ -34,7 +33,7 @@ public class LanguageUtil
|
||||
return allLocales;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static Locale getDefaultLanguageLocale()
|
||||
{
|
||||
return new Locale(Locale.getDefault().getLanguage(), "");
|
||||
|
@ -10,8 +10,6 @@ import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -19,14 +17,14 @@ public class Localisation
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Localisation.class);
|
||||
|
||||
@NotNull
|
||||
|
||||
public static ResourceBundle getResourceBundle()
|
||||
{
|
||||
return ResourceBundle.getBundle("i18n.displayStrings", new UTF8Control());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String get(@NotNull String key)
|
||||
|
||||
public static String get(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -38,8 +36,8 @@ public class Localisation
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String get(@NotNull String key, String... arguments)
|
||||
|
||||
public static String get(String key, String... arguments)
|
||||
{
|
||||
return MessageFormat.format(Localisation.get(key), arguments);
|
||||
}
|
||||
@ -47,14 +45,14 @@ public class Localisation
|
||||
|
||||
class UTF8Control extends ResourceBundle.Control
|
||||
{
|
||||
@Nullable
|
||||
public ResourceBundle newBundle(@NotNull String baseName, @NotNull Locale locale, @NotNull String format, @NotNull ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException
|
||||
|
||||
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException
|
||||
{
|
||||
// The below is a copy of the default implementation.
|
||||
final String bundleName = toBundleName(baseName, locale);
|
||||
final String resourceName = toResourceName(bundleName, "properties");
|
||||
@Nullable ResourceBundle bundle = null;
|
||||
@Nullable InputStream stream = null;
|
||||
ResourceBundle bundle = null;
|
||||
InputStream stream = null;
|
||||
if (reload)
|
||||
{
|
||||
final URL url = loader.getResource(resourceName);
|
||||
|
@ -2,19 +2,17 @@ package io.bitsquare.locale;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Region implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5930294199097793187L;
|
||||
|
||||
@NotNull
|
||||
|
||||
private final String code;
|
||||
@NotNull
|
||||
|
||||
private final String name;
|
||||
|
||||
public Region(@NotNull String code, @NotNull String name)
|
||||
public Region(String code, String name)
|
||||
{
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
@ -25,30 +23,30 @@ public class Region implements Serializable
|
||||
return Objects.hashCode(code);
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object obj)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof Region))
|
||||
return false;
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
@NotNull Region other = (Region) obj;
|
||||
Region other = (Region) obj;
|
||||
return code.equals(other.getCode());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -27,8 +27,6 @@ import net.tomp2p.rpc.ObjectDataReply;
|
||||
import net.tomp2p.storage.Data;
|
||||
import net.tomp2p.storage.StorageDisk;
|
||||
import net.tomp2p.utils.Utils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -44,7 +42,7 @@ public class MessageFacade
|
||||
private static final String PONG = "pong";
|
||||
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
||||
private static final int MASTER_PEER_PORT = 5000;
|
||||
@NotNull
|
||||
|
||||
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
||||
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
|
||||
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
||||
@ -54,7 +52,7 @@ public class MessageFacade
|
||||
private final List<PingPeerListener> pingPeerListeners = new ArrayList<>();
|
||||
private final BooleanProperty isDirty = new SimpleBooleanProperty(false);
|
||||
private Peer myPeer;
|
||||
@Nullable
|
||||
|
||||
private KeyPair keyPair;
|
||||
private Long lastTimeStamp = -3L;
|
||||
|
||||
@ -148,18 +146,18 @@ public class MessageFacade
|
||||
// Arbitrators
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void addArbitrator(@NotNull Arbitrator arbitrator) throws IOException
|
||||
public void addArbitrator(Arbitrator arbitrator) throws IOException
|
||||
{
|
||||
Number160 locationKey = Number160.createHash("Arbitrators");
|
||||
final Number160 contentKey = Number160.createHash(arbitrator.getId());
|
||||
@NotNull final Data arbitratorData = new Data(arbitrator);
|
||||
final Data arbitratorData = new Data(arbitrator);
|
||||
//offerData.setTTLSeconds(5);
|
||||
final FutureDHT addFuture = myPeer.put(locationKey).setData(contentKey, arbitratorData).start();
|
||||
//final FutureDHT addFuture = myPeer.add(locationKey).setData(offerData).start();
|
||||
addFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||
public void operationComplete(BaseFuture future) throws Exception
|
||||
{
|
||||
Platform.runLater(() -> onArbitratorAdded(arbitratorData, future.isSuccess(), locationKey));
|
||||
}
|
||||
@ -180,7 +178,7 @@ public class MessageFacade
|
||||
getArbitratorsFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||
public void operationComplete(BaseFuture future) throws Exception
|
||||
{
|
||||
final Map<Number160, Data> dataMap = getArbitratorsFuture.getDataMap();
|
||||
Platform.runLater(() -> onArbitratorsReceived(dataMap, future.isSuccess()));
|
||||
@ -190,7 +188,7 @@ public class MessageFacade
|
||||
|
||||
private void onArbitratorsReceived(Map<Number160, Data> dataMap, boolean success)
|
||||
{
|
||||
for (@NotNull ArbitratorListener arbitratorListener : arbitratorListeners)
|
||||
for (ArbitratorListener arbitratorListener : arbitratorListeners)
|
||||
arbitratorListener.onArbitratorsReceived(dataMap, success);
|
||||
}
|
||||
|
||||
@ -200,29 +198,29 @@ public class MessageFacade
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//TODO use Offer and do proper serialisation here
|
||||
public void addOffer(@NotNull Offer offer) throws IOException
|
||||
public void addOffer(Offer offer) throws IOException
|
||||
{
|
||||
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
|
||||
final Number160 contentKey = Number160.createHash(offer.getId());
|
||||
@NotNull final Data offerData = new Data(offer);
|
||||
final Data offerData = new Data(offer);
|
||||
//offerData.setTTLSeconds(5);
|
||||
final FutureDHT addFuture = myPeer.put(locationKey).setData(contentKey, offerData).start();
|
||||
//final FutureDHT addFuture = myPeer.add(locationKey).setData(offerData).start();
|
||||
addFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||
public void operationComplete(BaseFuture future) throws Exception
|
||||
{
|
||||
Platform.runLater(() -> onOfferAdded(offerData, future.isSuccess(), locationKey));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onOfferAdded(Data offerData, boolean success, @NotNull Number160 locationKey)
|
||||
private void onOfferAdded(Data offerData, boolean success, Number160 locationKey)
|
||||
{
|
||||
setDirty(locationKey);
|
||||
|
||||
for (@NotNull OrderBookListener orderBookListener : orderBookListeners)
|
||||
for (OrderBookListener orderBookListener : orderBookListeners)
|
||||
orderBookListener.onOfferAdded(offerData, success);
|
||||
}
|
||||
|
||||
@ -238,7 +236,7 @@ public class MessageFacade
|
||||
getOffersFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||
public void operationComplete(BaseFuture future) throws Exception
|
||||
{
|
||||
final Map<Number160, Data> dataMap = getOffersFuture.getDataMap();
|
||||
Platform.runLater(() -> onOffersReceived(dataMap, future.isSuccess()));
|
||||
@ -248,7 +246,7 @@ public class MessageFacade
|
||||
|
||||
private void onOffersReceived(Map<Number160, Data> dataMap, boolean success)
|
||||
{
|
||||
for (@NotNull OrderBookListener orderBookListener : orderBookListeners)
|
||||
for (OrderBookListener orderBookListener : orderBookListeners)
|
||||
orderBookListener.onOffersReceived(dataMap, success);
|
||||
}
|
||||
|
||||
@ -256,7 +254,7 @@ public class MessageFacade
|
||||
// Remove offer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void removeOffer(@NotNull Offer offer)
|
||||
public void removeOffer(Offer offer)
|
||||
{
|
||||
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
|
||||
Number160 contentKey = Number160.createHash(offer.getId());
|
||||
@ -265,20 +263,20 @@ public class MessageFacade
|
||||
removeFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||
public void operationComplete(BaseFuture future) throws Exception
|
||||
{
|
||||
@NotNull Data data = removeFuture.getData();
|
||||
Data data = removeFuture.getData();
|
||||
Platform.runLater(() -> onOfferRemoved(data, future.isSuccess(), locationKey));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onOfferRemoved(@NotNull Data data, boolean success, @NotNull Number160 locationKey)
|
||||
private void onOfferRemoved(Data data, boolean success, Number160 locationKey)
|
||||
{
|
||||
log.debug("onOfferRemoved");
|
||||
setDirty(locationKey);
|
||||
|
||||
for (@NotNull OrderBookListener orderBookListener : orderBookListeners)
|
||||
for (OrderBookListener orderBookListener : orderBookListeners)
|
||||
orderBookListener.onOfferRemoved(data, success);
|
||||
}
|
||||
|
||||
@ -287,13 +285,13 @@ public class MessageFacade
|
||||
// Check dirty flag for a location key
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public BooleanProperty getIsDirtyProperty()
|
||||
{
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public void getDirtyFlag(@NotNull Currency currency)
|
||||
public void getDirtyFlag(Currency currency)
|
||||
{
|
||||
Number160 locationKey = Number160.createHash(currency.getCurrencyCode());
|
||||
FutureDHT getFuture = myPeer.get(getDirtyLocationKey(locationKey)).start();
|
||||
@ -336,12 +334,12 @@ public class MessageFacade
|
||||
lastTimeStamp++;
|
||||
}
|
||||
|
||||
private Number160 getDirtyLocationKey(@NotNull Number160 locationKey)
|
||||
private Number160 getDirtyLocationKey(Number160 locationKey)
|
||||
{
|
||||
return Number160.createHash(locationKey + "Dirty");
|
||||
}
|
||||
|
||||
private void setDirty(@NotNull Number160 locationKey)
|
||||
private void setDirty(Number160 locationKey)
|
||||
{
|
||||
// we don't want to get an update from dirty for own changes, so update the lastTimeStamp to omit a change trigger
|
||||
lastTimeStamp = System.currentTimeMillis();
|
||||
@ -425,18 +423,18 @@ public class MessageFacade
|
||||
// Find peer address
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void getPeerAddress(final String pubKeyAsHex, @NotNull AddressLookupListener listener)
|
||||
public void getPeerAddress(final String pubKeyAsHex, AddressLookupListener listener)
|
||||
{
|
||||
final Number160 location = Number160.createHash(pubKeyAsHex);
|
||||
final FutureDHT getPeerAddressFuture = myPeer.get(location).start();
|
||||
getPeerAddressFuture.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(@NotNull BaseFuture baseFuture) throws Exception
|
||||
public void operationComplete(BaseFuture baseFuture) throws Exception
|
||||
{
|
||||
if (baseFuture.isSuccess() && getPeerAddressFuture.getData() != null)
|
||||
{
|
||||
@NotNull final PeerAddress peerAddress = (PeerAddress) getPeerAddressFuture.getData().getObject();
|
||||
final PeerAddress peerAddress = (PeerAddress) getPeerAddressFuture.getData().getObject();
|
||||
Platform.runLater(() -> onAddressFound(peerAddress, listener));
|
||||
}
|
||||
else
|
||||
@ -447,12 +445,12 @@ public class MessageFacade
|
||||
});
|
||||
}
|
||||
|
||||
private void onAddressFound(final PeerAddress peerAddress, @NotNull AddressLookupListener listener)
|
||||
private void onAddressFound(final PeerAddress peerAddress, AddressLookupListener listener)
|
||||
{
|
||||
listener.onResult(peerAddress);
|
||||
}
|
||||
|
||||
private void onGetPeerAddressFailed(@NotNull AddressLookupListener listener)
|
||||
private void onGetPeerAddressFailed(AddressLookupListener listener)
|
||||
{
|
||||
listener.onFailed();
|
||||
}
|
||||
@ -462,7 +460,7 @@ public class MessageFacade
|
||||
// Trade process
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void sendTradeMessage(final PeerAddress peerAddress, final TradeMessage tradeMessage, @NotNull TradeMessageListener listener)
|
||||
public void sendTradeMessage(final PeerAddress peerAddress, final TradeMessage tradeMessage, TradeMessageListener listener)
|
||||
{
|
||||
final PeerConnection peerConnection = myPeer.createPeerConnection(peerAddress, 10);
|
||||
final FutureResponse sendFuture = myPeer.sendDirect(peerConnection).setObject(tradeMessage).start();
|
||||
@ -484,12 +482,12 @@ public class MessageFacade
|
||||
);
|
||||
}
|
||||
|
||||
private void onSendTradingMessageResult(@NotNull TradeMessageListener listener)
|
||||
private void onSendTradingMessageResult(TradeMessageListener listener)
|
||||
{
|
||||
listener.onResult();
|
||||
}
|
||||
|
||||
private void onSendTradingMessageFailed(@NotNull TradeMessageListener listener)
|
||||
private void onSendTradingMessageFailed(TradeMessageListener listener)
|
||||
{
|
||||
listener.onFailed();
|
||||
}
|
||||
@ -499,7 +497,7 @@ public class MessageFacade
|
||||
// Process incoming tradingMessage
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void processTradingMessage(@NotNull TradeMessage tradeMessage, PeerAddress sender)
|
||||
private void processTradingMessage(TradeMessage tradeMessage, PeerAddress sender)
|
||||
{
|
||||
//TODO change to map (key: offerID) instead of list (offererPaymentProtocols, takerPaymentProtocols)
|
||||
log.info("processTradingMessage " + tradeMessage.getType());
|
||||
@ -507,39 +505,39 @@ public class MessageFacade
|
||||
{
|
||||
case REQUEST_TAKE_OFFER:
|
||||
// That is used to initiate the OffererPaymentProtocol and to show incoming requests in the view
|
||||
for (@NotNull TakeOfferRequestListener takeOfferRequestListener : takeOfferRequestListeners)
|
||||
for (TakeOfferRequestListener takeOfferRequestListener : takeOfferRequestListeners)
|
||||
takeOfferRequestListener.onTakeOfferRequested(tradeMessage, sender);
|
||||
break;
|
||||
case ACCEPT_TAKE_OFFER_REQUEST:
|
||||
for (@NotNull TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
for (TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
takeOfferTradeListener.onTakeOfferRequestAccepted();
|
||||
break;
|
||||
case REJECT_TAKE_OFFER_REQUEST:
|
||||
for (@NotNull TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
for (TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
takeOfferTradeListener.onTakeOfferRequestRejected();
|
||||
break;
|
||||
case TAKE_OFFER_FEE_PAYED:
|
||||
for (@NotNull OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
for (OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
offererPaymentProtocol.onTakeOfferFeePayed(tradeMessage);
|
||||
break;
|
||||
case REQUEST_TAKER_DEPOSIT_PAYMENT:
|
||||
for (@NotNull TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
for (TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
takeOfferTradeListener.onTakerDepositPaymentRequested(tradeMessage);
|
||||
break;
|
||||
case REQUEST_OFFERER_DEPOSIT_PUBLICATION:
|
||||
for (@NotNull OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
for (OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
offererPaymentProtocol.onDepositTxReadyForPublication(tradeMessage);
|
||||
break;
|
||||
case DEPOSIT_TX_PUBLISHED:
|
||||
for (@NotNull TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
for (TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
takeOfferTradeListener.onDepositTxPublished(tradeMessage);
|
||||
break;
|
||||
case BANK_TX_INITED:
|
||||
for (@NotNull TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
for (TakerPaymentProtocol takeOfferTradeListener : takerPaymentProtocols)
|
||||
takeOfferTradeListener.onBankTransferInited(tradeMessage);
|
||||
break;
|
||||
case PAYOUT_TX_PUBLISHED:
|
||||
for (@NotNull OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
for (OffererPaymentProtocol offererPaymentProtocol : offererPaymentProtocols)
|
||||
offererPaymentProtocol.onPayoutTxPublished(tradeMessage);
|
||||
break;
|
||||
|
||||
@ -566,7 +564,7 @@ public class MessageFacade
|
||||
final Data data = getPeerAddressFuture.getData();
|
||||
if (data != null && data.getObject() instanceof PeerAddress)
|
||||
{
|
||||
@NotNull final PeerAddress peerAddress = (PeerAddress) data.getObject();
|
||||
final PeerAddress peerAddress = (PeerAddress) data.getObject();
|
||||
Platform.runLater(() -> onAddressFoundPingPeer(peerAddress));
|
||||
}
|
||||
}
|
||||
@ -589,7 +587,7 @@ public class MessageFacade
|
||||
{
|
||||
if (sendFuture.isSuccess())
|
||||
{
|
||||
@NotNull final String pong = (String) sendFuture.getObject();
|
||||
final String pong = (String) sendFuture.getObject();
|
||||
Platform.runLater(() -> onResponseFromPing(PONG.equals(pong)));
|
||||
}
|
||||
else
|
||||
@ -609,7 +607,7 @@ public class MessageFacade
|
||||
|
||||
private void onResponseFromPing(boolean success)
|
||||
{
|
||||
for (@NotNull PingPeerListener pingPeerListener : pingPeerListeners)
|
||||
for (PingPeerListener pingPeerListener : pingPeerListeners)
|
||||
pingPeerListener.onPingPeerResult(success);
|
||||
}
|
||||
|
||||
@ -619,7 +617,6 @@ public class MessageFacade
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Nullable
|
||||
public PublicKey getPubKey()
|
||||
{
|
||||
return keyPair.getPublic();
|
||||
@ -698,7 +695,6 @@ public class MessageFacade
|
||||
keyPair = DSAKeyUtil.getKeyPair();
|
||||
myPeer = new PeerMaker(keyPair).setPorts(port).makeAndListen();
|
||||
final FutureBootstrap futureBootstrap = myPeer.bootstrap().setBroadcast().setPorts(MASTER_PEER_PORT).start();
|
||||
futureBootstrap.awaitUninterruptibly();
|
||||
futureBootstrap.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
@ -708,7 +704,6 @@ public class MessageFacade
|
||||
{
|
||||
PeerAddress masterPeerAddress = futureBootstrap.getBootstrapTo().iterator().next();
|
||||
final FutureDiscover futureDiscover = myPeer.discover().setPeerAddress(masterPeerAddress).start();
|
||||
futureDiscover.awaitUninterruptibly();
|
||||
futureDiscover.addListener(new BaseFutureListener<BaseFuture>()
|
||||
{
|
||||
@Override
|
||||
@ -759,7 +754,7 @@ public class MessageFacade
|
||||
//noinspection Convert2Lambda
|
||||
myPeer.setObjectDataReply(new ObjectDataReply()
|
||||
{
|
||||
@Nullable
|
||||
|
||||
@Override
|
||||
public Object reply(PeerAddress sender, Object request) throws Exception
|
||||
{
|
||||
|
@ -8,18 +8,16 @@ import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Settings implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 7995048077355006861L;
|
||||
|
||||
@NotNull
|
||||
|
||||
private List<Locale> acceptedLanguageLocales = new ArrayList<>();
|
||||
@NotNull
|
||||
|
||||
private List<Country> acceptedCountryLocales = new ArrayList<>();
|
||||
@NotNull
|
||||
|
||||
private List<Arbitrator> acceptedArbitrators = new ArrayList<>();
|
||||
private int maxCollateral;
|
||||
private int minCollateral;
|
||||
@ -38,7 +36,7 @@ public class Settings implements Serializable
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void updateFromStorage(@Nullable Settings savedSettings)
|
||||
public void updateFromStorage(Settings savedSettings)
|
||||
{
|
||||
if (savedSettings != null)
|
||||
{
|
||||
@ -50,35 +48,35 @@ public class Settings implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
public void addAcceptedLanguageLocale(@NotNull Locale locale)
|
||||
public void addAcceptedLanguageLocale(Locale locale)
|
||||
{
|
||||
if (!acceptedLanguageLocales.contains(locale))
|
||||
acceptedLanguageLocales.add(locale);
|
||||
}
|
||||
|
||||
public void removeAcceptedLanguageLocale(@NotNull Locale item)
|
||||
public void removeAcceptedLanguageLocale(Locale item)
|
||||
{
|
||||
acceptedLanguageLocales.remove(item);
|
||||
}
|
||||
|
||||
public void addAcceptedCountry(@NotNull Country locale)
|
||||
public void addAcceptedCountry(Country locale)
|
||||
{
|
||||
if (!acceptedCountryLocales.contains(locale))
|
||||
acceptedCountryLocales.add(locale);
|
||||
}
|
||||
|
||||
public void removeAcceptedCountry(@NotNull Country item)
|
||||
public void removeAcceptedCountry(Country item)
|
||||
{
|
||||
acceptedCountryLocales.remove(item);
|
||||
}
|
||||
|
||||
public void addAcceptedArbitrator(@NotNull Arbitrator arbitrator)
|
||||
public void addAcceptedArbitrator(Arbitrator arbitrator)
|
||||
{
|
||||
if (!acceptedArbitrators.contains(arbitrator))
|
||||
acceptedArbitrators.add(arbitrator);
|
||||
}
|
||||
|
||||
public void removeAcceptedArbitrator(@NotNull Arbitrator item)
|
||||
public void removeAcceptedArbitrator(Arbitrator item)
|
||||
{
|
||||
acceptedArbitrators.remove(item);
|
||||
}
|
||||
@ -88,19 +86,19 @@ public class Settings implements Serializable
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<Arbitrator> getAcceptedArbitrators()
|
||||
{
|
||||
return acceptedArbitrators;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<Locale> getAcceptedLanguageLocales()
|
||||
{
|
||||
return acceptedLanguageLocales;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<Country> getAcceptedCountries()
|
||||
{
|
||||
return acceptedCountryLocales;
|
||||
@ -108,10 +106,10 @@ public class Settings implements Serializable
|
||||
|
||||
//TODO
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
@Nullable
|
||||
public Arbitrator getRandomArbitrator(@SuppressWarnings("UnusedParameters") @NotNull Integer collateral, @SuppressWarnings("UnusedParameters") @NotNull BigInteger amount)
|
||||
|
||||
public Arbitrator getRandomArbitrator(@SuppressWarnings("UnusedParameters") Integer collateral, @SuppressWarnings("UnusedParameters") BigInteger amount)
|
||||
{
|
||||
@NotNull List<Arbitrator> candidates = new ArrayList<>();
|
||||
List<Arbitrator> candidates = new ArrayList<>();
|
||||
//noinspection Convert2streamapi
|
||||
for (Arbitrator arbitrator : acceptedArbitrators)
|
||||
{
|
||||
|
@ -11,8 +11,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -26,7 +24,7 @@ public class Storage
|
||||
|
||||
private final String prefix = BitSquare.ID + "_pref";
|
||||
private final File storageFile = FileUtil.getFile(prefix, "ser");
|
||||
@NotNull
|
||||
|
||||
@GuardedBy("lock")
|
||||
private Map<String, Serializable> rootMap = new HashMap<>();
|
||||
private boolean dirty;
|
||||
@ -74,49 +72,49 @@ public class Storage
|
||||
}
|
||||
|
||||
// Map
|
||||
public void write(@NotNull String key, @NotNull Map<String, ? extends Serializable> value)
|
||||
public void write(String key, Map<String, ? extends Serializable> value)
|
||||
{
|
||||
write(key, (Serializable) value);
|
||||
}
|
||||
|
||||
public void write(@NotNull Object classInstance, @NotNull String propertyKey, @NotNull Map<String, ? extends Serializable> value)
|
||||
public void write(Object classInstance, String propertyKey, Map<String, ? extends Serializable> value)
|
||||
{
|
||||
write(classInstance.getClass().getName() + "." + propertyKey, value);
|
||||
}
|
||||
|
||||
public void write(@NotNull Object classInstance, @NotNull Map<String, ? extends Serializable> value)
|
||||
public void write(Object classInstance, Map<String, ? extends Serializable> value)
|
||||
{
|
||||
write(classInstance.getClass().getName(), value);
|
||||
}
|
||||
|
||||
// List
|
||||
public void write(@NotNull String key, @NotNull List<? extends Serializable> value)
|
||||
public void write(String key, List<? extends Serializable> value)
|
||||
{
|
||||
write(key, (Serializable) value);
|
||||
}
|
||||
|
||||
public void write(@NotNull Object classInstance, @NotNull String propertyKey, @NotNull List<? extends Serializable> value)
|
||||
public void write(Object classInstance, String propertyKey, List<? extends Serializable> value)
|
||||
{
|
||||
write(classInstance.getClass().getName() + "." + propertyKey, value);
|
||||
}
|
||||
|
||||
public void write(@NotNull Object classInstance, @NotNull List<? extends Serializable> value)
|
||||
public void write(Object classInstance, List<? extends Serializable> value)
|
||||
{
|
||||
write(classInstance.getClass().getName(), value);
|
||||
}
|
||||
|
||||
// Serializable
|
||||
public void write(@NotNull Object classInstance, @NotNull String propertyKey, @NotNull Serializable value)
|
||||
public void write(Object classInstance, String propertyKey, Serializable value)
|
||||
{
|
||||
write(classInstance.getClass().getName() + "." + propertyKey, value);
|
||||
}
|
||||
|
||||
public void write(@NotNull Object classInstance, @NotNull Serializable value)
|
||||
public void write(Object classInstance, Serializable value)
|
||||
{
|
||||
write(classInstance.getClass().getName(), value);
|
||||
}
|
||||
|
||||
public void write(@NotNull String key, @NotNull Serializable value)
|
||||
public void write(String key, Serializable value)
|
||||
{
|
||||
// log.trace("Write object with key = " + key + " / value = " + value);
|
||||
try
|
||||
@ -132,20 +130,19 @@ public class Storage
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public Serializable read(@NotNull Object classInstance)
|
||||
public Serializable read(Object classInstance)
|
||||
{
|
||||
return read(classInstance.getClass().getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Serializable read(@NotNull Object classInstance, @NotNull String propertyKey)
|
||||
|
||||
public Serializable read(Object classInstance, String propertyKey)
|
||||
{
|
||||
return read(classInstance.getClass().getName() + "." + propertyKey);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Serializable read(@NotNull String key)
|
||||
|
||||
public Serializable read(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -180,7 +177,7 @@ public class Storage
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
|
||||
private Map<String, Serializable> readRootMap()
|
||||
{
|
||||
try
|
||||
@ -205,12 +202,12 @@ public class Storage
|
||||
}
|
||||
}
|
||||
|
||||
} catch (@NotNull FileNotFoundException e)
|
||||
} catch (FileNotFoundException e)
|
||||
{
|
||||
|
||||
log.trace("File not found is ok for the first run.");
|
||||
return null;
|
||||
} catch (@NotNull ClassNotFoundException | IOException e2)
|
||||
} catch (ClassNotFoundException | IOException e2)
|
||||
{
|
||||
e2.printStackTrace();
|
||||
log.error("Could not read rootMap. " + e2);
|
||||
@ -218,7 +215,7 @@ public class Storage
|
||||
}
|
||||
}
|
||||
|
||||
private void saveObjectToFile(@NotNull Serializable serializable)
|
||||
private void saveObjectToFile(Serializable serializable)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -266,8 +263,8 @@ public class Storage
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object readObjectFromFile(@NotNull File file) throws IOException, ClassNotFoundException
|
||||
|
||||
private Object readObjectFromFile(File file) throws IOException, ClassNotFoundException
|
||||
{
|
||||
lock.lock();
|
||||
try (final FileInputStream fileInputStream = new FileInputStream(file);
|
||||
|
@ -3,7 +3,6 @@ package io.bitsquare.trade;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Contract implements Serializable
|
||||
{
|
||||
@ -90,7 +89,7 @@ public class Contract implements Serializable
|
||||
return offererMessagePubKeyAsHex;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ import io.bitsquare.user.Arbitrator;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Offer implements Serializable
|
||||
{
|
||||
@ -18,7 +17,7 @@ public class Offer implements Serializable
|
||||
private final Currency currency;
|
||||
|
||||
private final String id;
|
||||
@NotNull
|
||||
|
||||
private final Date creationDate;
|
||||
|
||||
private final double price;
|
||||
@ -173,7 +172,7 @@ public class Offer implements Serializable
|
||||
return bankAccountUID;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@ -196,7 +195,7 @@ public class Offer implements Serializable
|
||||
'}';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Date getCreationDate()
|
||||
{
|
||||
return creationDate;
|
||||
|
@ -5,7 +5,6 @@ import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public class Trade implements Serializable
|
||||
@ -23,7 +22,7 @@ public class Trade implements Serializable
|
||||
private String takerSignature;
|
||||
private Transaction depositTransaction;
|
||||
private Transaction payoutTransaction;
|
||||
@NotNull
|
||||
|
||||
private State state = State.NONE;
|
||||
|
||||
public Trade(Offer offer)
|
||||
@ -123,37 +122,37 @@ public class Trade implements Serializable
|
||||
payoutTxChangedProperty.set(!payoutTxChangedProperty.get());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public State getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State state)
|
||||
public void setState(State state)
|
||||
{
|
||||
this.state = state;
|
||||
stateChangedProperty.set(state.toString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleBooleanProperty getDepositTxChangedProperty()
|
||||
{
|
||||
return depositTxChangedProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleBooleanProperty getContractChangedProperty()
|
||||
{
|
||||
return contractChangedProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleBooleanProperty getPayoutTxChangedProperty()
|
||||
{
|
||||
return payoutTxChangedProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleStringProperty getStateChangedProperty()
|
||||
{
|
||||
return stateChangedProperty;
|
||||
@ -164,7 +163,7 @@ public class Trade implements Serializable
|
||||
return getTradeAmount().multiply(BigInteger.valueOf(getOffer().getCollateral())).divide(BigInteger.valueOf(100));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -22,7 +22,6 @@ import java.util.Map;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -37,16 +36,16 @@ public class Trading
|
||||
private final Map<String, OffererPaymentProtocol> offererPaymentProtocols = new HashMap<>();
|
||||
private final String storageKey;
|
||||
private final User user;
|
||||
@NotNull
|
||||
|
||||
private final Storage storage;
|
||||
private final MessageFacade messageFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
private final StringProperty newTradeProperty = new SimpleStringProperty();
|
||||
@NotNull
|
||||
|
||||
private Map<String, Offer> myOffers = new HashMap<>();
|
||||
@NotNull
|
||||
|
||||
private Map<String, Trade> trades = new HashMap<>();
|
||||
|
||||
|
||||
@ -57,7 +56,7 @@ public class Trading
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject
|
||||
public Trading(User user,
|
||||
@NotNull Storage storage,
|
||||
Storage storage,
|
||||
MessageFacade messageFacade,
|
||||
BlockChainFacade blockChainFacade,
|
||||
WalletFacade walletFacade,
|
||||
@ -96,7 +95,7 @@ public class Trading
|
||||
storage.write(storageKey + ".offers", myOffers);
|
||||
}
|
||||
|
||||
public void addOffer(@NotNull Offer offer) throws IOException
|
||||
public void addOffer(Offer offer) throws IOException
|
||||
{
|
||||
if (myOffers.containsKey(offer.getId()))
|
||||
throw new IllegalStateException("offers contains already a offer with the ID " + offer.getId());
|
||||
@ -107,7 +106,7 @@ public class Trading
|
||||
messageFacade.addOffer(offer);
|
||||
}
|
||||
|
||||
public void removeOffer(@NotNull Offer offer) throws IOException
|
||||
public void removeOffer(Offer offer) throws IOException
|
||||
{
|
||||
myOffers.remove(offer.getId());
|
||||
saveOffers();
|
||||
@ -115,15 +114,15 @@ public class Trading
|
||||
messageFacade.removeOffer(offer);
|
||||
}
|
||||
|
||||
public boolean isOfferTradable(@NotNull Offer offer)
|
||||
public boolean isOfferTradable(Offer offer)
|
||||
{
|
||||
return !trades.containsKey(offer.getId());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Trade createTrade(@NotNull Offer offer)
|
||||
|
||||
public Trade createTrade(Offer offer)
|
||||
{
|
||||
@NotNull Trade trade = new Trade(offer);
|
||||
Trade trade = new Trade(offer);
|
||||
trades.put(offer.getId(), trade);
|
||||
//TODO for testing
|
||||
//storage.write(storageKey + ".trades", trades);
|
||||
@ -133,41 +132,41 @@ public class Trading
|
||||
return trade;
|
||||
}
|
||||
|
||||
public void removeTrade(@NotNull Trade trade)
|
||||
public void removeTrade(Trade trade)
|
||||
{
|
||||
trades.remove(trade.getId());
|
||||
storage.write(storageKey + ".trades", trades);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final StringProperty getNewTradeProperty()
|
||||
{
|
||||
return this.newTradeProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TakerPaymentProtocol addTakerPaymentProtocol(@NotNull Trade trade, TakerPaymentProtocolListener listener)
|
||||
|
||||
public TakerPaymentProtocol addTakerPaymentProtocol(Trade trade, TakerPaymentProtocolListener listener)
|
||||
{
|
||||
@NotNull TakerPaymentProtocol takerPaymentProtocol = new TakerPaymentProtocol(trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user);
|
||||
TakerPaymentProtocol takerPaymentProtocol = new TakerPaymentProtocol(trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user);
|
||||
takerPaymentProtocols.put(trade.getId(), takerPaymentProtocol);
|
||||
return takerPaymentProtocol;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
OffererPaymentProtocol addOffererPaymentProtocol(@NotNull Trade trade, OffererPaymentProtocolListener listener)
|
||||
|
||||
OffererPaymentProtocol addOffererPaymentProtocol(Trade trade, OffererPaymentProtocolListener listener)
|
||||
{
|
||||
@NotNull OffererPaymentProtocol offererPaymentProtocol = new OffererPaymentProtocol(trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user);
|
||||
OffererPaymentProtocol offererPaymentProtocol = new OffererPaymentProtocol(trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user);
|
||||
offererPaymentProtocols.put(trade.getId(), offererPaymentProtocol);
|
||||
return offererPaymentProtocol;
|
||||
}
|
||||
|
||||
public void createOffererPaymentProtocol(@NotNull TradeMessage tradeMessage, PeerAddress sender)
|
||||
public void createOffererPaymentProtocol(TradeMessage tradeMessage, PeerAddress sender)
|
||||
{
|
||||
Offer offer = myOffers.get(tradeMessage.getOfferUID());
|
||||
if (isOfferTradable(offer))
|
||||
{
|
||||
@NotNull Trade trade = createTrade(offer);
|
||||
@NotNull OffererPaymentProtocol offererPaymentProtocol = addOffererPaymentProtocol(trade, new OffererPaymentProtocolListener()
|
||||
Trade trade = createTrade(offer);
|
||||
OffererPaymentProtocol offererPaymentProtocol = addOffererPaymentProtocol(trade, new OffererPaymentProtocolListener()
|
||||
{
|
||||
@Override
|
||||
public void onProgress(double progress)
|
||||
@ -196,7 +195,7 @@ public class Trading
|
||||
@Override
|
||||
public void onPayoutTxPublished(String payoutTxAsHex)
|
||||
{
|
||||
@NotNull Transaction payoutTx = new Transaction(walletFacade.getWallet().getParams(), Utils.parseAsHexOrBase58(payoutTxAsHex));
|
||||
Transaction payoutTx = new Transaction(walletFacade.getWallet().getParams(), Utils.parseAsHexOrBase58(payoutTxAsHex));
|
||||
trade.setPayoutTransaction(payoutTx);
|
||||
trade.setState(Trade.State.COMPLETED);
|
||||
log.debug("trading onPayoutTxPublished");
|
||||
@ -233,7 +232,7 @@ public class Trading
|
||||
|
||||
|
||||
// 6
|
||||
public void releaseBTC(String tradeUID, @NotNull TradeMessage tradeMessage)
|
||||
public void releaseBTC(String tradeUID, TradeMessage tradeMessage)
|
||||
{
|
||||
takerPaymentProtocols.get(tradeUID).releaseBTC(tradeMessage);
|
||||
}
|
||||
@ -242,13 +241,13 @@ public class Trading
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public Map<String, Trade> getTrades()
|
||||
{
|
||||
return trades;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Map<String, Offer> getOffers()
|
||||
{
|
||||
return myOffers;
|
||||
|
@ -23,8 +23,6 @@ import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -77,7 +75,7 @@ public class OrderBook implements OrderBookListener
|
||||
messageFacade.getOffers(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
|
||||
}
|
||||
|
||||
public void removeOffer(@NotNull Offer offer)
|
||||
public void removeOffer(Offer offer)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -88,11 +86,11 @@ public class OrderBook implements OrderBookListener
|
||||
}
|
||||
}
|
||||
|
||||
public void applyFilter(@Nullable OrderBookFilter orderBookFilter)
|
||||
public void applyFilter(OrderBookFilter orderBookFilter)
|
||||
{
|
||||
filteredList.setPredicate(orderBookListItem -> {
|
||||
@NotNull Offer offer = orderBookListItem.getOffer();
|
||||
@Nullable BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
Offer offer = orderBookListItem.getOffer();
|
||||
BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
|
||||
if (orderBookFilter == null
|
||||
|| currentBankAccount == null
|
||||
@ -177,41 +175,41 @@ public class OrderBook implements OrderBookListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onOfferAdded(@NotNull Data offerData, boolean success)
|
||||
public void onOfferAdded(Data offerData, boolean success)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
@NotNull Offer offer = (Offer) offerDataObject;
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
allOffers.add(new OrderBookListItem(offer));
|
||||
}
|
||||
} catch (@NotNull ClassNotFoundException | IOException e)
|
||||
} catch (ClassNotFoundException | IOException e)
|
||||
{
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOffersReceived(@Nullable Map<Number160, Data> dataMap, boolean success)
|
||||
public void onOffersReceived(Map<Number160, Data> dataMap, boolean success)
|
||||
{
|
||||
if (success && dataMap != null)
|
||||
{
|
||||
allOffers.clear();
|
||||
|
||||
for (@NotNull Data offerData : dataMap.values())
|
||||
for (Data offerData : dataMap.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
@NotNull Offer offer = (Offer) offerDataObject;
|
||||
@NotNull OrderBookListItem orderBookListItem = new OrderBookListItem(offer);
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
OrderBookListItem orderBookListItem = new OrderBookListItem(offer);
|
||||
allOffers.add(orderBookListItem);
|
||||
}
|
||||
} catch (@NotNull ClassNotFoundException | IOException e)
|
||||
} catch (ClassNotFoundException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -224,7 +222,7 @@ public class OrderBook implements OrderBookListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOfferRemoved(@NotNull Data offerData, boolean success)
|
||||
public void onOfferRemoved(Data offerData, boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
@ -233,10 +231,10 @@ public class OrderBook implements OrderBookListener
|
||||
Object offerDataObject = offerData.getObject();
|
||||
if (offerDataObject instanceof Offer)
|
||||
{
|
||||
@NotNull Offer offer = (Offer) offerDataObject;
|
||||
Offer offer = (Offer) offerDataObject;
|
||||
allOffers.removeIf(orderBookListItem -> orderBookListItem.getOffer().getId().equals(offer.getId()));
|
||||
}
|
||||
} catch (@NotNull ClassNotFoundException | IOException e)
|
||||
} catch (ClassNotFoundException | IOException e)
|
||||
{
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
@ -252,7 +250,7 @@ public class OrderBook implements OrderBookListener
|
||||
// Getter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public SortedList<OrderBookListItem> getOfferList()
|
||||
{
|
||||
return offerList;
|
||||
@ -263,9 +261,9 @@ public class OrderBook implements OrderBookListener
|
||||
// Private Methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private boolean countryInList(@NotNull Country countryToMatch, @NotNull List<Country> list)
|
||||
private boolean countryInList(Country countryToMatch, List<Country> list)
|
||||
{
|
||||
for (@NotNull Country country : list)
|
||||
for (Country country : list)
|
||||
{
|
||||
if (country.getCode().equals(countryToMatch.getCode()))
|
||||
return true;
|
||||
@ -273,11 +271,11 @@ public class OrderBook implements OrderBookListener
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean languagesInList(@NotNull List<Locale> list1, @NotNull List<Locale> list2)
|
||||
private boolean languagesInList(List<Locale> list1, List<Locale> list2)
|
||||
{
|
||||
for (@NotNull Locale locale1 : list2)
|
||||
for (Locale locale1 : list2)
|
||||
{
|
||||
for (@NotNull Locale locale2 : list1)
|
||||
for (Locale locale2 : list1)
|
||||
{
|
||||
if (locale1.getLanguage().equals(locale2.getLanguage()))
|
||||
return true;
|
||||
@ -286,11 +284,11 @@ public class OrderBook implements OrderBookListener
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean arbitratorInList(@Nullable Arbitrator arbitratorToMatch, @NotNull List<Arbitrator> list)
|
||||
private boolean arbitratorInList(Arbitrator arbitratorToMatch, List<Arbitrator> list)
|
||||
{
|
||||
if (arbitratorToMatch != null)
|
||||
{
|
||||
for (@NotNull Arbitrator arbitrator : list)
|
||||
for (Arbitrator arbitrator : list)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.trade.orderbook;
|
||||
|
||||
import io.bitsquare.trade.Direction;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OrderBookFilter
|
||||
{
|
||||
@ -53,7 +52,7 @@ public class OrderBookFilter
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleBooleanProperty getDirectionChangedProperty()
|
||||
{
|
||||
return directionChangedProperty;
|
||||
|
@ -19,8 +19,6 @@ import io.bitsquare.util.Utilities;
|
||||
import java.math.BigInteger;
|
||||
import javafx.util.Pair;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -32,19 +30,19 @@ public class OffererPaymentProtocol
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererPaymentProtocol.class);
|
||||
|
||||
@NotNull
|
||||
|
||||
private final Trade trade;
|
||||
private final Offer offer;
|
||||
private final OffererPaymentProtocolListener offererPaymentProtocolListener;
|
||||
@NotNull
|
||||
|
||||
private final MessageFacade messageFacade;
|
||||
@NotNull
|
||||
|
||||
private final WalletFacade walletFacade;
|
||||
@NotNull
|
||||
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
@NotNull
|
||||
|
||||
private final CryptoFacade cryptoFacade;
|
||||
@NotNull
|
||||
|
||||
private final User user;
|
||||
private PeerAddress peerAddress;
|
||||
private boolean isTakeOfferRequested;
|
||||
@ -57,13 +55,13 @@ public class OffererPaymentProtocol
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public OffererPaymentProtocol(@NotNull Trade trade,
|
||||
public OffererPaymentProtocol(Trade trade,
|
||||
OffererPaymentProtocolListener offererPaymentProtocolListener,
|
||||
@NotNull MessageFacade messageFacade,
|
||||
@NotNull WalletFacade walletFacade,
|
||||
@NotNull BlockChainFacade blockChainFacade,
|
||||
@NotNull CryptoFacade cryptoFacade,
|
||||
@NotNull User user)
|
||||
MessageFacade messageFacade,
|
||||
WalletFacade walletFacade,
|
||||
BlockChainFacade blockChainFacade,
|
||||
CryptoFacade cryptoFacade,
|
||||
User user)
|
||||
{
|
||||
checkNotNull(trade);
|
||||
checkNotNull(messageFacade);
|
||||
@ -110,8 +108,8 @@ public class OffererPaymentProtocol
|
||||
if (isTakeOfferRequested)
|
||||
{
|
||||
log.debug("1.3 offer already requested REJECT_TAKE_OFFER_REQUEST");
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REJECT_TAKE_OFFER_REQUEST, trade.getId());
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REJECT_TAKE_OFFER_REQUEST, trade.getId());
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -134,7 +132,7 @@ public class OffererPaymentProtocol
|
||||
else
|
||||
{
|
||||
log.debug("1.3 offer not yet requested");
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -162,7 +160,7 @@ public class OffererPaymentProtocol
|
||||
offererPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
// 1.3a Send accept take offer message
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.ACCEPT_TAKE_OFFER_REQUEST, trade.getId());
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.ACCEPT_TAKE_OFFER_REQUEST, trade.getId());
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
}
|
||||
}
|
||||
@ -177,7 +175,7 @@ public class OffererPaymentProtocol
|
||||
// Step 2.3
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onTakeOfferFeePayed(@NotNull TradeMessage requestTradeMessage)
|
||||
public void onTakeOfferFeePayed(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.3 onTakeOfferFeePayed");
|
||||
trade.setTakeOfferFeeTxID(requestTradeMessage.getTakeOfferFeeTxID());
|
||||
@ -190,7 +188,7 @@ public class OffererPaymentProtocol
|
||||
// Step 2.4
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void verifyTakeOfferFeePayment(@NotNull TradeMessage requestTradeMessage)
|
||||
private void verifyTakeOfferFeePayment(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.4 verifyTakeOfferFeePayment");
|
||||
//TODO just dummy now, will be async
|
||||
@ -207,7 +205,7 @@ public class OffererPaymentProtocol
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void createDepositTx(@NotNull TradeMessage requestTradeMessage)
|
||||
private void createDepositTx(TradeMessage requestTradeMessage)
|
||||
{
|
||||
checkNotNull(requestTradeMessage);
|
||||
|
||||
@ -230,7 +228,7 @@ public class OffererPaymentProtocol
|
||||
log.debug("arbitrator pubkey " + arbitratorPubKey);
|
||||
try
|
||||
{
|
||||
@NotNull Transaction tx = walletFacade.offererCreatesMSTxAndAddPayment(offererInputAmount, offererPubKey, takerPubKey, arbitratorPubKey, trade.getId());
|
||||
Transaction tx = walletFacade.offererCreatesMSTxAndAddPayment(offererInputAmount, offererPubKey, takerPubKey, arbitratorPubKey, trade.getId());
|
||||
preparedOffererDepositTxAsHex = Utils.bytesToHexString(tx.bitcoinSerialize());
|
||||
long offererTxOutIndex = tx.getInput(0).getOutpoint().getIndex();
|
||||
log.debug("2.5 deposit tx created: " + tx);
|
||||
@ -250,12 +248,12 @@ public class OffererPaymentProtocol
|
||||
// Step 2.6
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void sendDepositTxAndDataForContract(@NotNull String preparedOffererDepositTxAsHex, String offererPubKey, long offererTxOutIndex)
|
||||
private void sendDepositTxAndDataForContract(String preparedOffererDepositTxAsHex, String offererPubKey, long offererTxOutIndex)
|
||||
{
|
||||
log.debug("2.6 sendDepositTxAndDataForContract");
|
||||
// Send all the requested data
|
||||
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -277,10 +275,10 @@ public class OffererPaymentProtocol
|
||||
|
||||
offererPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
@Nullable BankAccount bankAccount = user.getBankAccount(offer.getBankAccountUID());
|
||||
BankAccount bankAccount = user.getBankAccount(offer.getBankAccountUID());
|
||||
String accountID = user.getAccountID();
|
||||
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_TAKER_DEPOSIT_PAYMENT, trade.getId(), bankAccount, accountID, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex);
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_TAKER_DEPOSIT_PAYMENT, trade.getId(), bankAccount, accountID, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex);
|
||||
log.debug("2.6 sendTradingMessage");
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
}
|
||||
@ -294,7 +292,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.1 Incoming msg from taker
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onDepositTxReadyForPublication(@NotNull TradeMessage requestTradeMessage)
|
||||
public void onDepositTxReadyForPublication(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("3.1 onDepositTxReadyForPublication");
|
||||
takerPayoutAddress = requestTradeMessage.getTakerPayoutAddress();
|
||||
@ -306,7 +304,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.2 Verify offerers account registration and against the blacklist
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void verifyTaker(@NotNull TradeMessage requestTradeMessage)
|
||||
private void verifyTaker(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("3.2 verifyTaker");
|
||||
log.debug("3.2.1 verifyAccountRegistration");
|
||||
@ -333,7 +331,7 @@ public class OffererPaymentProtocol
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void verifyAndSignContract(@NotNull TradeMessage requestTradeMessage)
|
||||
private void verifyAndSignContract(TradeMessage requestTradeMessage)
|
||||
{
|
||||
Contract contract = new Contract(offer,
|
||||
trade.getTradeAmount(),
|
||||
@ -372,7 +370,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.4 Sign and publish the deposit tx
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void signAndPublishDepositTx(@NotNull TradeMessage requestTradeMessage)
|
||||
private void signAndPublishDepositTx(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("3.4 signAndPublishDepositTx");
|
||||
|
||||
@ -380,7 +378,7 @@ public class OffererPaymentProtocol
|
||||
String txConnOutAsHex = requestTradeMessage.getTxConnOutAsHex();
|
||||
String txScriptSigAsHex = requestTradeMessage.getTxScriptSigAsHex();
|
||||
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
@ -396,7 +394,7 @@ public class OffererPaymentProtocol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.error("3.4 signAndPublishDepositTx offererSignAndSendTx onFailure:" + t.getMessage());
|
||||
}
|
||||
@ -418,11 +416,11 @@ public class OffererPaymentProtocol
|
||||
// Step 3.5 Send tx id of published deposit tx to taker
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void sendDepositTxIdToTaker(@NotNull Transaction transaction)
|
||||
private void sendDepositTxIdToTaker(Transaction transaction)
|
||||
{
|
||||
log.debug("3.5 sendDepositTxIdToTaker");
|
||||
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -438,7 +436,7 @@ public class OffererPaymentProtocol
|
||||
offererPaymentProtocolListener.onFailure("sendDepositTxAndDataForContract onSendTradingMessageFailed");
|
||||
}
|
||||
};
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.DEPOSIT_TX_PUBLISHED, trade.getId(), Utils.bytesToHexString(transaction.bitcoinSerialize()));
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.DEPOSIT_TX_PUBLISHED, trade.getId(), Utils.bytesToHexString(transaction.bitcoinSerialize()));
|
||||
log.debug("3.5 sendTradingMessage");
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
|
||||
@ -456,7 +454,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.7 We setup a listener for block chain confirmation
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupListenerForBlockChainConfirmation(@NotNull Transaction transaction)
|
||||
private void setupListenerForBlockChainConfirmation(Transaction transaction)
|
||||
{
|
||||
log.debug("3.7 setupListenerForBlockChainConfirmation");
|
||||
|
||||
@ -467,7 +465,7 @@ public class OffererPaymentProtocol
|
||||
transaction.getConfidence().addEventListener(new TransactionConfidence.Listener()
|
||||
{
|
||||
@Override
|
||||
public void onConfidenceChanged(@NotNull Transaction tx, ChangeReason reason)
|
||||
public void onConfidenceChanged(Transaction tx, ChangeReason reason)
|
||||
{
|
||||
if (reason == ChangeReason.SEEN_PEERS)
|
||||
{
|
||||
@ -495,7 +493,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.8 We check if the block chain confirmation is >= 1
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void updateConfirmation(@NotNull TransactionConfidence confidence)
|
||||
private void updateConfirmation(TransactionConfidence confidence)
|
||||
{
|
||||
log.debug("3.8 updateConfirmation " + confidence);
|
||||
offererPaymentProtocolListener.onDepositTxConfirmedUpdate(confidence);
|
||||
@ -525,7 +523,7 @@ public class OffererPaymentProtocol
|
||||
{
|
||||
log.debug("3.10 bankTransferInited");
|
||||
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -555,14 +553,14 @@ public class OffererPaymentProtocol
|
||||
log.debug("depositTransaction.getHashAsString() " + depositTransaction.getHashAsString());
|
||||
log.debug("takerPayoutAddress " + takerPayoutAddress);
|
||||
log.debug("walletFacade.offererCreatesAndSignsPayoutTx");
|
||||
@NotNull Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx(depositTransaction.getHashAsString(), offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, trade.getId());
|
||||
Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx(depositTransaction.getHashAsString(), offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, trade.getId());
|
||||
|
||||
ECKey.ECDSASignature offererSignature = result.getKey();
|
||||
String offererSignatureR = offererSignature.r.toString();
|
||||
String offererSignatureS = offererSignature.s.toString();
|
||||
String depositTxAsHex = result.getValue();
|
||||
String offererPayoutAddress = walletFacade.getAddressInfoByTradeID(trade.getId()).getAddressString();
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.BANK_TX_INITED, trade.getId(),
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.BANK_TX_INITED, trade.getId(),
|
||||
depositTxAsHex,
|
||||
offererSignatureR,
|
||||
offererSignatureS,
|
||||
@ -596,7 +594,7 @@ public class OffererPaymentProtocol
|
||||
// Step 3.14 We received the payout tx. Trade is completed
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onPayoutTxPublished(@NotNull TradeMessage tradeMessage)
|
||||
public void onPayoutTxPublished(TradeMessage tradeMessage)
|
||||
{
|
||||
log.debug("3.14 onPayoutTxPublished");
|
||||
log.debug("3.14 TRADE COMPLETE!!!!!!!!!!!");
|
||||
|
@ -22,8 +22,6 @@ import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.Utilities;
|
||||
import java.math.BigInteger;
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -35,11 +33,11 @@ public class TakerPaymentProtocol
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerPaymentProtocol.class);
|
||||
|
||||
@NotNull
|
||||
|
||||
private final Trade trade;
|
||||
private final Offer offer;
|
||||
private final TakerPaymentProtocolListener takerPaymentProtocolListener;
|
||||
@NotNull
|
||||
|
||||
private final MessageFacade messageFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
@ -53,9 +51,9 @@ public class TakerPaymentProtocol
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public TakerPaymentProtocol(@NotNull Trade trade,
|
||||
public TakerPaymentProtocol(Trade trade,
|
||||
TakerPaymentProtocolListener takerPaymentProtocolListener,
|
||||
@NotNull MessageFacade messageFacade,
|
||||
MessageFacade messageFacade,
|
||||
WalletFacade walletFacade,
|
||||
BlockChainFacade blockChainFacade,
|
||||
CryptoFacade cryptoFacade,
|
||||
@ -90,7 +88,7 @@ public class TakerPaymentProtocol
|
||||
private void findPeerAddress()
|
||||
{
|
||||
log.debug("1.1 findPeerAddress");
|
||||
@NotNull AddressLookupListener addressLookupListener = new AddressLookupListener()
|
||||
AddressLookupListener addressLookupListener = new AddressLookupListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult(PeerAddress address)
|
||||
@ -127,7 +125,7 @@ public class TakerPaymentProtocol
|
||||
private void requestTakeOffer()
|
||||
{
|
||||
log.debug("1.2 requestTakeOffer");
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -153,7 +151,7 @@ public class TakerPaymentProtocol
|
||||
takerPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
// Send the take offer request
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_TAKE_OFFER, trade.getId());
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_TAKE_OFFER, trade.getId());
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
}
|
||||
|
||||
@ -189,10 +187,10 @@ public class TakerPaymentProtocol
|
||||
// Step 2.1
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void payOfferFee(@NotNull Trade trade)
|
||||
private void payOfferFee(Trade trade)
|
||||
{
|
||||
log.debug("2.1 payTakeOfferFee");
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(@javax.annotation.Nullable Transaction transaction)
|
||||
@ -210,7 +208,7 @@ public class TakerPaymentProtocol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.debug("2.1 payTakeOfferFee onFailure");
|
||||
takerPaymentProtocolListener.onFailure("payTakeOfferFee onFailure " + t.getMessage());
|
||||
@ -240,7 +238,7 @@ public class TakerPaymentProtocol
|
||||
private void sendTakerOfferFeeTxID(String takeOfferFeeTxID)
|
||||
{
|
||||
log.debug("2.2 sendTakerOfferFeeTxID");
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -263,7 +261,7 @@ public class TakerPaymentProtocol
|
||||
takerPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
// 2.3. send request for the account details and send fee tx id so offerer can verify that the fee has been paid.
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.TAKE_OFFER_FEE_PAYED,
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.TAKE_OFFER_FEE_PAYED,
|
||||
trade.getId(),
|
||||
trade.getTradeAmount(),
|
||||
takeOfferFeeTxID,
|
||||
@ -281,7 +279,7 @@ public class TakerPaymentProtocol
|
||||
// Step 2.7 Incoming msg from offerer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onTakerDepositPaymentRequested(@NotNull TradeMessage requestTradeMessage)
|
||||
public void onTakerDepositPaymentRequested(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.7 onTakerDepositPaymentRequested");
|
||||
verifyOfferer(requestTradeMessage);
|
||||
@ -292,7 +290,7 @@ public class TakerPaymentProtocol
|
||||
// Step 2.8 Verify offerers account registration and against the blacklist
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void verifyOfferer(@NotNull TradeMessage requestTradeMessage)
|
||||
private void verifyOfferer(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.8 verifyOfferer");
|
||||
log.debug("2.8.1 verifyAccountRegistration");
|
||||
@ -319,7 +317,7 @@ public class TakerPaymentProtocol
|
||||
// Step 2.9 Create and sign the contract
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createAndSignContract(@NotNull TradeMessage requestTradeMessage)
|
||||
private void createAndSignContract(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.9 createAndSignContract");
|
||||
checkNotNull(offer);
|
||||
@ -361,7 +359,7 @@ public class TakerPaymentProtocol
|
||||
// Step 2.10 Pay in the funds to the deposit tx and sign it
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void payDeposit(@NotNull TradeMessage requestTradeMessage)
|
||||
private void payDeposit(TradeMessage requestTradeMessage)
|
||||
{
|
||||
log.debug("2.10 payDeposit");
|
||||
|
||||
@ -390,7 +388,7 @@ public class TakerPaymentProtocol
|
||||
log.debug("preparedOffererDepositTxAsHex " + preparedOffererDepositTxAsHex);
|
||||
try
|
||||
{
|
||||
@NotNull Transaction signedTakerDepositTx = walletFacade.takerAddPaymentAndSignTx(takerInputAmount, msOutputAmount, offererPubKey, takerPubKey, arbitratorPubKey, preparedOffererDepositTxAsHex, trade.getId());
|
||||
Transaction signedTakerDepositTx = walletFacade.takerAddPaymentAndSignTx(takerInputAmount, msOutputAmount, offererPubKey, takerPubKey, arbitratorPubKey, preparedOffererDepositTxAsHex, trade.getId());
|
||||
log.debug("2.10 deposit tx created: " + signedTakerDepositTx);
|
||||
long takerTxOutIndex = signedTakerDepositTx.getInput(1).getOutpoint().getIndex();
|
||||
sendSignedTakerDepositTxAsHex(signedTakerDepositTx, takerTxOutIndex, requestTradeMessage.getOffererTxOutIndex());
|
||||
@ -405,11 +403,11 @@ public class TakerPaymentProtocol
|
||||
// Step 2.11 Send the tx to the offerer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void sendSignedTakerDepositTxAsHex(@NotNull Transaction signedTakerDepositTx, long takerTxOutIndex, long offererTxOutIndex)
|
||||
private void sendSignedTakerDepositTxAsHex(Transaction signedTakerDepositTx, long takerTxOutIndex, long offererTxOutIndex)
|
||||
{
|
||||
log.debug("2.11 sendSignedTakerDepositTxAsHex");
|
||||
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -429,7 +427,7 @@ public class TakerPaymentProtocol
|
||||
|
||||
takerPaymentProtocolListener.onProgress(getProgress());
|
||||
|
||||
@Nullable BankAccount bankAccount = user.getCurrentBankAccount();
|
||||
BankAccount bankAccount = user.getCurrentBankAccount();
|
||||
String accountID = user.getAccountID();
|
||||
String messagePubKey = user.getMessagePubKeyAsHex();
|
||||
String contractAsJson = trade.getContractAsJson();
|
||||
@ -445,7 +443,7 @@ public class TakerPaymentProtocol
|
||||
log.debug("2.10 txConnOutAsHex: " + txConnOutAsHex);
|
||||
log.debug("2.10 payoutAddress: " + payoutAddress);
|
||||
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_OFFERER_DEPOSIT_PUBLICATION,
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.REQUEST_OFFERER_DEPOSIT_PUBLICATION,
|
||||
trade.getId(),
|
||||
bankAccount,
|
||||
accountID,
|
||||
@ -474,7 +472,7 @@ public class TakerPaymentProtocol
|
||||
// Step 3.6 Incoming msg from offerer
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onDepositTxPublished(@NotNull TradeMessage tradeMessage)
|
||||
public void onDepositTxPublished(TradeMessage tradeMessage)
|
||||
{
|
||||
log.debug("3.6 DepositTxID received: " + tradeMessage.getDepositTxAsHex());
|
||||
|
||||
@ -508,10 +506,10 @@ public class TakerPaymentProtocol
|
||||
// Step 3.12 User clicked the "bank transfer received" button, so we release the funds for pay out
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void releaseBTC(@NotNull TradeMessage tradeMessage)
|
||||
public void releaseBTC(TradeMessage tradeMessage)
|
||||
{
|
||||
log.debug("3.12 releaseBTC");
|
||||
@NotNull FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(@javax.annotation.Nullable Transaction transaction)
|
||||
@ -524,7 +522,7 @@ public class TakerPaymentProtocol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable t)
|
||||
public void onFailure(Throwable t)
|
||||
{
|
||||
log.error("######### 3.12 onFailure walletFacade.takerSignsAndSendsTx");
|
||||
System.err.println("3.12 onFailure walletFacade.takerSignsAndSendsTx");
|
||||
@ -562,7 +560,7 @@ public class TakerPaymentProtocol
|
||||
void sendPayoutTxToOfferer(String payoutTxAsHex)
|
||||
{
|
||||
log.debug("3.13 sendPayoutTxToOfferer ");
|
||||
@NotNull TradeMessageListener listener = new TradeMessageListener()
|
||||
TradeMessageListener listener = new TradeMessageListener()
|
||||
{
|
||||
@Override
|
||||
public void onResult()
|
||||
@ -580,7 +578,7 @@ public class TakerPaymentProtocol
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull TradeMessage tradeMessage = new TradeMessage(TradeMessageType.PAYOUT_TX_PUBLISHED, trade.getId());
|
||||
TradeMessage tradeMessage = new TradeMessage(TradeMessageType.PAYOUT_TX_PUBLISHED, trade.getId());
|
||||
tradeMessage.setPayoutTxAsHex(payoutTxAsHex);
|
||||
log.debug("3.13 sendTradeMessage PAYOUT_TX_PUBLISHED");
|
||||
messageFacade.sendTradeMessage(peerAddress, tradeMessage, listener);
|
||||
|
@ -4,8 +4,6 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Arbitrator implements Serializable
|
||||
{
|
||||
@ -25,30 +23,30 @@ public class Arbitrator implements Serializable
|
||||
private double minArbitrationFee;
|
||||
private List<METHOD> arbitrationMethods;
|
||||
private List<ID_VERIFICATION> idVerifications;
|
||||
@Nullable
|
||||
|
||||
private String webUrl;
|
||||
@Nullable
|
||||
|
||||
private String description;
|
||||
|
||||
public Arbitrator()
|
||||
{
|
||||
}
|
||||
|
||||
public Arbitrator(@NotNull String pubKeyAsHex,
|
||||
@NotNull String messagePubKeyAsHex,
|
||||
@NotNull String name,
|
||||
@NotNull ID_TYPE idType,
|
||||
@NotNull List<Locale> languages,
|
||||
@NotNull Reputation reputation,
|
||||
public Arbitrator(String pubKeyAsHex,
|
||||
String messagePubKeyAsHex,
|
||||
String name,
|
||||
ID_TYPE idType,
|
||||
List<Locale> languages,
|
||||
Reputation reputation,
|
||||
double maxTradeVolume,
|
||||
double passiveServiceFee,
|
||||
double minPassiveServiceFee,
|
||||
double arbitrationFee,
|
||||
double minArbitrationFee,
|
||||
@NotNull List<METHOD> arbitrationMethods,
|
||||
@NotNull List<ID_VERIFICATION> idVerifications,
|
||||
@Nullable String webUrl,
|
||||
@Nullable String description)
|
||||
List<METHOD> arbitrationMethods,
|
||||
List<ID_VERIFICATION> idVerifications,
|
||||
String webUrl,
|
||||
String description)
|
||||
{
|
||||
this.pubKeyAsHex = pubKeyAsHex;
|
||||
this.messagePubKeyAsHex = messagePubKeyAsHex;
|
||||
@ -70,7 +68,7 @@ public class Arbitrator implements Serializable
|
||||
id = name;
|
||||
}
|
||||
|
||||
public void updateFromStorage(@NotNull Arbitrator savedArbitrator)
|
||||
public void updateFromStorage(Arbitrator savedArbitrator)
|
||||
{
|
||||
this.pubKeyAsHex = savedArbitrator.getPubKeyAsHex();
|
||||
this.messagePubKeyAsHex = savedArbitrator.getPubKeyAsHex();
|
||||
@ -102,7 +100,7 @@ public class Arbitrator implements Serializable
|
||||
}
|
||||
|
||||
@SuppressWarnings("NonFinalFieldReferenceInEquals")
|
||||
public boolean equals(@Nullable Object obj)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof Arbitrator))
|
||||
return false;
|
||||
@ -113,19 +111,19 @@ public class Arbitrator implements Serializable
|
||||
return id != null && id.equals(other.getId());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getPubKeyAsHex()
|
||||
{
|
||||
return pubKeyAsHex;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getMessagePubKeyAsHex()
|
||||
{
|
||||
return messagePubKeyAsHex;
|
||||
@ -136,25 +134,25 @@ public class Arbitrator implements Serializable
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public ID_TYPE getIdType()
|
||||
{
|
||||
return idType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<Locale> getLanguages()
|
||||
{
|
||||
return languages;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Reputation getReputation()
|
||||
{
|
||||
return reputation;
|
||||
@ -185,25 +183,25 @@ public class Arbitrator implements Serializable
|
||||
return minArbitrationFee;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<METHOD> getArbitrationMethods()
|
||||
{
|
||||
return arbitrationMethods;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<ID_VERIFICATION> getIdVerifications()
|
||||
{
|
||||
return idVerifications;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getWebUrl()
|
||||
{
|
||||
return webUrl;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.bitsquare.user;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -16,7 +15,7 @@ public class Reputation implements Serializable
|
||||
{
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -5,8 +5,6 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class User implements Serializable
|
||||
{
|
||||
@ -14,14 +12,14 @@ public class User implements Serializable
|
||||
|
||||
transient private final SimpleBooleanProperty bankAccountChangedProperty = new SimpleBooleanProperty();
|
||||
|
||||
@Nullable
|
||||
|
||||
private String accountID;
|
||||
@Nullable
|
||||
|
||||
private String messagePubKeyAsHex;
|
||||
private boolean isOnline;
|
||||
@NotNull
|
||||
|
||||
private List<BankAccount> bankAccounts = new ArrayList<>();
|
||||
@Nullable
|
||||
|
||||
private BankAccount currentBankAccount = null;
|
||||
|
||||
public User()
|
||||
@ -33,7 +31,7 @@ public class User implements Serializable
|
||||
// Public Methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void updateFromStorage(@Nullable User savedUser)
|
||||
public void updateFromStorage(User savedUser)
|
||||
{
|
||||
if (savedUser != null)
|
||||
{
|
||||
@ -45,7 +43,7 @@ public class User implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
public void addBankAccount(@NotNull BankAccount bankAccount)
|
||||
public void addBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
if (!bankAccounts.contains(bankAccount))
|
||||
bankAccounts.add(bankAccount);
|
||||
@ -66,10 +64,10 @@ public class User implements Serializable
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getStringifiedBankAccounts()
|
||||
{
|
||||
@NotNull String bankAccountUIDs = "";
|
||||
String bankAccountUIDs = "";
|
||||
for (int i = 0; i < bankAccounts.size(); i++)
|
||||
{
|
||||
BankAccount bankAccount = bankAccounts.get(i);
|
||||
@ -82,24 +80,24 @@ public class User implements Serializable
|
||||
return bankAccountUIDs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getMessagePubKeyAsHex()
|
||||
{
|
||||
return messagePubKeyAsHex;
|
||||
}
|
||||
|
||||
public void setMessagePubKeyAsHex(@Nullable String messageID)
|
||||
public void setMessagePubKeyAsHex(String messageID)
|
||||
{
|
||||
this.messagePubKeyAsHex = messageID;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getAccountID()
|
||||
{
|
||||
return accountID;
|
||||
}
|
||||
|
||||
public void setAccountID(@Nullable String accountID)
|
||||
public void setAccountID(String accountID)
|
||||
{
|
||||
this.accountID = accountID;
|
||||
}
|
||||
@ -109,31 +107,31 @@ public class User implements Serializable
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<BankAccount> getBankAccounts()
|
||||
{
|
||||
return bankAccounts;
|
||||
}
|
||||
|
||||
public void setBankAccounts(@NotNull List<BankAccount> bankAccounts)
|
||||
public void setBankAccounts(List<BankAccount> bankAccounts)
|
||||
{
|
||||
this.bankAccounts = bankAccounts;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public BankAccount getCurrentBankAccount()
|
||||
{
|
||||
return currentBankAccount;
|
||||
}
|
||||
|
||||
public void setCurrentBankAccount(@NotNull BankAccount bankAccount)
|
||||
public void setCurrentBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
this.currentBankAccount = bankAccount;
|
||||
bankAccountChangedProperty.set(!bankAccountChangedProperty.get());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BankAccount getBankAccount(@NotNull String bankAccountId)
|
||||
|
||||
public BankAccount getBankAccount(String bankAccountId)
|
||||
{
|
||||
for (final BankAccount bankAccount : bankAccounts)
|
||||
{
|
||||
@ -153,13 +151,13 @@ public class User implements Serializable
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public SimpleBooleanProperty getBankAccountChangedProperty()
|
||||
{
|
||||
return bankAccountChangedProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -9,8 +9,6 @@ import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -25,8 +23,8 @@ public class DSAKeyUtil
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
public static String getHexStringFromPublicKey(@NotNull PublicKey publicKey)
|
||||
|
||||
public static String getHexStringFromPublicKey(PublicKey publicKey)
|
||||
{
|
||||
final X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicKey.getEncoded());
|
||||
return Utils.bytesToHexString(x509EncodedKeySpec.getEncoded());
|
||||
@ -34,7 +32,7 @@ public class DSAKeyUtil
|
||||
|
||||
// not used yet
|
||||
/*
|
||||
@Nullable
|
||||
|
||||
public static PublicKey getPublicKeyFromHexString(String publicKeyAsHex) throws NoSuchAlgorithmException, InvalidKeySpecException
|
||||
{
|
||||
final byte[] bytes = Utils.parseAsHexOrBase58(publicKeyAsHex);
|
||||
@ -42,7 +40,7 @@ public class DSAKeyUtil
|
||||
return keyFactory.generatePublic(new X509EncodedKeySpec(bytes));
|
||||
} */
|
||||
|
||||
@Nullable
|
||||
|
||||
public static KeyPair getKeyPair()
|
||||
{
|
||||
return getKeyPair(FileUtil.getFile(prefix + "public", "key"), FileUtil.getFile(prefix + "private", "key"));
|
||||
@ -53,8 +51,8 @@ public class DSAKeyUtil
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Nullable
|
||||
private static KeyPair getKeyPair(@NotNull File pubKeyFile, @NotNull File privKeyFile)
|
||||
|
||||
private static KeyPair getKeyPair(File pubKeyFile, File privKeyFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -90,7 +88,7 @@ public class DSAKeyUtil
|
||||
}
|
||||
|
||||
|
||||
private static void saveKeyPairToFiles(@NotNull File pubKeyFile, @NotNull File privKeyFile, @NotNull KeyPair keyPair) throws IOException
|
||||
private static void saveKeyPairToFiles(File pubKeyFile, File privKeyFile, KeyPair keyPair) throws IOException
|
||||
{
|
||||
lock.lock();
|
||||
final File pubKeyTempFile = FileUtil.getTempFile("pubKey_temp_" + prefix);
|
||||
@ -156,8 +154,8 @@ public class DSAKeyUtil
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static KeyPair readKeyPairFromFiles(@NotNull File pubKeyFile, @NotNull File privKeyFile) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException
|
||||
|
||||
private static KeyPair readKeyPairFromFiles(File pubKeyFile, File privKeyFile) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException
|
||||
{
|
||||
lock.lock();
|
||||
try (final FileInputStream pubKeyFileInputStream = new FileInputStream(pubKeyFile);
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -17,7 +16,7 @@ public class FileUtil
|
||||
}
|
||||
|
||||
// not used yet
|
||||
/* public static void setRootDirectory(@NotNull File rootDirectory)
|
||||
/* public static void setRootDirectory( File rootDirectory)
|
||||
{
|
||||
FileUtil.rootDirectory = rootDirectory;
|
||||
if (!rootDirectory.exists())
|
||||
@ -27,8 +26,8 @@ public class FileUtil
|
||||
}
|
||||
} */
|
||||
|
||||
@NotNull
|
||||
public static File getDirectory(@NotNull String name)
|
||||
|
||||
public static File getDirectory(String name)
|
||||
{
|
||||
final File dir = new File(rootDirectory, name);
|
||||
if (!dir.exists())
|
||||
@ -40,14 +39,14 @@ public class FileUtil
|
||||
return dir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getFile(@NotNull String name, @NotNull String suffix)
|
||||
|
||||
public static File getFile(String name, String suffix)
|
||||
{
|
||||
return new File(rootDirectory, name + "." + suffix);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getTempFile(@NotNull String prefix) throws IOException
|
||||
|
||||
public static File getTempFile(String prefix) throws IOException
|
||||
{
|
||||
return File.createTempFile("temp_" + prefix, null, rootDirectory);
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.util.function.Function;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -31,16 +29,16 @@ public class Utilities
|
||||
return gson.fromJson(jsonString, classOfT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public static Object deserializeHexStringToObject(String serializedHexString)
|
||||
{
|
||||
@Nullable Object result = null;
|
||||
Object result = null;
|
||||
try
|
||||
{
|
||||
@NotNull ByteInputStream byteInputStream = new ByteInputStream();
|
||||
ByteInputStream byteInputStream = new ByteInputStream();
|
||||
byteInputStream.setBuf(com.google.bitcoin.core.Utils.parseAsHexOrBase58(serializedHexString));
|
||||
|
||||
try (@NotNull ObjectInputStream objectInputStream = new ObjectInputStream(byteInputStream))
|
||||
try (ObjectInputStream objectInputStream = new ObjectInputStream(byteInputStream))
|
||||
{
|
||||
result = objectInputStream.readObject();
|
||||
} catch (ClassNotFoundException e)
|
||||
@ -59,14 +57,14 @@ public class Utilities
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public static String serializeObjectToHexString(Serializable serializable)
|
||||
{
|
||||
@Nullable String result = null;
|
||||
@NotNull ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
String result = null;
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try
|
||||
{
|
||||
@NotNull ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
||||
objectOutputStream.writeObject(serializable);
|
||||
|
||||
result = com.google.bitcoin.core.Utils.bytesToHexString(byteArrayOutputStream.toByteArray());
|
||||
@ -81,7 +79,7 @@ public class Utilities
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static void printElapsedTime(@NotNull String msg)
|
||||
private static void printElapsedTime(String msg)
|
||||
{
|
||||
if (!msg.isEmpty())
|
||||
msg += " / ";
|
||||
@ -96,30 +94,29 @@ public class Utilities
|
||||
}
|
||||
|
||||
|
||||
public static void openURL(@NotNull String url) throws Exception
|
||||
public static void openURL(String url) throws Exception
|
||||
{
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static Object copy(Serializable orig)
|
||||
{
|
||||
@Nullable Object obj = null;
|
||||
Object obj = null;
|
||||
try
|
||||
{
|
||||
// Write the object out to a byte array
|
||||
@NotNull ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
@NotNull ObjectOutputStream out = new ObjectOutputStream(bos);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(bos);
|
||||
out.writeObject(orig);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
// Make an input stream from the byte array and read
|
||||
// a copy of the object back in.
|
||||
@NotNull ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
|
||||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
|
||||
obj = in.readObject();
|
||||
} catch (@NotNull IOException | ClassNotFoundException e)
|
||||
} catch (IOException | ClassNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -127,10 +124,10 @@ public class Utilities
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
public static AnimationTimer setTimeout(int delay, @NotNull Function<AnimationTimer, Void> callback)
|
||||
|
||||
public static AnimationTimer setTimeout(int delay, Function<AnimationTimer, Void> callback)
|
||||
{
|
||||
@NotNull AnimationTimer animationTimer = new AnimationTimer()
|
||||
AnimationTimer animationTimer = new AnimationTimer()
|
||||
{
|
||||
final long lastTimeStamp = System.currentTimeMillis();
|
||||
|
||||
@ -149,10 +146,10 @@ public class Utilities
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
public static AnimationTimer setInterval(int delay, @NotNull Function<AnimationTimer, Void> callback)
|
||||
|
||||
public static AnimationTimer setInterval(int delay, Function<AnimationTimer, Void> callback)
|
||||
{
|
||||
@NotNull AnimationTimer animationTimer = new AnimationTimer()
|
||||
AnimationTimer animationTimer = new AnimationTimer()
|
||||
{
|
||||
long lastTimeStamp = System.currentTimeMillis();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.bitsquare;
|
||||
|
||||
import io.bitsquare.btc.BtcValidatorTest;
|
||||
import io.bitsquare.currency.BitcoinTest;
|
||||
import io.bitsquare.gui.util.BitSquareConverterTest;
|
||||
import io.bitsquare.gui.util.BitSquareValidatorTest;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -10,7 +11,8 @@ import org.junit.runners.Suite;
|
||||
@Suite.SuiteClasses({
|
||||
BtcValidatorTest.class,
|
||||
BitSquareConverterTest.class,
|
||||
BitSquareValidatorTest.class
|
||||
BitSquareValidatorTest.class,
|
||||
BitcoinTest.class
|
||||
})
|
||||
|
||||
public class BitSquareTestSuite
|
||||
|
@ -2,7 +2,6 @@ package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import java.math.BigInteger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -13,23 +12,23 @@ public class BtcValidatorTest
|
||||
@Test
|
||||
public void testIsMinSpendableAmount()
|
||||
{
|
||||
@Nullable BigInteger amount = null;
|
||||
BigInteger amount = null;
|
||||
//noinspection ConstantConditions
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = BigInteger.ZERO;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE;
|
||||
amount = FeePolicy.TX_FEE_depr;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = Transaction.MIN_NONDUST_OUTPUT;
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT);
|
||||
amount = FeePolicy.TX_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT);
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
|
||||
amount = FeePolicy.TX_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
|
||||
assertTrue("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
}
|
||||
}
|
||||
|
50
src/test/java/io/bitsquare/currency/BitcoinTest.java
Normal file
50
src/test/java/io/bitsquare/currency/BitcoinTest.java
Normal file
@ -0,0 +1,50 @@
|
||||
package io.bitsquare.currency;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import java.math.BigInteger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BitcoinTest
|
||||
{
|
||||
@Test
|
||||
public void testBitcoin()
|
||||
{
|
||||
Bitcoin bitcoin;
|
||||
Bitcoin compareValue;
|
||||
|
||||
bitcoin = new Bitcoin("0");
|
||||
assertTrue(bitcoin.isZero());
|
||||
|
||||
bitcoin = new Bitcoin("0");
|
||||
compareValue = new Bitcoin("1");
|
||||
assertTrue(bitcoin.isLess(compareValue));
|
||||
assertFalse(compareValue.isLess(bitcoin));
|
||||
assertFalse(compareValue.isEqual(bitcoin));
|
||||
|
||||
bitcoin = new Bitcoin("1");
|
||||
compareValue = new Bitcoin("0");
|
||||
assertFalse(bitcoin.isLess(compareValue));
|
||||
assertTrue(compareValue.isLess(bitcoin));
|
||||
assertFalse(compareValue.isEqual(bitcoin));
|
||||
|
||||
bitcoin = new Bitcoin("1");
|
||||
compareValue = new Bitcoin("1");
|
||||
assertFalse(bitcoin.isLess(compareValue));
|
||||
assertFalse(compareValue.isLess(bitcoin));
|
||||
assertTrue(compareValue.isEqual(bitcoin));
|
||||
|
||||
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT);
|
||||
assertTrue(bitcoin.isMinValue());
|
||||
|
||||
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT.subtract(BigInteger.ONE));
|
||||
assertFalse(bitcoin.isMinValue());
|
||||
|
||||
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT.add(BigInteger.ONE));
|
||||
assertTrue(bitcoin.isMinValue());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user