Cleanup from code inspect

This commit is contained in:
Manfred Karrer 2015-03-16 23:41:50 +01:00
parent f0d9a5d81e
commit 232270bf86
32 changed files with 84 additions and 289 deletions

View File

@ -31,7 +31,6 @@ import io.bitsquare.offer.tomp2p.TomP2POfferModule;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.settings.Preferences;
import io.bitsquare.trade.TradeMessageModule;
import io.bitsquare.trade.TradeModule;
import io.bitsquare.trade.tomp2p.TomP2PTradeMessageModule;
import io.bitsquare.user.User;
@ -72,7 +71,6 @@ class BitsquareAppModule extends BitsquareModule {
install(networkModule());
install(bitcoinModule());
install(cryptoModule());
install(tradeModule());
install(tradeMessageModule());
install(offerModule());
install(arbitratorMessageModule());
@ -95,10 +93,6 @@ class BitsquareAppModule extends BitsquareModule {
return new CryptoModule(env);
}
protected TradeModule tradeModule() {
return new TradeModule(env);
}
protected TradeMessageModule tradeMessageModule() {
return new TomP2PTradeMessageModule(env);
}

View File

@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory;
import static com.google.inject.internal.util.$Preconditions.*;
//
// TradeService handles all trade relevant transactions as a delegate for WalletService
/*
Deposit tx:

View File

@ -28,7 +28,6 @@ import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.DownloadListener;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.InsufficientMoneyException;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Transaction;
@ -157,7 +156,7 @@ public class WalletService {
initWallet();
tradeService = new TradeService(params, wallet, walletAppKit, feePolicy);
status.onCompleted();
}
};
@ -478,7 +477,7 @@ public class WalletService {
public TradeService getTradeService() {
return tradeService;
}
public void payRegistrationFee(String stringifiedBankAccounts, FutureCallback<Transaction> callback) throws
InsufficientMoneyException {
log.debug("payRegistrationFee");
@ -513,7 +512,6 @@ public class WalletService {
printTxWithInputs("payRegistrationFee", tx);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Withdrawal
@ -547,71 +545,6 @@ public class WalletService {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Trade process
///////////////////////////////////////////////////////////////////////////////////////////
/*
public TransactionDataResult offererCreatesDepositTxInputs(Coin inputAmount, AddressEntry addressInfo) throws InsufficientMoneyException,
TransactionVerificationException, WalletException {
// We pay the tx fee 2 times to the deposit tx:
// 1. Will be spent when publishing the deposit tx (paid by offerer)
// 2. Will be added to the MS amount, so when publishing the payout tx the fee is already there and the outputs are not changed by fee reduction
// The fee for the payout will be paid by the taker.
// inputAmount includes the tx fee. So we subtract the fee to get the dummyOutputAmount.
Coin dummyOutputAmount = inputAmount.subtract(FeePolicy.TX_FEE);
Transaction dummyTX = new Transaction(params);
// The output is just used to get the right inputs and change outputs, so we use an anonymous ECKey, as it will never be used for anything.
// We don't care about fee calculation differences between the real tx and that dummy tx as we use a static tx fee.
TransactionOutput dummyOutput = new TransactionOutput(params, dummyTX, dummyOutputAmount, new ECKey().toAddress(params));
dummyTX.addOutput(dummyOutput);
// Fin the needed inputs to pay the output, optional add change output.
// Normally only 1 input and no change output is used, but we support multiple inputs and outputs. Our spending transaction output is from the create
// offer fee payment. In future changes (in case of no offer fee) multiple inputs might become used.
addAvailableInputsAndChangeOutputs(dummyTX, addressInfo);
// The completeTx() call signs the input, but we don't want to pass over signed tx inputs
// But to be safe and to support future changes (in case of no offer fee) we handle potential multiple inputs
removeSignatures(dummyTX);
verifyTransaction(dummyTX);
checkWalletConsistency();
// The created tx looks like:
*//*
IN[0] any input > inputAmount (including tx fee) (unsigned)
IN[1...n] optional inputs supported, but currently there is just 1 input (unsigned)
OUT[0] dummyOutputAmount (inputAmount - tx fee)
OUT[1] Optional Change = inputAmount - dummyOutputAmount - tx fee
OUT[2...n] optional more outputs are supported, but currently there is just max. 1 optional change output
*//*
printTxWithInputs("dummyTX", dummyTX);
List<TransactionOutput> connectedOutputsForAllInputs = new ArrayList<>();
for (TransactionInput input : dummyTX.getInputs()) {
connectedOutputsForAllInputs.add(input.getConnectedOutput());
}
// Only save offerer outputs, the MS output is ignored
List<TransactionOutput> outputs = new ArrayList<>();
for (TransactionOutput output : dummyTX.getOutputs()) {
if (output.equals(dummyOutput))
continue;
outputs.add(output);
}
return new TransactionDataResult(connectedOutputsForAllInputs, outputs);
}*/
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@ -639,53 +572,6 @@ public class WalletService {
// Inner classes
///////////////////////////////////////////////////////////////////////////////////////////
public class TransactionDataResult {
private List<TransactionOutput> connectedOutputsForAllInputs;
private List<TransactionOutput> outputs;
private Transaction depositTx;
private Transaction payoutTx;
private ECKey.ECDSASignature offererSignature;
public TransactionDataResult(List<TransactionOutput> connectedOutputsForAllInputs, List<TransactionOutput> outputs) {
this.connectedOutputsForAllInputs = connectedOutputsForAllInputs;
this.outputs = outputs;
}
public TransactionDataResult(Transaction depositTx, List<TransactionOutput> connectedOutputsForAllInputs, List<TransactionOutput> outputs) {
this.depositTx = depositTx;
this.connectedOutputsForAllInputs = connectedOutputsForAllInputs;
this.outputs = outputs;
}
public TransactionDataResult(Transaction payoutTx, ECKey.ECDSASignature offererSignature) {
this.payoutTx = payoutTx;
this.offererSignature = offererSignature;
}
public List<TransactionOutput> getOutputs() {
return outputs;
}
public List<TransactionOutput> getConnectedOutputsForAllInputs() {
return connectedOutputsForAllInputs;
}
public Transaction getDepositTx() {
return depositTx;
}
public Transaction getPayoutTx() {
return payoutTx;
}
public ECKey.ECDSASignature getOffererSignature() {
return offererSignature;
}
}
private static class ObservableDownloadListener extends DownloadListener {
private final Subject<Double, Double> subject = BehaviorSubject.create(0d);

View File

@ -29,7 +29,6 @@ import io.bitsquare.offer.Offer;
import io.bitsquare.offer.OfferBookService;
import io.bitsquare.offer.OpenOffer;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.handlers.MessageHandler;
import io.bitsquare.trade.handlers.TransactionResultHandler;
import io.bitsquare.trade.listeners.SendMessageListener;
import io.bitsquare.trade.protocol.availability.CheckOfferAvailabilityModel;
@ -81,7 +80,6 @@ public class TradeManager {
private final ObservableMap<String, OpenOffer> openOffers = FXCollections.observableHashMap();
private final ObservableMap<String, Trade> pendingTrades = FXCollections.observableHashMap();
private final ObservableMap<String, Trade> closedTrades = FXCollections.observableHashMap();
private final MessageHandler messageHandler;
private Trade currentPendingTrade;
@ -118,9 +116,8 @@ public class TradeManager {
if (closedTradesObject instanceof Map) {
closedTrades.putAll((Map<String, Trade>) closedTradesObject);
}
messageHandler = this::handleMessage;
tradeMessageService.addMessageHandler(messageHandler);
tradeMessageService.addMessageHandler(this::handleMessage);
}
// When all services are initialized we create the protocols for our open offers (which will listen for take offer requests)
@ -190,9 +187,7 @@ public class TradeManager {
createBuyerAcceptsOfferProtocol(openOffer);
resultHandler.handleResult(transaction);
},
(message) -> {
errorMessageHandler.handleErrorMessage(message);
}
(message) -> errorMessageHandler.handleErrorMessage(message)
);
placeOfferProtocol.placeOffer();
@ -249,7 +244,7 @@ public class TradeManager {
}
public void onFiatPaymentStarted(String tradeId) {
// TODO remove if check when peristence is impl.
// TODO remove if check when persistence is impl.
if (buyerAcceptsOfferProtocolMap.containsKey(tradeId)) {
buyerAcceptsOfferProtocolMap.get(tradeId).onFiatPaymentStarted();
persistPendingTrades();
@ -442,9 +437,9 @@ public class TradeManager {
closedTrades.put(trade.getId(), trade);
persistClosedTrades();
}
else {
/*else {
// TODO add failed trades to history
}
}*/
}
private void disposeCheckOfferAvailabilityRequest(Offer offer) {
@ -456,7 +451,7 @@ public class TradeManager {
}
}
public boolean isOfferOpen(String offerId) {
boolean isOfferOpen(String offerId) {
// Don't use openOffers as the offer gets removed async from DHT, but is added sync to pendingTrades
return !pendingTrades.containsKey(offerId) && !closedTrades.containsKey(offerId);
}

View File

@ -1,36 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade;
import io.bitsquare.BitsquareModule;
import com.google.inject.Singleton;
import org.springframework.core.env.Environment;
public class TradeModule extends BitsquareModule {
public TradeModule(Environment env) {
super(env);
}
@Override
protected void configure() {
bind(TradeManager.class).in(Singleton.class);
}
}

View File

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

View File

@ -23,6 +23,7 @@ import java.io.Serializable;
public class ReportOfferAvailabilityMessage implements Serializable, OfferMessage {
private static final long serialVersionUID = 6177387534187739018L;
private final String offerId;
private final boolean isOfferOpen;

View File

@ -24,6 +24,7 @@ import java.io.Serializable;
// That msg is used to ping the offerer if he is online and if the offer is still available
public class RequestIsOfferAvailableMessage implements Serializable, OfferMessage {
private static final long serialVersionUID = 4630151440192191798L;
private final String offerId;
public RequestIsOfferAvailableMessage(String offerId) {

View File

@ -44,6 +44,7 @@ public class GetPeerAddress extends Task<CheckOfferAvailabilityModel> {
log.trace("Found peer: " + peer.toString());
model.setPeer(peer);
complete();
}

View File

@ -32,8 +32,8 @@ public class PlaceOfferProtocol {
private static final Logger log = LoggerFactory.getLogger(PlaceOfferProtocol.class);
private final PlaceOfferModel model;
private TransactionResultHandler resultHandler;
private ErrorMessageHandler errorMessageHandler;
private final TransactionResultHandler resultHandler;
private final ErrorMessageHandler errorMessageHandler;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor

View File

@ -28,6 +28,8 @@ import org.bitcoinj.core.Transaction;
import com.google.common.util.concurrent.FutureCallback;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -56,44 +58,39 @@ public class BroadcastCreateOfferFeeTx extends Task<PlaceOfferModel> {
@Override
public void onSuccess(Transaction transaction) {
log.info("Broadcast of offer fee payment succeeded: transaction = " + transaction.toString());
if (transaction != null) {
if (model.getTransaction().getHashAsString() == transaction.getHashAsString()) {
// No tx malleability happened after broadcast (still not in blockchain)
complete();
}
else {
log.warn("Tx malleability happened after broadcast. We publish the changed offer to the DHT again.");
// Tx malleability happened after broadcast. We publish the changed offer to the DHT again.
model.getOfferBookService().removeOffer(model.getOffer(),
() -> {
log.info("We store now the changed txID to the offer and add that again.");
// We store now the changed txID to the offer and add that again.
model.getOffer().setOfferFeePaymentTxID(transaction.getHashAsString());
model.getOfferBookService().addOffer(model.getOffer(),
() -> {
complete();
},
(message, throwable) -> {
log.error("addOffer failed");
addOfferFailed = true;
failed(throwable);
});
},
(message, throwable) -> {
log.error("removeOffer failed");
removeOfferFailed = true;
failed(throwable);
});
}
if (model.getTransaction().getHashAsString().equals(transaction.getHashAsString())) {
// No tx malleability happened after broadcast (still not in blockchain)
complete();
}
else {
failed("Fault reason: Transaction = null.");
log.warn("Tx malleability happened after broadcast. We publish the changed offer to the DHT again.");
// Tx malleability happened after broadcast. We publish the changed offer to the DHT again.
model.getOfferBookService().removeOffer(model.getOffer(),
() -> {
log.info("We store now the changed txID to the offer and add that again.");
// We store now the changed txID to the offer and add that again.
model.getOffer().setOfferFeePaymentTxID(transaction.getHashAsString());
model.getOfferBookService().addOffer(model.getOffer(),
() -> {
complete();
},
(message, throwable) -> {
log.error("addOffer failed");
addOfferFailed = true;
failed(throwable);
});
},
(message, throwable) -> {
log.error("removeOffer failed");
removeOfferFailed = true;
failed(throwable);
});
}
}
@Override
public void onFailure(Throwable t) {
public void onFailure(@NotNull Throwable t) {
failed(t);
}
});

View File

@ -39,34 +39,34 @@ public class OfferSharedModel extends SharedModel {
protected static final Logger log = LoggerFactory.getLogger(OfferSharedModel.class);
// provided
protected final Offer offer;
protected final TradeMessageService tradeMessageService;
protected final WalletService walletService;
protected final BlockChainService blockChainService;
protected final SignatureService signatureService;
private final Offer offer;
private final TradeMessageService tradeMessageService;
private final WalletService walletService;
private final BlockChainService blockChainService;
private final SignatureService signatureService;
// derived
protected final String id;
protected final BankAccount bankAccount;
protected final String accountId;
protected final PublicKey networkPubKey;
protected final byte[] registrationPubKey;
protected final DeterministicKey registrationKeyPair;
protected final byte[] arbitratorPubKey;
protected final AddressEntry addressEntry;
private final String id;
private final BankAccount bankAccount;
private final String accountId;
private final PublicKey networkPubKey;
private final byte[] registrationPubKey;
private final DeterministicKey registrationKeyPair;
private final byte[] arbitratorPubKey;
private final AddressEntry addressEntry;
private final TradeService tradeService;
// data written/read by tasks
protected TradeMessage tradeMessage;
private TradeMessage tradeMessage;
public OfferSharedModel(Offer offer,
TradeMessageService tradeMessageService,
WalletService walletService,
BlockChainService blockChainService,
SignatureService signatureService,
User user) {
protected OfferSharedModel(Offer offer,
TradeMessageService tradeMessageService,
WalletService walletService,
BlockChainService blockChainService,
SignatureService signatureService,
User user) {
this.offer = offer;
this.tradeMessageService = tradeMessageService;
this.walletService = walletService;

View File

@ -112,7 +112,6 @@ public class BuyerAsOffererModel extends OfferSharedModel {
this.offererOutputs = offererOutputs;
}
public OpenOffer getOpenOffer() {
return openOffer;
}
@ -121,7 +120,6 @@ public class BuyerAsOffererModel extends OfferSharedModel {
return taker;
}
public String getTakeOfferFeeTxId() {
return takeOfferFeeTxId;
}
@ -202,7 +200,6 @@ public class BuyerAsOffererModel extends OfferSharedModel {
this.taker = taker;
}
public void setTakerDepositTx(Transaction takerDepositTx) {
this.takerDepositTx = takerDepositTx;
}

View File

@ -56,7 +56,7 @@ public class BuyerAsOffererProtocol {
private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererProtocol.class);
private BuyerAsOffererModel model;
private final BuyerAsOffererModel model;
private final MessageHandler messageHandler;
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -24,7 +24,7 @@ import io.bitsquare.util.taskrunner.TaskRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BuyerAsOffererTaskRunner<T extends BuyerAsOffererModel> extends TaskRunner<BuyerAsOffererModel> {
class BuyerAsOffererTaskRunner<T extends BuyerAsOffererModel> extends TaskRunner<BuyerAsOffererModel> {
private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererTaskRunner.class);
public BuyerAsOffererTaskRunner(T sharedModel, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {

View File

@ -26,8 +26,8 @@ import java.io.Serializable;
public class BankTransferStartedMessage implements Serializable, TradeMessage {
private static final long serialVersionUID = -3479634129543632523L;
private final String tradeId;
private final Transaction depositTx;
private final byte[] offererSignature;
private final Coin offererPayoutAmount;

View File

@ -24,10 +24,9 @@ import org.bitcoinj.core.Transaction;
import java.io.Serializable;
public class DepositTxPublishedMessage implements Serializable, TradeMessage {
private static final long serialVersionUID = -1532231540167406581L;
private final String tradeId;
private final Transaction depositTx;
public DepositTxPublishedMessage(String tradeId, Transaction depositTx) {

View File

@ -21,14 +21,13 @@ import io.bitsquare.trade.protocol.trade.TradeMessage;
import java.io.Serializable;
import org.jetbrains.annotations.NotNull;
public class RespondToTakeOfferRequestMessage implements Serializable, TradeMessage {
private static final long serialVersionUID = 6177387534087739018L;
private final String tradeId;
private final boolean offerIsAvailable;
public RespondToTakeOfferRequestMessage(@NotNull String tradeId, boolean offerIsAvailable) {
public RespondToTakeOfferRequestMessage(String tradeId, boolean offerIsAvailable) {
this.tradeId = tradeId;
this.offerIsAvailable = offerIsAvailable;
}

View File

@ -40,7 +40,7 @@ public class GetOffererDepositTxInputs extends Task<BuyerAsOffererModel> {
protected void doRun() {
try {
Coin offererInputAmount = model.getTrade().getSecurityDeposit().add(FeePolicy.TX_FEE);
AddressEntry addressInfo = model.getWalletService().getAddressEntry(model.getId());
AddressEntry addressInfo = model.getAddressEntry();
TradeService.TransactionDataResult result = model.getTradeService().offererCreatesDepositTxInputs(offererInputAmount, addressInfo);
model.setOffererConnectedOutputsForAllInputs(result.getConnectedOutputsForAllInputs());

View File

@ -53,7 +53,7 @@ public class RequestDepositPayment extends Task<BuyerAsOffererModel> {
@Override
public void handleFault() {
failed("RequestTakerDepositPaymentMessage did not arrive at peer");
failed();
}
});
}

View File

@ -41,7 +41,7 @@ public class SignPayoutTx extends Task<BuyerAsOffererModel> {
Trade trade = model.getTrade();
Coin securityDeposit = trade.getSecurityDeposit();
Coin offererPayoutAmount = trade.getTradeAmount().add(securityDeposit);
Coin takerPayoutAmount = securityDeposit;
@SuppressWarnings("UnnecessaryLocalVariable") Coin takerPayoutAmount = securityDeposit;
TradeService.TransactionDataResult result = model.getTradeService().offererCreatesAndSignsPayoutTx(
trade.getDepositTx(),

View File

@ -49,13 +49,10 @@ public class SellerAsTakerModel extends OfferSharedModel {
// written/read by task
private Peer offerer;
private Transaction preparedDepositTx;
private Transaction depositTx;
private Transaction signedTakerDepositTx;
private Transaction payoutTx;
private Coin takerPayoutAmount;
private byte[] offererPubKey;
private long offererTxOutIndex;
private Coin offererPayoutAmount;
private String offererPayoutAddress;
private List<TransactionOutput> offererConnectedOutputsForAllInputs;
@ -134,23 +131,6 @@ public class SellerAsTakerModel extends OfferSharedModel {
return offererPubKey;
}
public Transaction getPreparedDepositTx() {
return preparedDepositTx;
}
public void setPreparedDepositTx(Transaction preparedDepositTx) {
this.preparedDepositTx = preparedDepositTx;
}
public long getOffererTxOutIndex() {
return offererTxOutIndex;
}
public void setOffererTxOutIndex(long offererTxOutIndex) {
this.offererTxOutIndex = offererTxOutIndex;
}
public Transaction getDepositTx() {
return depositTx;
}
@ -183,15 +163,6 @@ public class SellerAsTakerModel extends OfferSharedModel {
this.offererPayoutAddress = offererPayoutAddress;
}
public Transaction getSignedTakerDepositTx() {
return signedTakerDepositTx;
}
public void setSignedTakerDepositTx(Transaction signedTakerDepositTx) {
this.signedTakerDepositTx = signedTakerDepositTx;
}
public void setTakerConnectedOutputsForAllInputs(List<TransactionOutput> takerConnectedOutputsForAllInputs) {
this.takerConnectedOutputsForAllInputs = takerConnectedOutputsForAllInputs;
}

View File

@ -196,7 +196,7 @@ public class SellerAsTakerProtocol {
// Massage dispatcher
///////////////////////////////////////////////////////////////////////////////////////////
private void handleMessage(Message message, Peer sender) {
private void handleMessage(Message message, @SuppressWarnings("UnusedParameters") Peer sender) {
log.trace("handleNewMessage: message = " + message.getClass().getSimpleName());
if (message instanceof TradeMessage) {
TradeMessage tradeMessage = (TradeMessage) message;

View File

@ -24,7 +24,7 @@ import io.bitsquare.util.taskrunner.TaskRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SellerAsTakerTaskRunner<T extends SellerAsTakerModel> extends TaskRunner<SellerAsTakerModel> {
class SellerAsTakerTaskRunner<T extends SellerAsTakerModel> extends TaskRunner<SellerAsTakerModel> {
private static final Logger log = LoggerFactory.getLogger(SellerAsTakerTaskRunner.class);
public SellerAsTakerTaskRunner(T sharedModel, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {

View File

@ -25,6 +25,7 @@ import java.io.Serializable;
public class PayoutTxPublishedMessage implements Serializable, TradeMessage {
private static final long serialVersionUID = 1288653559218403873L;
private final String tradeId;
private final Transaction payoutTx;

View File

@ -31,16 +31,17 @@ import java.util.List;
public class RequestOffererPublishDepositTxMessage implements Serializable, TradeMessage {
private static final long serialVersionUID = 2179683654379803071L;
private final String tradeId;
private final BankAccount bankAccount;
private final String accountID;
private final PublicKey takerMessagePublicKey;
private final String contractAsJson;
private final String takerContractSignature;
private String takerPayoutAddress;
private Transaction takersDepositTx;
private List<TransactionOutput> takerConnectedOutputsForAllInputs;
private List<TransactionOutput> takerOutputs;
private final String takerPayoutAddress;
private final Transaction takersDepositTx;
private final List<TransactionOutput> takerConnectedOutputsForAllInputs;
private final List<TransactionOutput> takerOutputs;
public RequestOffererPublishDepositTxMessage(String tradeId,
BankAccount bankAccount,

View File

@ -43,12 +43,14 @@ public class GetPeerAddress extends Task<SellerAsTakerModel> {
log.trace("Found peer: " + peer.toString());
model.setOfferer(peer);
complete();
}
@Override
public void onFailed() {
model.getOffer().setState(Offer.State.OFFERER_OFFLINE);
failed();
}
});

View File

@ -22,7 +22,6 @@ import io.bitsquare.trade.protocol.trade.taker.SellerAsTakerModel;
import io.bitsquare.util.taskrunner.Task;
import io.bitsquare.util.taskrunner.TaskRunner;
import org.bitcoinj.core.InsufficientMoneyException;
import org.bitcoinj.core.Transaction;
import com.google.common.util.concurrent.FutureCallback;
@ -57,7 +56,7 @@ public class PayTakeOfferFee extends Task<SellerAsTakerModel> {
failed(t);
}
});
} catch (InsufficientMoneyException e) {
} catch (Exception e) {
appendToErrorMessage(e.getMessage());
failed(e);
}

View File

@ -34,7 +34,7 @@ public class SendTakeOfferFeePayedMessage extends Task<SellerAsTakerModel> {
super(taskHandler, model);
}
public int retryCounter = 0;
private int retryCounter = 0;
@Override
protected void doRun() {

View File

@ -23,7 +23,6 @@ import io.bitsquare.util.taskrunner.Task;
import io.bitsquare.util.taskrunner.TaskRunner;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.Utils;
import com.google.common.util.concurrent.FutureCallback;
@ -52,9 +51,6 @@ public class SignAndPublishPayoutTx extends Task<SellerAsTakerModel> {
new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
log.debug("published payoutTx " + transaction);
String payoutTxAsHex = Utils.HEX.encode(transaction.bitcoinSerialize());
model.setPayoutTx(transaction);
model.getTrade().setState(Trade.State.PAYOUT_PUBLISHED);

View File

@ -22,7 +22,6 @@ import io.bitsquare.trade.TradeMessageModule;
import io.bitsquare.trade.TradeMessageService;
import io.bitsquare.user.User;
import com.google.inject.Injector;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@ -42,11 +41,6 @@ public class TomP2PTradeMessageModule extends TradeMessageModule {
protected void doConfigure() {
bind(TradeMessageService.class).toProvider(TomP2PTradeMessageServiceProvider.class).in(Singleton.class);
}
@Override
protected void doClose(Injector injector) {
super.doClose(injector);
}
}
class TomP2PTradeMessageServiceProvider implements Provider<TradeMessageService> {

View File

@ -56,7 +56,6 @@ public class TomP2PTradeMessageService implements TradeMessageService {
private static final Logger log = LoggerFactory.getLogger(TomP2PTradeMessageService.class);
private final TomP2PNode tomP2PNode;
private final User user;
private final List<MessageHandler> messageHandlers = new ArrayList<>();
private Executor executor;
@ -66,11 +65,9 @@ public class TomP2PTradeMessageService implements TradeMessageService {
///////////////////////////////////////////////////////////////////////////////////////////
public TomP2PTradeMessageService(User user, TomP2PNode tomP2PNode) {
this.user = user;
this.tomP2PNode = tomP2PNode;
}
public void setExecutor(Executor executor) {
this.executor = executor;
}