Exclude 2nd log binding, cleanup, reformat

This commit is contained in:
Manfred Karrer 2015-03-17 00:51:43 +01:00
parent c4d56d43f4
commit 8713f9d835
38 changed files with 82 additions and 60 deletions

View File

@ -192,6 +192,14 @@
<groupId>com.vinumeris</groupId>
<artifactId>updatefx</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--

View File

@ -58,7 +58,7 @@ public class Arbitrator implements Serializable {
List<ID_VERIFICATION> idVerifications,
String webUrl,
String description) {
this.pubKey=pubKey;
this.pubKey = pubKey;
this.messagePubKeyAsHex = messagePubKeyAsHex;
this.name = name;
this.idType = idType;

View File

@ -53,12 +53,13 @@ class AddressBasedCoinSelector extends DefaultCoinSelector {
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
public AddressBasedCoinSelector(NetworkParameters params, AddressEntry addressEntry, boolean includePending) {
public AddressBasedCoinSelector(NetworkParameters params, AddressEntry addressEntry, @SuppressWarnings("SameParameterValue") boolean includePending) {
this.params = params;
this.addressEntry = addressEntry;
this.includePending = includePending;
}
@SuppressWarnings("WeakerAccess")
@VisibleForTesting
static void sortOutputs(ArrayList<TransactionOutput> outputs) {
Collections.sort(outputs, (a, b) -> {
@ -130,14 +131,14 @@ class AddressBasedCoinSelector extends DefaultCoinSelector {
}
private boolean matchesRequiredAddress(TransactionOutput transactionOutput) {
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isPayToScriptHash
()) {
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);
log.trace("matchesRequiredAddress?");
log.trace(addressOutput.toString());
log.trace(addressEntry.getAddress().toString());
if (addressEntry != null && addressOutput.equals(addressEntry.getAddress())) {
if (addressOutput.equals(addressEntry.getAddress())) {
return true;
}
log.warn("No match found at matchesRequiredAddress addressOutput/addressEntry " + addressOutput.toString

View File

@ -38,7 +38,7 @@ public class AddressEntry implements Serializable {
private final byte[] pubKey;
private final byte[] pubKeyHash;
public AddressEntry(DeterministicKey keyPair, NetworkParameters params, AddressContext addressContext) {
public AddressEntry(DeterministicKey keyPair, NetworkParameters params, @SuppressWarnings("SameParameterValue") AddressContext addressContext) {
this(keyPair, params, addressContext, null);
}

View File

@ -24,6 +24,7 @@ import javax.inject.Inject;
/**
* A service delivers blockchain functionality from the BitcoinJ library.
*/
@SuppressWarnings({"UnusedDeclaration", "UnusedParameters"})
public class BlockChainService {
@Inject
public BlockChainService() {
@ -31,36 +32,43 @@ public class BlockChainService {
}
//TODO
public boolean isAccountBlackListed(String accountID, BankAccount bankAccount) {
@SuppressWarnings("SameReturnValue")
public boolean isAccountBlackListed(String accountId, BankAccount bankAccount) {
return false;
}
//TODO
@SuppressWarnings("SameReturnValue")
public boolean verifyAccountRegistration() {
return true;
}
@SuppressWarnings("SameReturnValue")
private boolean findAddressInBlockChain(String address) {
// TODO lookup for address in blockchain
return true;
}
@SuppressWarnings("SameReturnValue")
private byte[] getDataForTxWithAddress(String address) {
// TODO return data after OP_RETURN
return null;
}
@SuppressWarnings("SameReturnValue")
private boolean isFeePayed(String address) {
// TODO check if fee is paid
return true;
}
@SuppressWarnings("SameReturnValue")
private boolean isAccountIDBlacklisted(String accountID) {
// TODO check if accountID is on blacklist
return false;
}
@SuppressWarnings("SameReturnValue")
private boolean isBankAccountBlacklisted(BankAccount bankAccount) {
// TODO check if accountID is on blacklist
return false;

View File

@ -80,8 +80,8 @@ public class TradeService {
private final NetworkParameters params;
private final Wallet wallet;
private WalletAppKit walletAppKit;
private FeePolicy feePolicy;
private final WalletAppKit walletAppKit;
private final FeePolicy feePolicy;
public TradeService(NetworkParameters params, Wallet wallet, WalletAppKit walletAppKit, FeePolicy feePolicy) {
this.params = params;
@ -136,7 +136,7 @@ public class TradeService {
// Trade
///////////////////////////////////////////////////////////////////////////////////////////
public TransactionDataResult offererCreatesDepositTxInputs(Coin inputAmount, AddressEntry addressInfo) throws InsufficientMoneyException,
public TransactionDataResult offererCreatesDepositTxInputs(Coin inputAmount, AddressEntry addressInfo) throws
TransactionVerificationException, WalletException {
// We pay the tx fee 2 times to the deposit tx:
@ -199,7 +199,7 @@ public class TradeService {
AddressEntry addressInfo,
byte[] offererPubKey,
byte[] takerPubKey,
byte[] arbitratorPubKey) throws InsufficientMoneyException, SigningException,
byte[] arbitratorPubKey) throws SigningException,
TransactionVerificationException, WalletException {
checkArgument(offererConnectedOutputsForAllInputs.size() > 0);
@ -308,7 +308,6 @@ public class TradeService {
}
// Add taker inputs and apply signature
List<TransactionInput> takerInputs = new ArrayList<>();
for (TransactionOutput connectedOutputForInput : takerConnectedOutputsForAllInputs) {
TransactionOutPoint outPoint = new TransactionOutPoint(params, connectedOutputForInput.getIndex(), connectedOutputForInput.getParentTransaction());
@ -319,7 +318,6 @@ public class TradeService {
throw new TransactionVerificationException("Inputs from taker not singed.");
TransactionInput transactionInput = new TransactionInput(params, depositTx, scriptProgram, outPoint, connectedOutputForInput.getValue());
takerInputs.add(transactionInput);
depositTx.addInput(transactionInput);
}
@ -372,7 +370,7 @@ public class TradeService {
Coin takerPayoutAmount,
String takerAddressString,
AddressEntry addressEntry)
throws AddressFormatException, TransactionVerificationException, WalletException {
throws AddressFormatException, TransactionVerificationException {
Transaction payoutTx = createPayoutTx(depositTx, offererPayoutAmount, takerPayoutAmount, addressEntry.getAddressString(), takerAddressString);
@ -442,7 +440,7 @@ public class TradeService {
return tx;
}
public static void printTxWithInputs(String tracePrefix, Transaction tx) {
private static void printTxWithInputs(String tracePrefix, Transaction tx) {
log.trace(tracePrefix + ": " + tx.toString());
for (TransactionInput input : tx.getInputs()) {
if (input.getConnectedOutput() != null)
@ -474,7 +472,7 @@ public class TradeService {
}
}
private void signInput(Transaction transaction, TransactionInput input, int inputIndex) throws SigningException, TransactionVerificationException {
private void signInput(Transaction transaction, TransactionInput input, int inputIndex) throws SigningException {
Script scriptPubKey = input.getConnectedOutput().getScriptPubKey();
ECKey sigKey = input.getOutpoint().getConnectedKey(wallet);
Sha256Hash hash = transaction.hashForSignature(inputIndex, scriptPubKey, Transaction.SigHash.ALL, false);
@ -510,7 +508,7 @@ public class TradeService {
}
}*/
private void removeSignatures(Transaction transaction) throws InsufficientMoneyException {
private void removeSignatures(Transaction transaction) {
for (TransactionInput input : transaction.getInputs()) {
input.setScriptSig(new Script(new byte[]{}));
}

View File

@ -211,7 +211,7 @@ public class WalletService {
wallet.addEventListener(walletEventListener);
Serializable serializable = persistence.read(this, "addressEntryList");
if (serializable instanceof List) {
if (serializable instanceof List<?>) {
List<AddressEntry> persistedAddressEntryList = (List<AddressEntry>) serializable;
for (AddressEntry persistedAddressEntry : persistedAddressEntryList) {
persistedAddressEntry.setDeterministicKey((DeterministicKey) wallet.findKeyFromPubHash(persistedAddressEntry.getPubKeyHash()));
@ -355,9 +355,6 @@ public class WalletService {
return null;
}
private void notifyConfidenceListeners(Transaction tx) {
}
private TransactionConfidence getTransactionConfidence(Transaction tx, Address address) {
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
@ -412,6 +409,7 @@ public class WalletService {
}
@SuppressWarnings("UnusedDeclaration")
public boolean isRegistrationFeeConfirmed() {
TransactionConfidence transactionConfidence = null;
if (getRegistrationAddressEntry() != null) {
@ -442,7 +440,7 @@ public class WalletService {
return balance;
}
public Coin getWalletBalance() {
Coin getWalletBalance() {
return wallet.getBalance(Wallet.BalanceType.ESTIMATED);
}
@ -454,16 +452,19 @@ public class WalletService {
return getBalanceForAddress(getArbitratorDepositAddressEntry().getAddress());
}
@SuppressWarnings("UnusedDeclaration")
public boolean isRegistrationFeeBalanceNonZero() {
return getRegistrationBalance().compareTo(Coin.ZERO) > 0;
}
@SuppressWarnings("UnusedDeclaration")
public boolean isRegistrationFeeBalanceSufficient() {
return getRegistrationBalance().compareTo(FeePolicy.REGISTRATION_FEE) >= 0;
}
//TODO
public int getNumOfPeersSeenTx(String txID) {
@SuppressWarnings("SameReturnValue")
public int getNumOfPeersSeenTx(String txId) {
// TODO check from blockchain
// will be async
return 3;
@ -558,7 +559,7 @@ public class WalletService {
}
}
public static void printTxWithInputs(String tracePrefix, Transaction tx) {
private static void printTxWithInputs(String tracePrefix, Transaction tx) {
log.trace(tracePrefix + ": " + tx.toString());
for (TransactionInput input : tx.getInputs()) {
if (input.getConnectedOutput() != null)

View File

@ -21,12 +21,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SigningException extends Exception {
private static final long serialVersionUID = -4585301671813918976L;
private static final Logger log = LoggerFactory.getLogger(SigningException.class);
public SigningException(String message) {
super(message);
}
@SuppressWarnings("WeakerAccess")
public SigningException(Throwable t) {
super(t);

View File

@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TransactionVerificationException extends Exception {
private static final long serialVersionUID = 4447301533313718296L;
private static final Logger log = LoggerFactory.getLogger(TransactionVerificationException.class);
public TransactionVerificationException(Throwable t) {

View File

@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WalletException extends Exception {
private static final long serialVersionUID = 4782095361220152803L;
private static final Logger log = LoggerFactory.getLogger(WalletException.class);
public WalletException(Throwable t) {

View File

@ -31,6 +31,7 @@ public class AddressConfidenceListener {
return address;
}
@SuppressWarnings("UnusedParameters")
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
}
}

View File

@ -34,6 +34,7 @@ public class BalanceListener {
return address;
}
@SuppressWarnings("UnusedParameters")
public void onBalanceChanged(Coin balance) {
}
}

View File

@ -30,6 +30,7 @@ public class TxConfidenceListener {
return txID;
}
@SuppressWarnings("UnusedParameters")
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
}
}

View File

@ -31,10 +31,10 @@ import io.bitsquare.trade.protocol.trade.offerer.tasks.ProcessPayoutTxPublishedM
import io.bitsquare.trade.protocol.trade.offerer.tasks.ProcessRequestOffererPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.offerer.tasks.ProcessRequestTakeOfferMessage;
import io.bitsquare.trade.protocol.trade.offerer.tasks.ProcessTakeOfferFeePayedMessage;
import io.bitsquare.trade.protocol.trade.offerer.tasks.RequestDepositPayment;
import io.bitsquare.trade.protocol.trade.offerer.tasks.RespondToTakeOfferRequest;
import io.bitsquare.trade.protocol.trade.offerer.tasks.SendBankTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.offerer.tasks.SendDepositTxIdToTaker;
import io.bitsquare.trade.protocol.trade.offerer.tasks.RequestDepositPayment;
import io.bitsquare.trade.protocol.trade.offerer.tasks.SetupListenerForBlockChainConfirmation;
import io.bitsquare.trade.protocol.trade.offerer.tasks.SignAndPublishDepositTx;
import io.bitsquare.trade.protocol.trade.offerer.tasks.SignPayoutTx;
@ -43,18 +43,18 @@ import io.bitsquare.trade.protocol.trade.offerer.tasks.VerifyTakeOfferFeePayment
import io.bitsquare.trade.protocol.trade.offerer.tasks.VerifyTakerAccount;
import io.bitsquare.trade.protocol.trade.taker.SellerAsTakerProtocol;
import io.bitsquare.trade.protocol.trade.taker.tasks.CreateAndSignContract;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.PayTakeOfferFee;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessBankTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessRespondToTakeOfferRequestMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessRequestDepositPaymentMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessRespondToTakeOfferRequestMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.RequestTakeOffer;
import io.bitsquare.trade.protocol.trade.taker.tasks.SendPayoutTxToOfferer;
import io.bitsquare.trade.protocol.trade.taker.tasks.SendSignedTakerDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.SendTakeOfferFeePayedMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.SignAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.VerifyOfferFeePayment;
import io.bitsquare.trade.protocol.trade.taker.tasks.VerifyOffererAccount;
import io.bitsquare.util.taskrunner.Task;

View File

@ -103,17 +103,17 @@ public class TradeManager {
this.offerBookService = offerBookService;
Object openOffersObject = persistence.read(this, "openOffers");
if (openOffersObject instanceof Map) {
if (openOffersObject instanceof Map<?, ?>) {
openOffers.putAll((Map<String, OpenOffer>) openOffersObject);
}
Object pendingTradesObject = persistence.read(this, "pendingTrades");
if (pendingTradesObject instanceof Map) {
if (pendingTradesObject instanceof Map<?, ?>) {
pendingTrades.putAll((Map<String, Trade>) pendingTradesObject);
}
Object closedTradesObject = persistence.read(this, "closedTrades");
if (closedTradesObject instanceof Map) {
if (closedTradesObject instanceof Map<?, ?>) {
closedTrades.putAll((Map<String, Trade>) closedTradesObject);
}

View File

@ -90,7 +90,7 @@ public class CheckOfferAvailabilityProtocol {
// Incoming message handling
///////////////////////////////////////////////////////////////////////////////////////////
private void handleMessage(Message message, @SuppressWarnings("UnusedParameters") Peer sender) {
private void handleMessage(Message message, Peer sender) {
if (!isCanceled) {
if (message instanceof ReportOfferAvailabilityMessage)
handleReportOfferAvailabilityMessage((ReportOfferAvailabilityMessage) message);

View File

@ -47,7 +47,7 @@ public class SetupListenerForBlockChainConfirmation extends Task<BuyerAsOffererM
model.getTrade().setState(Trade.State.DEPOSIT_CONFIRMED);
boolean removed = confidence.removeEventListener(this);
log.debug("listener removed? "+removed);
log.debug("listener removed? " + removed);
}
}
});

View File

@ -28,7 +28,6 @@ import io.bitsquare.trade.protocol.trade.offerer.messages.RequestDepositPaymentM
import io.bitsquare.trade.protocol.trade.offerer.messages.RespondToTakeOfferRequestMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.CreateAndSignContract;
import io.bitsquare.trade.protocol.trade.taker.tasks.GetPeerAddress;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.PayTakeOfferFee;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessBankTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.ProcessDepositTxPublishedMessage;
@ -40,6 +39,7 @@ import io.bitsquare.trade.protocol.trade.taker.tasks.SendSignedTakerDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.SendTakeOfferFeePayedMessage;
import io.bitsquare.trade.protocol.trade.taker.tasks.SignAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.taker.tasks.VerifyOfferFeePayment;
import io.bitsquare.trade.protocol.trade.taker.tasks.VerifyOffererAccount;
@ -196,7 +196,7 @@ public class SellerAsTakerProtocol {
// Massage dispatcher
///////////////////////////////////////////////////////////////////////////////////////////
private void handleMessage(Message message, @SuppressWarnings("UnusedParameters") Peer sender) {
private void handleMessage(Message message, Peer sender) {
log.trace("handleNewMessage: message = " + message.getClass().getSimpleName());
if (message instanceof TradeMessage) {
TradeMessage tradeMessage = (TradeMessage) message;

View File

@ -26,7 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
import static io.bitsquare.util.Validator.*;
import static io.bitsquare.util.Validator.checkTradeId;
public class ProcessDepositTxPublishedMessage extends Task<SellerAsTakerModel> {
private static final Logger log = LoggerFactory.getLogger(ProcessDepositTxPublishedMessage.class);

View File

@ -20,7 +20,6 @@ package io.bitsquare.trade.tomp2p;
import io.bitsquare.network.tomp2p.TomP2PNode;
import io.bitsquare.trade.TradeMessageModule;
import io.bitsquare.trade.TradeMessageService;
import io.bitsquare.user.User;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@ -47,8 +46,8 @@ class TomP2PTradeMessageServiceProvider implements Provider<TradeMessageService>
private final TradeMessageService tradeMessageService;
@Inject
public TomP2PTradeMessageServiceProvider(User user, TomP2PNode tomP2PNode) {
tradeMessageService = new TomP2PTradeMessageService(user, tomP2PNode);
public TomP2PTradeMessageServiceProvider(TomP2PNode tomP2PNode) {
tradeMessageService = new TomP2PTradeMessageService(tomP2PNode);
tradeMessageService.setExecutor(Platform::runLater);
}

View File

@ -25,7 +25,6 @@ import io.bitsquare.trade.TradeMessageService;
import io.bitsquare.trade.handlers.MessageHandler;
import io.bitsquare.trade.listeners.GetPeerAddressListener;
import io.bitsquare.trade.listeners.SendMessageListener;
import io.bitsquare.user.User;
import java.security.PublicKey;
@ -64,7 +63,7 @@ public class TomP2PTradeMessageService implements TradeMessageService {
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
public TomP2PTradeMessageService(User user, TomP2PNode tomP2PNode) {
public TomP2PTradeMessageService(TomP2PNode tomP2PNode) {
this.tomP2PNode = tomP2PNode;
}

View File

@ -96,7 +96,7 @@ public class PlaceOfferProtocolTest {
user.applyPersistedUser(null);
bootstrappedPeerBuilder = new BootstrappedPeerBuilder(Node.DEFAULT_PORT, false, bootstrapNode, "<unspecified>");
tomP2PNode = new TomP2PNode(bootstrappedPeerBuilder);
tradeMessageService = new TomP2PTradeMessageService(user, tomP2PNode);
tradeMessageService = new TomP2PTradeMessageService(tomP2PNode);
Observable<BootstrapState> messageObservable = tomP2PNode.bootstrap(user.getNetworkKeyPair(), tradeMessageService);
messageObservable.publish();