mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-15 10:26:37 -04:00
refactor packages and rename protocol class for trade process, comments
This commit is contained in:
parent
c455ae176b
commit
d3d23cc459
@ -27,7 +27,7 @@ import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.msg.BootstrapListener;
|
||||
import io.bitsquare.msg.listeners.BootstrapListener;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
|
@ -29,8 +29,8 @@ import io.bitsquare.gui.util.BitSquareValidator;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.protocol.taker.ProtocolForTakerAsSeller;
|
||||
import io.bitsquare.trade.protocol.taker.ProtocolForTakerAsSellerListener;
|
||||
import io.bitsquare.trade.protocol.trade.taker.SellerTakesOfferProtocol;
|
||||
import io.bitsquare.trade.protocol.trade.taker.SellerTakesOfferProtocolListener;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
|
||||
@ -173,7 +173,7 @@ public class TakerOfferController extends CachedViewController {
|
||||
else {
|
||||
takeOfferButton.setDisable(true);
|
||||
amountTextField.setEditable(false);
|
||||
tradeManager.takeOffer(amount, offer, new ProtocolForTakerAsSellerListener() {
|
||||
tradeManager.takeOffer(amount, offer, new SellerTakesOfferProtocolListener() {
|
||||
@Override
|
||||
public void onDepositTxPublished(String depositTxId) {
|
||||
setDepositTxId(depositTxId);
|
||||
@ -207,19 +207,19 @@ public class TakerOfferController extends CachedViewController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(Throwable throwable, ProtocolForTakerAsSeller.State state) {
|
||||
public void onFault(Throwable throwable, SellerTakesOfferProtocol.State state) {
|
||||
log.error("Error while executing trade process at state: " + state + " / " + throwable);
|
||||
Popups.openErrorPopup("Error while executing trade process",
|
||||
"Error while executing trade process at state: " + state + " / " + throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWaitingForPeerResponse(ProtocolForTakerAsSeller.State state) {
|
||||
public void onWaitingForPeerResponse(SellerTakesOfferProtocol.State state) {
|
||||
log.debug("Waiting for peers response at state " + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(ProtocolForTakerAsSeller.State state) {
|
||||
public void onCompleted(SellerTakesOfferProtocol.State state) {
|
||||
log.debug("Trade protocol completed at state " + state);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,6 @@ public class BitSquareValidator {
|
||||
public static boolean validateStringAsDouble(String input) {
|
||||
try {
|
||||
input = input.replace(",", ".");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
Double.parseDouble(input);
|
||||
return true;
|
||||
} catch (NumberFormatException | NullPointerException e) {
|
||||
|
@ -55,7 +55,6 @@ public abstract class NumberValidator {
|
||||
|
||||
protected ValidationResult validateIfNumber(String input) {
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
Double.parseDouble(input);
|
||||
return new ValidationResult(true);
|
||||
} catch (Exception e) {
|
||||
|
@ -19,6 +19,9 @@ package io.bitsquare.msg;
|
||||
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
||||
/**
|
||||
* Interface for the object handling incoming messages.
|
||||
*/
|
||||
public interface MessageBroker {
|
||||
void handleMessage(Object message, PeerAddress peerAddress);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.msg;
|
||||
|
||||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.msg.listeners.BootstrapListener;
|
||||
import io.bitsquare.msg.listeners.GetPeerAddressListener;
|
||||
import io.bitsquare.msg.listeners.IncomingTradeMessageListener;
|
||||
import io.bitsquare.msg.listeners.OrderBookListener;
|
||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
// TODO Might be better with a config file
|
||||
public class SeedNodeAddress {
|
||||
private final String id;
|
||||
private final String ip;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.msg;
|
||||
package io.bitsquare.msg.listeners;
|
||||
|
||||
public interface BootstrapListener {
|
||||
public void onCompleted();
|
@ -1,24 +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.msg.listeners;
|
||||
|
||||
public interface PingPeerListener {
|
||||
void onPing();
|
||||
|
||||
void onPingPeerResult(boolean success);
|
||||
}
|
@ -35,7 +35,8 @@ public class Settings implements Serializable {
|
||||
private List<Country> acceptedCountryLocales = new ArrayList<>();
|
||||
private List<Arbitrator> acceptedArbitrators = new ArrayList<>();
|
||||
|
||||
private long collateral = 100; // is 1/1000 so 100 is a multiplier of 0,1 or 10% of the amount
|
||||
private long collateral = 100; // is 1/1000 so 100 results to 100/1000 = 0,1 (or 10%)
|
||||
// which will be used for multiplying with the amount to get the collateral size in BTC.
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -111,7 +112,6 @@ public class Settings implements Serializable {
|
||||
//TODO
|
||||
public Arbitrator getRandomArbitrator(Coin amount) {
|
||||
List<Arbitrator> candidates = new ArrayList<>();
|
||||
//noinspection Convert2streamapi
|
||||
for (Arbitrator arbitrator : acceptedArbitrators) {
|
||||
candidates.add(arbitrator);
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Simple storage solution for serialized data
|
||||
* TODO: Should be improved with a more robust solution or maybe a lightweight database.
|
||||
* TODO: Should run in a dedicated thread.
|
||||
*/
|
||||
public class Persistence {
|
||||
private static final Logger log = LoggerFactory.getLogger(Persistence.class);
|
||||
@ -191,7 +193,6 @@ public class Persistence {
|
||||
}
|
||||
else {
|
||||
if (object instanceof Map) {
|
||||
//noinspection unchecked
|
||||
return (Map<String, Serializable>) object;
|
||||
}
|
||||
else {
|
||||
|
@ -29,18 +29,18 @@ import io.bitsquare.trade.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
import io.bitsquare.trade.protocol.createoffer.CreateOfferCoordinator;
|
||||
import io.bitsquare.trade.protocol.offerer.BankTransferInitedMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.ProtocolForOffererAsBuyer;
|
||||
import io.bitsquare.trade.protocol.offerer.ProtocolForOffererAsBuyerListener;
|
||||
import io.bitsquare.trade.protocol.offerer.RequestTakerDepositPaymentMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.RespondToTakeOfferRequestMessage;
|
||||
import io.bitsquare.trade.protocol.taker.PayoutTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.taker.ProtocolForTakerAsSeller;
|
||||
import io.bitsquare.trade.protocol.taker.ProtocolForTakerAsSellerListener;
|
||||
import io.bitsquare.trade.protocol.taker.RequestOffererPublishDepositTxMessage;
|
||||
import io.bitsquare.trade.protocol.taker.RequestTakeOfferMessage;
|
||||
import io.bitsquare.trade.protocol.taker.TakeOfferFeePayedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocol;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.RequestTakerDepositPaymentMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.RespondToTakeOfferRequestMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.SellerTakesOfferProtocol;
|
||||
import io.bitsquare.trade.protocol.trade.taker.SellerTakesOfferProtocolListener;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.PayoutTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.RequestOffererPublishDepositTxMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.RequestTakeOfferMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.TakeOfferFeePayedMessage;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
@ -81,8 +81,8 @@ public class TradeManager {
|
||||
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
|
||||
|
||||
//TODO store TakerAsSellerProtocol in trade
|
||||
private final Map<String, ProtocolForTakerAsSeller> takerAsSellerProtocolMap = new HashMap<>();
|
||||
private final Map<String, ProtocolForOffererAsBuyer> offererAsBuyerProtocolMap = new HashMap<>();
|
||||
private final Map<String, SellerTakesOfferProtocol> takerAsSellerProtocolMap = new HashMap<>();
|
||||
private final Map<String, BuyerAcceptsOfferProtocol> offererAsBuyerProtocolMap = new HashMap<>();
|
||||
private final Map<String, CreateOfferCoordinator> createOfferCoordinatorMap = new HashMap<>();
|
||||
|
||||
private final StringProperty newTradeProperty = new SimpleStringProperty();
|
||||
@ -227,14 +227,14 @@ public class TradeManager {
|
||||
messageFacade.removeOffer(offer);
|
||||
}
|
||||
|
||||
public Trade takeOffer(Coin amount, Offer offer, ProtocolForTakerAsSellerListener listener) {
|
||||
public Trade takeOffer(Coin amount, Offer offer, SellerTakesOfferProtocolListener listener) {
|
||||
Trade trade = createTrade(offer);
|
||||
trade.setTradeAmount(amount);
|
||||
|
||||
ProtocolForTakerAsSeller protocolForTakerAsSeller = new ProtocolForTakerAsSeller(
|
||||
SellerTakesOfferProtocol sellerTakesOfferProtocol = new SellerTakesOfferProtocol(
|
||||
trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user);
|
||||
takerAsSellerProtocolMap.put(trade.getId(), protocolForTakerAsSeller);
|
||||
protocolForTakerAsSeller.start();
|
||||
takerAsSellerProtocolMap.put(trade.getId(), sellerTakesOfferProtocol);
|
||||
sellerTakesOfferProtocol.start();
|
||||
|
||||
return trade;
|
||||
}
|
||||
@ -284,14 +284,14 @@ public class TradeManager {
|
||||
Trade trade = createTrade(offer);
|
||||
pendingTrade = trade;
|
||||
|
||||
ProtocolForOffererAsBuyer protocolForOffererAsBuyer = new ProtocolForOffererAsBuyer(trade,
|
||||
BuyerAcceptsOfferProtocol buyerAcceptsOfferProtocol = new BuyerAcceptsOfferProtocol(trade,
|
||||
sender,
|
||||
messageFacade,
|
||||
walletFacade,
|
||||
blockChainFacade,
|
||||
cryptoFacade,
|
||||
user,
|
||||
new ProtocolForOffererAsBuyerListener() {
|
||||
new BuyerAcceptsOfferProtocolListener() {
|
||||
@Override
|
||||
public void onOfferAccepted(Offer offer) {
|
||||
removeOffer(offer);
|
||||
@ -317,7 +317,7 @@ public class TradeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(Throwable throwable, ProtocolForOffererAsBuyer.State state) {
|
||||
public void onFault(Throwable throwable, BuyerAcceptsOfferProtocol.State state) {
|
||||
log.error("Error while executing trade process at state: " + state + " / " + throwable);
|
||||
Popups.openErrorPopup("Error while executing trade process",
|
||||
"Error while executing trade process at state: " + state + " / " +
|
||||
@ -325,17 +325,17 @@ public class TradeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWaitingForPeerResponse(ProtocolForOffererAsBuyer.State state) {
|
||||
public void onWaitingForPeerResponse(BuyerAcceptsOfferProtocol.State state) {
|
||||
log.debug("Waiting for peers response at state " + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(ProtocolForOffererAsBuyer.State state) {
|
||||
public void onCompleted(BuyerAcceptsOfferProtocol.State state) {
|
||||
log.debug("Trade protocol completed at state " + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWaitingForUserInteraction(ProtocolForOffererAsBuyer.State state) {
|
||||
public void onWaitingForUserInteraction(BuyerAcceptsOfferProtocol.State state) {
|
||||
log.debug("Waiting for UI activity at state " + state);
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ public class TradeManager {
|
||||
});
|
||||
|
||||
if (!offererAsBuyerProtocolMap.containsKey(trade.getId())) {
|
||||
offererAsBuyerProtocolMap.put(trade.getId(), protocolForOffererAsBuyer);
|
||||
offererAsBuyerProtocolMap.put(trade.getId(), buyerAcceptsOfferProtocol);
|
||||
}
|
||||
else {
|
||||
// We don't store the protocol in case we have already a pending offer. The protocol is only
|
||||
@ -356,7 +356,7 @@ public class TradeManager {
|
||||
log.trace("offererAsBuyerProtocol not stored as offer is already pending.");
|
||||
}
|
||||
|
||||
protocolForOffererAsBuyer.start();
|
||||
buyerAcceptsOfferProtocol.start();
|
||||
}
|
||||
else {
|
||||
log.warn("Incoming offer take request does not match with any saved offer. We ignore that request.");
|
||||
|
@ -55,6 +55,7 @@ remove dependencies to tomp2p
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
*/
|
||||
|
||||
public class OrderBook implements OrderBookListener {
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderBook.class);
|
||||
private final ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
|
||||
@ -148,8 +149,6 @@ public class OrderBook implements OrderBookListener {
|
||||
// (1 to n)
|
||||
boolean arbitratorResult = arbitratorInList(offer.getArbitrator(), settings.getAcceptedArbitrators());
|
||||
|
||||
|
||||
//noinspection UnnecessaryLocalVariable
|
||||
boolean result = currencyResult && countryResult && languageResult && amountResult && directionResult &&
|
||||
priceResult && arbitratorResult;
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.google.bitcoin.core.Coin;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
public class OrderBookFilter {
|
||||
// TODO use ObjectProperty<Direction> instead
|
||||
private final SimpleBooleanProperty directionChangedProperty = new SimpleBooleanProperty();
|
||||
|
||||
private double price;
|
||||
@ -65,10 +66,7 @@ public class OrderBookFilter {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
|
||||
public SimpleBooleanProperty getDirectionChangedProperty() {
|
||||
return directionChangedProperty;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,53 +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.protocol.old;
|
||||
|
||||
//TODO not used but let it for reference until all use cases are impl.
|
||||
class BuyOffererPaymentProcess extends PaymentProcess {
|
||||
public BuyOffererPaymentProcess() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
// case 1 offerer step 1
|
||||
private void buyOfferOfferer_payToDeposit() {
|
||||
onDataDepositTx();
|
||||
payCollateral();
|
||||
signDepositTx();
|
||||
publishDepositTx();
|
||||
sendMessageDepositTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
}
|
||||
|
||||
// case 1 offerer step 2
|
||||
private void buyOfferOfferer_payToDeposist() {
|
||||
payFiat();
|
||||
sendMessageFiatTxInited();
|
||||
createPayoutTx();
|
||||
signPayoutTx();
|
||||
sendDataPayoutTx();
|
||||
onBlockChainConfirmation();
|
||||
}
|
||||
|
||||
// case 1 offerer step 3
|
||||
private void buyOfferOfferer_waitForRelease() {
|
||||
onMessagePayoutTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
done();
|
||||
}
|
||||
}
|
@ -1,52 +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.protocol.old;
|
||||
|
||||
//TODO not used but let it for reference until all use cases are impl.
|
||||
public class BuyTakerPaymentProcess extends PaymentProcess {
|
||||
|
||||
public BuyTakerPaymentProcess() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStep0() {
|
||||
// bitcoinServices.createMultiSig();
|
||||
createDepositTx();
|
||||
payPaymentAndCollateral();
|
||||
signDepositTx();
|
||||
sendDataDepositTx();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStep1() {
|
||||
onMessageDepositTxPublished();
|
||||
onMessageFiatTxInited();
|
||||
onUserInputFiatReceived();
|
||||
onDataPayoutTx();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStep2() {
|
||||
signPayoutTx();
|
||||
publishPayoutTx();
|
||||
sendMessagePayoutTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
done();
|
||||
}
|
||||
}
|
@ -1,224 +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.protocol.old;
|
||||
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//TODO not used but let it for reference until all use cases are impl.
|
||||
public class PaymentProcess {
|
||||
private static final Logger log = LoggerFactory.getLogger(PaymentProcess.class);
|
||||
protected String offererDepositPubKey;
|
||||
protected String offererPayoutAddress;
|
||||
protected String offererChangeAddress;
|
||||
protected String offererTotalInputPayment;
|
||||
protected String offererOutputPayment;
|
||||
protected String takerDepositPubKey;
|
||||
protected String takerPayoutAddress;
|
||||
protected String takerChangeAddress;
|
||||
protected String takerTotalInputPayment;
|
||||
protected String takerOutputPayment;
|
||||
protected String multiSigAddress;
|
||||
|
||||
public PaymentProcess() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setMessageService(MessageFacade messageService) {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setWallet(WalletFacade wallet) {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setBtcServices(BlockChainFacade bitcoinServices) {
|
||||
}
|
||||
|
||||
|
||||
public void executeStep0() {
|
||||
}
|
||||
|
||||
public void executeStep1() {
|
||||
}
|
||||
|
||||
public void executeStep2() {
|
||||
}
|
||||
|
||||
public void executeStep3() {
|
||||
}
|
||||
|
||||
|
||||
protected void createDepositTx() {
|
||||
//wallet.getInputs(offererTotalInputPayment);
|
||||
//bitcoinServices.createTx(taker);
|
||||
}
|
||||
|
||||
protected void payPaymentAndCollateral() {
|
||||
}
|
||||
|
||||
protected void signDepositTx() {
|
||||
}
|
||||
|
||||
protected void sendDataDepositTx() {
|
||||
}
|
||||
|
||||
protected void onMessageFiatTxInited() {
|
||||
}
|
||||
|
||||
protected void onUserInputFiatReceived() {
|
||||
}
|
||||
|
||||
protected void onDataPayoutTx() {
|
||||
}
|
||||
|
||||
protected void onMessageDepositTxPublished() {
|
||||
}
|
||||
|
||||
protected void signPayoutTx() {
|
||||
}
|
||||
|
||||
protected void publishPayoutTx() {
|
||||
}
|
||||
|
||||
protected void sendMessagePayoutTxPublished() {
|
||||
}
|
||||
|
||||
protected void onBlockChainConfirmation() {
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
}
|
||||
|
||||
protected void onDataDepositTx() {
|
||||
}
|
||||
|
||||
protected void payCollateral() {
|
||||
}
|
||||
|
||||
protected void publishDepositTx() {
|
||||
}
|
||||
|
||||
protected void sendMessageDepositTxPublished() {
|
||||
}
|
||||
|
||||
protected void payFiat() {
|
||||
}
|
||||
|
||||
protected void sendMessageFiatTxInited() {
|
||||
}
|
||||
|
||||
protected void createPayoutTx() {
|
||||
}
|
||||
|
||||
protected void sendDataPayoutTx() {
|
||||
}
|
||||
|
||||
protected void onMessagePayoutTxPublished() {
|
||||
}
|
||||
|
||||
/*
|
||||
case 1:
|
||||
BUY offer
|
||||
taker:
|
||||
1 PAY BTC
|
||||
create ms
|
||||
create deposit tx
|
||||
pay payment+coll
|
||||
signContract
|
||||
send deposit tx to offerer
|
||||
2 WAIT FOR FIAT
|
||||
wait for pub tx info msg
|
||||
wait for build fiat info msg
|
||||
wait for fiat on bank
|
||||
wait for payout tx
|
||||
3 RELEASE BTC
|
||||
signContract payout tx
|
||||
pub payout tx
|
||||
send info to offerer
|
||||
wait for >= 1 confirm
|
||||
DONE
|
||||
offerer:
|
||||
1 WAIT FOR BTC PAYMENT
|
||||
wait for deposit tx
|
||||
pay coll
|
||||
signContract
|
||||
pub deposit tx
|
||||
send info msg to taker
|
||||
wait for >=1 confirm
|
||||
2 PAY FIAT
|
||||
build fiat
|
||||
send info msg to taker
|
||||
create payout tx
|
||||
signContract payout tx
|
||||
send payout tx to taker
|
||||
3 WAIT FOR BTC RELEASE
|
||||
wait for release info msg
|
||||
wait for >= 1 confirm
|
||||
DONE
|
||||
|
||||
case 2:
|
||||
SELL offer
|
||||
taker:
|
||||
1 PAY COLL
|
||||
create ms
|
||||
create deposit tx
|
||||
pay coll
|
||||
signContract
|
||||
send deposit tx to offerer
|
||||
2 WAIT FOR BTC PAYMENT
|
||||
wait for pub tx info msg
|
||||
wait for >=1 confirm
|
||||
3 PAY FIAT -> Same
|
||||
build fiat
|
||||
send info msg to taker
|
||||
create payout tx
|
||||
signContract payout tx
|
||||
send payout tx to offerer
|
||||
4 WAIT FOR BTC RELEASE -> Same
|
||||
wait for release info msg
|
||||
wait for >= 1 confirm
|
||||
DONE
|
||||
offerer:
|
||||
1 WAIT FOR COLL
|
||||
wait for deposit tx
|
||||
2 PAY BTC
|
||||
pay coll+payment
|
||||
signContract
|
||||
pub deposit tx
|
||||
send info msg to taker
|
||||
3 WAIT FOR FIAT
|
||||
wait for build fiat info msg
|
||||
wait for payout tx
|
||||
wait for fiat on bank
|
||||
4 RELEASE BTC
|
||||
signContract payout tx
|
||||
pub payout tx
|
||||
send info to taker
|
||||
wait for >= 1 confirm
|
||||
DONE
|
||||
|
||||
|
||||
*/
|
||||
}
|
@ -1,56 +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.protocol.old;
|
||||
|
||||
//TODO not used but let it for reference until all use cases are impl.
|
||||
class SellOffererPaymentProcess extends PaymentProcess {
|
||||
public SellOffererPaymentProcess() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
// case 2 offerer step 1
|
||||
private void sellOfferOfferer_waitForCollateralPayedByPeer() {
|
||||
onDataDepositTx();
|
||||
}
|
||||
|
||||
// case 2 offerer step 2
|
||||
private void sellOfferOfferer_payToDeposit() {
|
||||
payPaymentAndCollateral();
|
||||
signDepositTx();
|
||||
publishDepositTx();
|
||||
sendMessageDepositTxPublished();
|
||||
}
|
||||
|
||||
// case 2 offerer step 3
|
||||
private void sellOfferOfferer_waitForFiat() {
|
||||
onMessageFiatTxInited();
|
||||
onDataPayoutTx();
|
||||
onUserInputFiatReceived();
|
||||
}
|
||||
|
||||
// case 2 offerer step 4
|
||||
private void sellOfferOfferer_releasePayment() {
|
||||
signPayoutTx();
|
||||
publishPayoutTx();
|
||||
sendMessagePayoutTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
done();
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +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.protocol.old;
|
||||
|
||||
//TODO not used but let it for reference until all use cases are impl.
|
||||
class SellTakerPaymentProcess extends PaymentProcess {
|
||||
public SellTakerPaymentProcess() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
// case 2 taker step 1
|
||||
private void sellOfferTaker_payToDeposit() {
|
||||
//createMultiSig();
|
||||
createDepositTx();
|
||||
payCollateral();
|
||||
signDepositTx();
|
||||
sendDataDepositTx();
|
||||
}
|
||||
|
||||
// case 2 taker step 2
|
||||
private void sellOfferTaker_waitForDepositPublished() {
|
||||
onMessageDepositTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
}
|
||||
|
||||
// case 2 taker step 3
|
||||
private void sellOfferTaker_payFiat() {
|
||||
payFiat();
|
||||
sendMessageFiatTxInited();
|
||||
createPayoutTx();
|
||||
signPayoutTx();
|
||||
sendDataPayoutTx();
|
||||
}
|
||||
|
||||
// case 2 taker step 4
|
||||
private void sellOfferTaker_waitForRelease() {
|
||||
onMessagePayoutTxPublished();
|
||||
onBlockChainConfirmation();
|
||||
done();
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
@ -26,9 +26,19 @@ import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.taker.PayoutTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.taker.RequestOffererPublishDepositTxMessage;
|
||||
import io.bitsquare.trade.protocol.taker.TakeOfferFeePayedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.CreateDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.HandleTakeOfferRequest;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.RequestTakerDepositPayment;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.SendDepositTxIdToTaker;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.tasks.SendSignedPayoutTx;
|
||||
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.VerifyAndSignContract;
|
||||
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.messages.PayoutTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.RequestOffererPublishDepositTxMessage;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.TakeOfferFeePayedMessage;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
@ -56,9 +66,9 @@ import static io.bitsquare.util.Validator.*;
|
||||
* It uses sub tasks to not pollute the main class too much with all the async result/fault handling.
|
||||
* Any data from incoming messages need to be validated before further processing.
|
||||
*/
|
||||
public class ProtocolForOffererAsBuyer {
|
||||
public class BuyerAcceptsOfferProtocol {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProtocolForOffererAsBuyer.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(BuyerAcceptsOfferProtocol.class);
|
||||
|
||||
public enum State {
|
||||
Init,
|
||||
@ -90,7 +100,7 @@ public class ProtocolForOffererAsBuyer {
|
||||
private final WalletFacade walletFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
private final ProtocolForOffererAsBuyerListener listener;
|
||||
private final BuyerAcceptsOfferProtocolListener listener;
|
||||
|
||||
// derived
|
||||
private final String tradeId;
|
||||
@ -127,14 +137,14 @@ public class ProtocolForOffererAsBuyer {
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public ProtocolForOffererAsBuyer(Trade trade,
|
||||
public BuyerAcceptsOfferProtocol(Trade trade,
|
||||
PeerAddress peerAddress,
|
||||
MessageFacade messageFacade,
|
||||
WalletFacade walletFacade,
|
||||
BlockChainFacade blockChainFacade,
|
||||
CryptoFacade cryptoFacade,
|
||||
User user,
|
||||
ProtocolForOffererAsBuyerListener listener) {
|
||||
BuyerAcceptsOfferProtocolListener listener) {
|
||||
this.trade = trade;
|
||||
this.peerAddress = peerAddress;
|
||||
this.listener = listener;
|
@ -15,13 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
|
||||
public interface ProtocolForOffererAsBuyerListener {
|
||||
public interface BuyerAcceptsOfferProtocolListener {
|
||||
void onOfferAccepted(Offer offer);
|
||||
|
||||
void onDepositTxPublished(String depositTxID);
|
||||
@ -32,11 +32,11 @@ public interface ProtocolForOffererAsBuyerListener {
|
||||
|
||||
void onPayoutTxPublished(String payoutTxID);
|
||||
|
||||
void onFault(Throwable throwable, ProtocolForOffererAsBuyer.State state);
|
||||
void onFault(Throwable throwable, BuyerAcceptsOfferProtocol.State state);
|
||||
|
||||
void onWaitingForPeerResponse(ProtocolForOffererAsBuyer.State state);
|
||||
void onWaitingForPeerResponse(BuyerAcceptsOfferProtocol.State state);
|
||||
|
||||
void onCompleted(ProtocolForOffererAsBuyer.State state);
|
||||
void onCompleted(BuyerAcceptsOfferProtocol.State state);
|
||||
|
||||
void onWaitingForUserInteraction(ProtocolForOffererAsBuyer.State state);
|
||||
void onWaitingForUserInteraction(BuyerAcceptsOfferProtocol.State state);
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.messages;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,12 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.RespondToTakeOfferRequestMessage;
|
||||
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
@ -15,13 +15,14 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.RequestTakerDepositPaymentMessage;
|
||||
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
@ -15,12 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.Utils;
|
@ -15,13 +15,14 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
import com.google.bitcoin.core.ECKey;
|
@ -15,10 +15,11 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.BuyerAcceptsOfferProtocolListener;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
@ -30,7 +31,7 @@ public class SetupListenerForBlockChainConfirmation {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetupListenerForBlockChainConfirmation.class);
|
||||
|
||||
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler,
|
||||
Transaction depositTransaction, ProtocolForOffererAsBuyerListener listener) {
|
||||
Transaction depositTransaction, BuyerAcceptsOfferProtocolListener listener) {
|
||||
log.trace("Run task");
|
||||
//TODO
|
||||
// sharedModel.offererPaymentProtocolListener.onDepositTxConfirmedInBlockchain();
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,13 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.offerer;
|
||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.shared.VerifyPeerAccount;
|
||||
import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.shared;
|
||||
package io.bitsquare.trade.protocol.trade.shared.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
@ -25,10 +25,20 @@ import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.offerer.BankTransferInitedMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.RequestTakerDepositPaymentMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.RespondToTakeOfferRequestMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.messages.RequestTakerDepositPaymentMessage;
|
||||
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.PayDeposit;
|
||||
import io.bitsquare.trade.protocol.trade.taker.tasks.PayTakeOfferFee;
|
||||
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.SendSignedTakerDepositTxAsHex;
|
||||
import io.bitsquare.trade.protocol.trade.taker.tasks.SendTakeOfferFeePayedTxId;
|
||||
import io.bitsquare.trade.protocol.trade.taker.tasks.SignAndPublishPayoutTx;
|
||||
import io.bitsquare.trade.protocol.trade.taker.tasks.VerifyOffererAccount;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
@ -52,8 +62,8 @@ import static io.bitsquare.util.Validator.*;
|
||||
* It uses sub tasks to not pollute the main class too much with all the async result/fault handling.
|
||||
* Any data from incoming messages as well data used to send to the peer need to be validated before further processing.
|
||||
*/
|
||||
public class ProtocolForTakerAsSeller {
|
||||
private static final Logger log = LoggerFactory.getLogger(ProtocolForTakerAsSeller.class);
|
||||
public class SellerTakesOfferProtocol {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerTakesOfferProtocol.class);
|
||||
|
||||
|
||||
public enum State {
|
||||
@ -76,7 +86,7 @@ public class ProtocolForTakerAsSeller {
|
||||
|
||||
// provided data
|
||||
private final Trade trade;
|
||||
private final ProtocolForTakerAsSellerListener listener;
|
||||
private final SellerTakesOfferProtocolListener listener;
|
||||
private final MessageFacade messageFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
@ -122,8 +132,8 @@ public class ProtocolForTakerAsSeller {
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public ProtocolForTakerAsSeller(Trade trade,
|
||||
ProtocolForTakerAsSellerListener listener,
|
||||
public SellerTakesOfferProtocol(Trade trade,
|
||||
SellerTakesOfferProtocolListener listener,
|
||||
MessageFacade messageFacade,
|
||||
WalletFacade walletFacade,
|
||||
BlockChainFacade blockChainFacade,
|
@ -15,22 +15,22 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker;
|
||||
|
||||
import io.bitsquare.trade.Trade;
|
||||
|
||||
public interface ProtocolForTakerAsSellerListener {
|
||||
public interface SellerTakesOfferProtocolListener {
|
||||
void onDepositTxPublished(String depositTxId);
|
||||
|
||||
void onBankTransferInited(String tradeId);
|
||||
|
||||
void onPayoutTxPublished(Trade trade, String hashAsString);
|
||||
|
||||
void onFault(Throwable throwable, ProtocolForTakerAsSeller.State state);
|
||||
void onFault(Throwable throwable, SellerTakesOfferProtocol.State state);
|
||||
|
||||
void onWaitingForPeerResponse(ProtocolForTakerAsSeller.State state);
|
||||
void onWaitingForPeerResponse(SellerTakesOfferProtocol.State state);
|
||||
|
||||
void onCompleted(ProtocolForTakerAsSeller.State state);
|
||||
void onCompleted(SellerTakesOfferProtocol.State state);
|
||||
|
||||
void onTakeOfferRequestRejected(Trade trade);
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.messages;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.messages;
|
||||
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.GetPeerAddressListener;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,12 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.RequestTakeOfferMessage;
|
||||
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
@ -15,12 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.PayoutTxPublishedMessage;
|
||||
|
||||
import net.tomp2p.peers.PeerAddress;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
@ -23,6 +23,7 @@ import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.RequestOffererPublishDepositTxMessage;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
import com.google.bitcoin.core.Utils;
|
@ -15,12 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.OutgoingTradeMessageListener;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.trade.taker.messages.TakeOfferFeePayedMessage;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
@ -15,13 +15,13 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.taker;
|
||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.trade.handlers.ExceptionHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import io.bitsquare.trade.protocol.shared.VerifyPeerAccount;
|
||||
import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
@ -28,7 +28,6 @@ public class BtcValidatorTest {
|
||||
@Test
|
||||
public void testIsMinSpendableAmount() {
|
||||
Coin amount = null;
|
||||
//noinspection ConstantConditions
|
||||
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
|
||||
|
||||
amount = Coin.ZERO;
|
||||
|
Loading…
x
Reference in New Issue
Block a user