diff --git a/src/main/java/io/bitsquare/BitSquare.java b/src/main/java/io/bitsquare/BitSquare.java index 10c5f5c081..1ed40fb5f0 100644 --- a/src/main/java/io/bitsquare/BitSquare.java +++ b/src/main/java/io/bitsquare/BitSquare.java @@ -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(); diff --git a/src/main/java/io/bitsquare/RelayNode.java b/src/main/java/io/bitsquare/RelayNode.java index 43448fc5cd..51e7abce84 100755 --- a/src/main/java/io/bitsquare/RelayNode.java +++ b/src/main/java/io/bitsquare/RelayNode.java @@ -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])); diff --git a/src/main/java/io/bitsquare/bank/BankAccount.java b/src/main/java/io/bitsquare/bank/BankAccount.java index 2744dfbbac..2df783a350 100644 --- a/src/main/java/io/bitsquare/bank/BankAccount.java +++ b/src/main/java/io/bitsquare/bank/BankAccount.java @@ -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() { diff --git a/src/main/java/io/bitsquare/bank/BankAccountType.java b/src/main/java/io/bitsquare/bank/BankAccountType.java index 7f9235675b..4df67a36a2 100644 --- a/src/main/java/io/bitsquare/bank/BankAccountType.java +++ b/src/main/java/io/bitsquare/bank/BankAccountType.java @@ -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 getAllBankAccountTypes() { return new ArrayList<>(Arrays.asList(BankAccountType.values())); } - @NotNull + public String getPrimaryId() { return primaryId; } - @NotNull + public String getSecondaryId() { return secondaryId; diff --git a/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java b/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java index 805f9f19fb..bfeee1b383 100644 --- a/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java +++ b/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java @@ -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 outputs) + static void sortOutputs(ArrayList 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 candidates) + + public CoinSelection select(BigInteger biTarget, LinkedList candidates) { long target = biTarget.longValue(); - @NotNull HashSet selected = new HashSet<>(); + HashSet 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 sortedOutputs = new ArrayList<>(candidates); + ArrayList 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. diff --git a/src/main/java/io/bitsquare/btc/AddressEntry.java b/src/main/java/io/bitsquare/btc/AddressEntry.java index 55f2eadb8c..0f03f1510a 100644 --- a/src/main/java/io/bitsquare/btc/AddressEntry.java +++ b/src/main/java/io/bitsquare/btc/AddressEntry.java @@ -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; } diff --git a/src/main/java/io/bitsquare/btc/BitSquareWalletAppKit.java b/src/main/java/io/bitsquare/btc/BitSquareWalletAppKit.java index 1597c872ae..e93b334acc 100644 --- a/src/main/java/io/bitsquare/btc/BitSquareWalletAppKit.java +++ b/src/main/java/io/bitsquare/btc/BitSquareWalletAppKit.java @@ -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); } diff --git a/src/main/java/io/bitsquare/btc/BlockChainFacade.java b/src/main/java/io/bitsquare/btc/BlockChainFacade.java index 6d2a254dbe..8e937a3725 100644 --- a/src/main/java/io/bitsquare/btc/BlockChainFacade.java +++ b/src/main/java/io/bitsquare/btc/BlockChainFacade.java @@ -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 diff --git a/src/main/java/io/bitsquare/btc/BtcFormatter.java b/src/main/java/io/bitsquare/btc/BtcFormatter.java index c01a795b0e..235504e84f 100644 --- a/src/main/java/io/bitsquare/btc/BtcFormatter.java +++ b/src/main/java/io/bitsquare/btc/BtcFormatter.java @@ -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); diff --git a/src/main/java/io/bitsquare/btc/BtcValidator.java b/src/main/java/io/bitsquare/btc/BtcValidator.java index 0a1a397357..7b8d87bc79 100644 --- a/src/main/java/io/bitsquare/btc/BtcValidator.java +++ b/src/main/java/io/bitsquare/btc/BtcValidator.java @@ -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) diff --git a/src/main/java/io/bitsquare/btc/FeePolicy.java b/src/main/java/io/bitsquare/btc/FeePolicy.java index c6f8abab16..53026a1fc4 100644 --- a/src/main/java/io/bitsquare/btc/FeePolicy.java +++ b/src/main/java/io/bitsquare/btc/FeePolicy.java @@ -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 diff --git a/src/main/java/io/bitsquare/btc/WalletFacade.java b/src/main/java/io/bitsquare/btc/WalletFacade.java index 18acfc9fd3..1dc1c22453 100644 --- a/src/main/java/io/bitsquare/btc/WalletFacade.java +++ b/src/main/java/io/bitsquare/btc/WalletFacade.java @@ -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 balanceListeners = new ArrayList<>(); private BitSquareWallet wallet; private WalletEventListener walletEventListener; - @NotNull + @GuardedBy("lock") private List 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 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 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 transactionConfidenceList = new ArrayList<>(); + List transactionConfidenceList = new ArrayList<>(); Set 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 transactionConfidenceList = new ArrayList<>(); + List 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 mergedOutputs = getOutputsWithConnectedOutputs(tx); - @NotNull List transactionConfidenceList = new ArrayList<>(); + List mergedOutputs = getOutputsWithConnectedOutputs(tx); + List 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 getOutputsWithConnectedOutputs(@NotNull Transaction tx) + + private List getOutputsWithConnectedOutputs(Transaction tx) { List transactionOutputs = tx.getOutputs(); - @NotNull List connectedOutputs = new ArrayList<>(); + List connectedOutputs = new ArrayList<>(); // add all connected outputs from any inputs as well List 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 mergedOutputs = new ArrayList<>(); + List mergedOutputs = new ArrayList<>(); mergedOutputs.addAll(transactionOutputs); mergedOutputs.addAll(connectedOutputs); return mergedOutputs; } - @Nullable - private TransactionConfidence getMostRecentConfidence(@NotNull List transactionConfidenceList) + + private TransactionConfidence getMostRecentConfidence(List 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 transactionOutputs, Address address) + private BigInteger getBalance(LinkedList 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 callback) throws InsufficientMoneyException + public void payRegistrationFee(String stringifiedBankAccounts, FutureCallback 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 callback) throws InsufficientMoneyException + public String payCreateOfferFee(String offerId, FutureCallback 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 callback) throws InsufficientMoneyException + public String payTakeOfferFee(String offerId, FutureCallback 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 callback) throws AddressFormatException, InsufficientMoneyException, IllegalArgumentException + BigInteger amount, + FutureCallback 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 callback) + FutureCallback 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 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 callback) throws AddressFormatException + FutureCallback 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 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(); } } diff --git a/src/main/java/io/bitsquare/crypto/CryptoFacade.java b/src/main/java/io/bitsquare/crypto/CryptoFacade.java index 3f2a00b217..de6cec609a 100644 --- a/src/main/java/io/bitsquare/crypto/CryptoFacade.java +++ b/src/main/java/io/bitsquare/crypto/CryptoFacade.java @@ -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; diff --git a/src/main/java/io/bitsquare/currency/Bitcoin.java b/src/main/java/io/bitsquare/currency/Bitcoin.java new file mode 100644 index 0000000000..824a821a24 --- /dev/null +++ b/src/main/java/io/bitsquare/currency/Bitcoin.java @@ -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); + } + + +} diff --git a/src/main/java/io/bitsquare/currency/Fiat.java b/src/main/java/io/bitsquare/currency/Fiat.java new file mode 100644 index 0000000000..e5361f9a2a --- /dev/null +++ b/src/main/java/io/bitsquare/currency/Fiat.java @@ -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; + } +} diff --git a/src/main/java/io/bitsquare/di/BitSquareModule.java b/src/main/java/io/bitsquare/di/BitSquareModule.java index 65df03759a..3dfdac3e2f 100644 --- a/src/main/java/io/bitsquare/di/BitSquareModule.java +++ b/src/main/java/io/bitsquare/di/BitSquareModule.java @@ -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 this.networkParameters = networkParameters; } - @NotNull + public BitSquareWalletAppKit get() { return new BitSquareWalletAppKit(networkParameters, FileUtil.getRootDirectory()); @@ -84,10 +82,10 @@ class NetworkParametersProvider implements Provider this.networkType = networkType; } - @Nullable + public NetworkParameters get() { - @Nullable NetworkParameters result = null; + NetworkParameters result = null; switch (networkType) { diff --git a/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java b/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java index 5fad4e0829..b967cb65a6 100644 --- a/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java +++ b/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java @@ -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; } diff --git a/src/main/java/io/bitsquare/gui/ChildController.java b/src/main/java/io/bitsquare/gui/ChildController.java index ed54af9d4a..03a20c98db 100644 --- a/src/main/java/io/bitsquare/gui/ChildController.java +++ b/src/main/java/io/bitsquare/gui/ChildController.java @@ -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(); } diff --git a/src/main/java/io/bitsquare/gui/MainController.java b/src/main/java/io/bitsquare/gui/MainController.java index 12f323ff27..9e5aca4cc8 100644 --- a/src/main/java/io/bitsquare/gui/MainController.java +++ b/src/main/java/io/bitsquare/gui/MainController.java @@ -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() { - @NotNull + @Override - public String toString(@NotNull BankAccount bankAccount) + public String toString(BankAccount bankAccount) { return bankAccount.getAccountTitle(); } - @Nullable + @Override public BankAccount fromString(String s) { diff --git a/src/main/java/io/bitsquare/gui/NavigationController.java b/src/main/java/io/bitsquare/gui/NavigationController.java index 64b221b061..cd6d7670d8 100644 --- a/src/main/java/io/bitsquare/gui/NavigationController.java +++ b/src/main/java/io/bitsquare/gui/NavigationController.java @@ -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); } diff --git a/src/main/java/io/bitsquare/gui/NavigationItem.java b/src/main/java/io/bitsquare/gui/NavigationItem.java index 89a19ce7d5..f17cf7257e 100644 --- a/src/main/java/io/bitsquare/gui/NavigationItem.java +++ b/src/main/java/io/bitsquare/gui/NavigationItem.java @@ -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"), diff --git a/src/main/java/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewController.java b/src/main/java/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewController.java index 1fc04f0a4f..c30be17f31 100644 --- a/src/main/java/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewController.java +++ b/src/main/java/io/bitsquare/gui/arbitrators/overview/ArbitratorOverviewController.java @@ -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 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 dataMap, boolean success) + public void onArbitratorsReceived(Map 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(); } diff --git a/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java b/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java index f926483dbe..ecaa1c6f40 100644 --- a/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java +++ b/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java @@ -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; } diff --git a/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java b/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java index 0e5530bab1..41709cb055 100644 --- a/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java +++ b/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java @@ -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 languageList = new ArrayList<>(); - @NotNull + private List methodList = new ArrayList<>(); - @NotNull + private List 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() { @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() { - @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() { - @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() { - @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(); } diff --git a/src/main/java/io/bitsquare/gui/components/LazyLoadingTabPane.java b/src/main/java/io/bitsquare/gui/components/LazyLoadingTabPane.java index 548cc7fede..f4d13e4298 100644 --- a/src/main/java/io/bitsquare/gui/components/LazyLoadingTabPane.java +++ b/src/main/java/io/bitsquare/gui/components/LazyLoadingTabPane.java @@ -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(); diff --git a/src/main/java/io/bitsquare/gui/components/NetworkSyncPane.java b/src/main/java/io/bitsquare/gui/components/NetworkSyncPane.java index 6f190c88b4..b52057c02f 100644 --- a/src/main/java/io/bitsquare/gui/components/NetworkSyncPane.java +++ b/src/main/java/io/bitsquare/gui/components/NetworkSyncPane.java @@ -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); diff --git a/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java b/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java index 1a5fbfa164..036a2d7b3d 100644 --- a/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java +++ b/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java @@ -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() { diff --git a/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java b/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java index b7ef4af93b..a3433ac967 100644 --- a/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java +++ b/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java @@ -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> @@ -84,12 +82,12 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase getCssMetaData() { @@ -124,7 +122,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase 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 progressColor = new StyleableObjectProperty(null) { @@ -167,7 +165,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase getCssMetaData() { @@ -211,14 +209,14 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase(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 updateProgress(); + InvalidationListener progressListener = valueModel -> updateProgress(); control.progressProperty().addListener(progressListener); getChildren().clear(); @@ -454,7 +452,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase 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 { + InvalidationListener treeVisibilityListener = valueModel -> { if (piSkin.skin.getSkinnable().impl_isTreeVisible()) { piSkin.pauseIndicator(false); @@ -791,7 +789,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase 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> STYLEABLES; - @Nullable + private static final CssMetaData PROGRESS_COLOR = new CssMetaData("-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 getStyleableProperty(@NotNull ConfidenceProgressIndicator n) + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { - @NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); return (StyleableProperty) skin.progressColor; } }; - @Nullable + private static final CssMetaData INDETERMINATE_SEGMENT_COUNT = new CssMetaData("-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 getStyleableProperty(@NotNull ConfidenceProgressIndicator n) + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { - @NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); return (StyleableProperty) skin.indeterminateSegmentCount; } }; - @Nullable + private static final CssMetaData SPIN_ENABLED = new CssMetaData("-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 getStyleableProperty(@NotNull ConfidenceProgressIndicator node) + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator node) { - @NotNull final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); return (StyleableProperty) skin.spinEnabled; } }; static { - @NotNull final List> styleables = new ArrayList<>(SkinBase.getClassCssMetaData()); + final List> styleables = new ArrayList<>(SkinBase.getClassCssMetaData()); styleables.add(PROGRESS_COLOR); styleables.add(INDETERMINATE_SEGMENT_COUNT); styleables.add(SPIN_ENABLED); diff --git a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBar.java b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBar.java index eba12db2d2..b34ef2844f 100644 --- a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBar.java +++ b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBar.java @@ -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 extends Control { - @Nullable private List processStepItems = null; public ProcessStepBar() @@ -18,25 +15,25 @@ public class ProcessStepBar extends Control } - public ProcessStepBar(@Nullable List processStepItems) + public ProcessStepBar(List processStepItems) { this.processStepItems = processStepItems; } - @NotNull + @Override protected Skin createDefaultSkin() { return new ProcessStepBarSkin<>(this); } - @Nullable + List getProcessStepItems() { return processStepItems; } - public void setProcessStepItems(@Nullable List processStepItems) + public void setProcessStepItems(List processStepItems) { this.processStepItems = processStepItems; if (getSkin() != null) diff --git a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBarSkin.java b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBarSkin.java index ab0a4d222d..99ceee3017 100644 --- a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBarSkin.java +++ b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepBarSkin.java @@ -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 extends BehaviorSkinBase, BehaviorBase>> { @@ -47,9 +46,9 @@ class ProcessStepBarSkin extends BehaviorSkinBase, 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 extends BehaviorSkinBase, 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 extends BehaviorSkinBase, 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 extends BehaviorSkinBase, Behavior return arrowWidth; } - @NotNull + private Path createButtonShape() { // build the following shape (or home without left arrow) @@ -161,14 +160,14 @@ class ProcessStepBarSkin extends BehaviorSkinBase, 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 extends BehaviorSkinBase, 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 extends BehaviorSkinBase, 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); diff --git a/src/main/java/io/bitsquare/gui/funds/FundsController.java b/src/main/java/io/bitsquare/gui/funds/FundsController.java index c085f6e3d6..ddfcfa7a34 100644 --- a/src/main/java/io/bitsquare/gui/funds/FundsController.java +++ b/src/main/java/io/bitsquare/gui/funds/FundsController.java @@ -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()); } diff --git a/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java b/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java index bb214fcdca..2c8f9ba8d4 100644 --- a/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java +++ b/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java @@ -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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn column) { return new TableCell() { - @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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn column) { return new TableCell() { @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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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); diff --git a/src/main/java/io/bitsquare/gui/funds/deposit/DepositListItem.java b/src/main/java/io/bitsquare/gui/funds/deposit/DepositListItem.java index 2c5a0f4085..ceefa4fc46 100644 --- a/src/main/java/io/bitsquare/gui/funds/deposit/DepositListItem.java +++ b/src/main/java/io/bitsquare/gui/funds/deposit/DepositListItem.java @@ -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); } diff --git a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java index 2699767fb3..6e74044fea 100644 --- a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java +++ b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java @@ -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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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); diff --git a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java index 63826ce727..e5c72b9d56 100644 --- a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java +++ b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java @@ -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; diff --git a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java index 1f2d16e65b..d809b8b032 100644 --- a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java +++ b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java @@ -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 callback = new FutureCallback() + FutureCallback callback = new FutureCallback() { @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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn column) { return new TableCell() { - @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, TableCell>() { - @NotNull + @Override public TableCell call(TableColumn column) { return new TableCell() { @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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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); diff --git a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalListItem.java b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalListItem.java index be4c7ab049..9e5f719b5b 100644 --- a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalListItem.java +++ b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalListItem.java @@ -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; diff --git a/src/main/java/io/bitsquare/gui/home/HomeController.java b/src/main/java/io/bitsquare/gui/home/HomeController.java index 33dea12d8a..1582089921 100644 --- a/src/main/java/io/bitsquare/gui/home/HomeController.java +++ b/src/main/java/io/bitsquare/gui/home/HomeController.java @@ -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(); diff --git a/src/main/java/io/bitsquare/gui/market/MarketController.java b/src/main/java/io/bitsquare/gui/market/MarketController.java index c0733d4be8..e989b9ad0a 100644 --- a/src/main/java/io/bitsquare/gui/market/MarketController.java +++ b/src/main/java/io/bitsquare/gui/market/MarketController.java @@ -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) { } diff --git a/src/main/java/io/bitsquare/gui/market/createOffer/CreateOfferController.java b/src/main/java/io/bitsquare/gui/market/createOffer/CreateOfferController.java index 1c71abe812..fd11041fdd 100644 --- a/src/main/java/io/bitsquare/gui/market/createOffer/CreateOfferController.java +++ b/src/main/java/io/bitsquare/gui/market/createOffer/CreateOfferController.java @@ -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 callback = new FutureCallback() + FutureCallback callback = new FutureCallback() { @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); diff --git a/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookController.java b/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookController.java index 1e544e6db9..a4cfacf130 100644 --- a/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookController.java +++ b/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookController.java @@ -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 offerList; - @Nullable + private AnimationTimer pollingTimer; @FXML private TableColumn 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 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 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 callback = new FutureCallback() + FutureCallback callback = new FutureCallback() { @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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn 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, TableCell>() { - @Nullable + @Override public TableCell call(TableColumn directionColumn) { return new TableCell() { @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) { diff --git a/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookListItem.java b/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookListItem.java index 6c5a613929..7ba89dac2e 100644 --- a/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookListItem.java +++ b/src/main/java/io/bitsquare/gui/market/orderbook/OrderBookListItem.java @@ -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; diff --git a/src/main/java/io/bitsquare/gui/market/trade/TakeOfferView.fxml b/src/main/java/io/bitsquare/gui/market/trade/TakeOfferView.fxml new file mode 100644 index 0000000000..733b3ac52e --- /dev/null +++ b/src/main/java/io/bitsquare/gui/market/trade/TakeOfferView.fxml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + +