Unified Seller tasks

This commit is contained in:
Manfred Karrer 2015-04-02 16:32:32 +02:00
parent 06c06b1244
commit a71853140a
42 changed files with 178 additions and 551 deletions

View File

@ -28,27 +28,25 @@ import io.bitsquare.trade.protocol.placeoffer.tasks.AddOfferToRemoteOfferBook;
import io.bitsquare.trade.protocol.placeoffer.tasks.BroadcastCreateOfferFeeTx;
import io.bitsquare.trade.protocol.placeoffer.tasks.CreateOfferFeeTx;
import io.bitsquare.trade.protocol.placeoffer.tasks.ValidateOffer;
import io.bitsquare.trade.protocol.trade.buyer.offerer.BuyerAsOffererProtocol;
import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.BuyerAsOffererProtocol;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSignsAndPublishDepositTx;
import io.bitsquare.trade.protocol.trade.seller.taker.SellerAsTakerProtocol;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignContract;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.ProcessRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.seller.SellerAsTakerProtocol;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SendRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakeOfferFeePayment;
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakerAccount;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
@ -100,11 +98,11 @@ public class DebugView extends InitializableView {
/*---- Protocol ----*/
BuyerAsOffererProtocol.class,
OffererProcessRequestDepositTxInputsMessage.class,
ProcessRequestDepositTxInputsMessage.class,
BuyerCreatesDepositTxInputs.class,
BuyerSendsRequestPayDepositMessage.class,
OffererProcessRequestPublishDepositTxMessage.class,
BuyerProcessRequestPublishDepositTxMessage.class,
VerifyTakerAccount.class,
BuyerSignsAndPublishDepositTx.class,
BuyerSendsDepositTxPublishedMessage.class,
@ -120,22 +118,20 @@ public class DebugView extends InitializableView {
/*---- Protocol ----*/
SellerAsTakerProtocol.class,
CreateTakeOfferFeeTx.class,
TakerSendsRequestDepositTxInputsMessage.class,
SendRequestDepositTxInputsMessage.class,
TakerProcessRequestPayDepositMessage.class,
SellerProcessRequestPayDepositMessage.class,
VerifyOffererAccount.class,
TakerCreatesAndSignContract.class,
TakerCreatesAndSignsDepositTx.class,
TakerSendsRequestPublishDepositTxMessage.class,
SellerCreatesAndSignsDepositTx.class,
TakerProcessDepositTxPublishedMessage.class,
TakerCommitDepositTx.class,
SellerProcessDepositTxPublishedMessage.class,
SellerCommitDepositTx.class,
TakerProcessFiatTransferStartedMessage.class,
SellerProcessFiatTransferStartedMessage.class,
TakerSignsAndPublishPayoutTx.class,
SellerSignsAndPublishPayoutTx.class,
VerifyOfferFeePayment.class,
TakerSendsPayoutTxPublishedMessage.class
SellerSendsPayoutTxPublishedMessage.class
)
);

View File

@ -64,7 +64,7 @@ class ClosedTradesDataModel implements Activatable, DataModel {
}
public Offer.Direction getDirection(Offer offer) {
return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ?
return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ?
offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -75,7 +75,7 @@ class OffersDataModel implements Activatable, DataModel {
}
public Offer.Direction getDirection(Offer offer) {
return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ?
return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ?
offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -135,7 +135,7 @@ class PendingTradesDataModel implements Activatable, DataModel {
currentTrade.set(item.getTrade());
Trade trade = item.getTrade();
isOfferer = trade.getOffer().getP2PSigPubKey().equals(user.getP2PSigPubKey());
isOfferer = trade.getOffer().getP2pSigPubKey().equals(user.getP2pSigPubKey());
if (trade instanceof SellerAsTakerTrade)
takerAsSellerProcessState.bind(trade.processStateProperty());
else if (trade instanceof BuyerAsOffererTrade)
@ -248,7 +248,7 @@ class PendingTradesDataModel implements Activatable, DataModel {
}
public Offer.Direction getDirection(Offer offer) {
return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ?
return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ?
offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -211,7 +211,7 @@ class OfferBookDataModel implements Activatable, DataModel {
}
boolean isMyOffer(Offer offer) {
return offer.getP2PSigPubKey() != null && offer.getP2PSigPubKey().equals(user.getP2PSigPubKey());
return offer.getP2pSigPubKey() != null && offer.getP2pSigPubKey().equals(user.getP2pSigPubKey());
}
Coin getAmountAsCoin() {

View File

@ -144,7 +144,7 @@ public class Offer implements Serializable {
checkNotNull(getCurrencyCode(), "Currency is null");
checkNotNull(getDirection(), "Direction is null");
checkNotNull(getId(), "Id is null");
checkNotNull(getP2PSigPubKey(), "p2pSigPubKey is null");
checkNotNull(getP2pSigPubKey(), "p2pSigPubKey is null");
checkNotNull(getMinAmount(), "MinAmount is null");
checkNotNull(getPrice(), "Price is null");
@ -255,7 +255,7 @@ public class Offer implements Serializable {
return bankAccountUID;
}
public PublicKey getP2PSigPubKey() {
public PublicKey getP2pSigPubKey() {
return p2pSigPubKey;
}

View File

@ -19,7 +19,7 @@ package io.bitsquare.trade;
import io.bitsquare.offer.Offer;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.protocol.trade.buyer.offerer.BuyerAsOffererProtocol;
import io.bitsquare.trade.protocol.trade.buyer.BuyerAsOffererProtocol;
import io.bitsquare.trade.states.OffererState;
import io.bitsquare.trade.states.TradeState;

View File

@ -20,7 +20,7 @@ package io.bitsquare.trade;
import io.bitsquare.offer.Offer;
import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.protocol.trade.buyer.taker.BuyerAsTakerProtocol;
import io.bitsquare.trade.protocol.trade.buyer.BuyerAsTakerProtocol;
import io.bitsquare.trade.states.TakerState;
import io.bitsquare.trade.states.TradeState;

View File

@ -42,8 +42,8 @@ public class Contract implements Serializable {
public final String sellerAccountID;
public final FiatAccount buyerFiatAccount;
public final FiatAccount sellerFiatAccount;
public final String buyerP2PSigPubKeyAsString;
public final String sellerP2PSigPubKeyAsString;
public final String buyerP2pSigPubKeyAsString;
public final String sellerP2pSigPubKeyAsString;
public Contract(Offer offer,
Coin tradeAmount,
@ -52,8 +52,8 @@ public class Contract implements Serializable {
String sellerAccountID,
FiatAccount buyerFiatAccount,
FiatAccount sellerFiatAccount,
PublicKey buyerP2PSigPubKey,
PublicKey sellerP2PSigPubKey) {
PublicKey buyerP2pSigPubKey,
PublicKey sellerP2pSigPubKey) {
this.offer = offer;
this.tradeAmount = tradeAmount;
this.takeOfferFeeTxID = takeOfferFeeTxID;
@ -61,8 +61,8 @@ public class Contract implements Serializable {
this.sellerAccountID = sellerAccountID;
this.buyerFiatAccount = buyerFiatAccount;
this.sellerFiatAccount = sellerFiatAccount;
this.buyerP2PSigPubKeyAsString = Utilities.getHexFromPubKey(buyerP2PSigPubKey);
this.sellerP2PSigPubKeyAsString = Utilities.getHexFromPubKey(sellerP2PSigPubKey);
this.buyerP2pSigPubKeyAsString = Utilities.getHexFromPubKey(buyerP2pSigPubKey);
this.sellerP2pSigPubKeyAsString = Utilities.getHexFromPubKey(sellerP2pSigPubKey);
}
@Override
@ -75,8 +75,8 @@ public class Contract implements Serializable {
", sellerAccountID='" + sellerAccountID + '\'' +
", buyerFiatAccount=" + buyerFiatAccount +
", sellerFiatAccount=" + sellerFiatAccount +
", buyerP2PSigPubKeyAsString='" + buyerP2PSigPubKeyAsString + '\'' +
", sellerP2PSigPubKeyAsString='" + sellerP2PSigPubKeyAsString + '\'' +
", buyerP2pSigPubKeyAsString='" + buyerP2pSigPubKeyAsString + '\'' +
", sellerP2pSigPubKeyAsString='" + sellerP2pSigPubKeyAsString + '\'' +
'}';
}
}

View File

@ -19,7 +19,7 @@ package io.bitsquare.trade;
import io.bitsquare.offer.Offer;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.protocol.trade.seller.offerer.SellerAsOffererProtocol;
import io.bitsquare.trade.protocol.trade.seller.SellerAsOffererProtocol;
import io.bitsquare.trade.states.OffererState;
import io.bitsquare.trade.states.TradeState;

View File

@ -20,7 +20,7 @@ package io.bitsquare.trade;
import io.bitsquare.offer.Offer;
import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.protocol.trade.seller.taker.SellerAsTakerProtocol;
import io.bitsquare.trade.protocol.trade.seller.SellerAsTakerProtocol;
import io.bitsquare.trade.states.TakerState;
import io.bitsquare.trade.states.TradeState;

View File

@ -190,7 +190,7 @@ public class TradeManager {
}
// if there are messages in our mailbox we apply it and remove them from the DHT
mailboxService.getAllMessages(user.getP2PSigPubKey(),
mailboxService.getAllMessages(user.getP2pSigPubKey(),
(encryptedMailboxMessages) -> {
setMailboxMessagesToTrades(encryptedMailboxMessages);
emptyMailbox();
@ -217,7 +217,7 @@ public class TradeManager {
}
private void emptyMailbox() {
mailboxService.removeAllMessages(user.getP2PSigPubKey(),
mailboxService.removeAllMessages(user.getP2pSigPubKey(),
() -> log.debug("All mailbox entries removed"),
(errorMessage, fault) -> {
log.error(errorMessage);
@ -252,7 +252,7 @@ public class TradeManager {
FiatAccount fiatAccount = user.currentFiatAccountProperty().get();
Offer offer = new Offer(id,
user.getP2PSigPubKey(),
user.getP2pSigPubKey(),
direction,
price.getValue(),
amount,

View File

@ -39,7 +39,7 @@ public class GetPeerAddress extends Task<CheckOfferAvailabilityModel> {
@Override
protected void doRun() {
try {
model.addressService.findPeerAddress(model.offer.getP2PSigPubKey(), new GetPeerAddressListener() {
model.addressService.findPeerAddress(model.offer.getP2pSigPubKey(), new GetPeerAddressListener() {
@Override
public void onResult(Peer peer) {
model.setPeer(peer);

View File

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.tasks;
package io.bitsquare.trade.protocol.trade;
import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.BuyerAsTakerTrade;

View File

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.offerer;
package io.bitsquare.trade.protocol.trade.buyer;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.MailboxMessage;
@ -27,17 +27,17 @@ import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.protocol.availability.messages.ReportOfferAvailabilityMessage;
import io.bitsquare.trade.protocol.availability.messages.RequestIsOfferAvailableMessage;
import io.bitsquare.trade.protocol.trade.TradeProtocol;
import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCommitsPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSignsAndPublishDepositTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerVerifiesAndSignsContract;
import io.bitsquare.trade.protocol.trade.buyer.tasks.ProcessRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage;
@ -143,7 +143,7 @@ public class BuyerAsOffererProtocol implements TradeProtocol {
() -> log.debug("taskRunner at handleRequestDepositTxInputsMessage completed"),
this::handleTaskRunnerFault);
taskRunner.addTasks(
OffererProcessRequestDepositTxInputsMessage.class,
ProcessRequestDepositTxInputsMessage.class,
BuyerCreatesDepositTxInputs.class,
BuyerSendsRequestPayDepositMessage.class
);
@ -157,7 +157,7 @@ public class BuyerAsOffererProtocol implements TradeProtocol {
() -> log.debug("taskRunner at handleRequestPublishDepositTxMessage completed"),
this::handleTaskRunnerFault);
taskRunner.addTasks(
OffererProcessRequestPublishDepositTxMessage.class,
BuyerProcessRequestPublishDepositTxMessage.class,
VerifyTakerAccount.class,
BuyerVerifiesAndSignsContract.class,
BuyerSignsAndPublishDepositTx.class,

View File

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.taker;
package io.bitsquare.trade.protocol.trade.buyer;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.MailboxMessage;
@ -24,11 +24,11 @@ import io.bitsquare.p2p.MessageHandler;
import io.bitsquare.p2p.Peer;
import io.bitsquare.trade.BuyerAsTakerTrade;
import io.bitsquare.trade.protocol.trade.TradeProtocol;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerProcessRequestPublishDepositTxFromSellerMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCommitsPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage;
@ -119,7 +119,7 @@ public class BuyerAsTakerProtocol implements TradeProtocol {
() -> log.debug("taskRunner at handleRequestPublishDepositTxMessage completed"),
this::handleTaskRunnerFault);
taskRunner.addTasks(
TakerProcessRequestPublishDepositTxFromSellerMessage.class,
BuyerProcessRequestPublishDepositTxMessage.class,
VerifyOffererAccount.class,
BuyerVerifiesAndSignsContract.class,
BuyerSignsAndPublishDepositTx.class,

View File

@ -1,66 +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.trade.buyer.taker.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxFromSellerMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.*;
import static io.bitsquare.util.Validator.*;
public class TakerProcessRequestPublishDepositTxFromSellerMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(TakerProcessRequestPublishDepositTxFromSellerMessage.class);
public TakerProcessRequestPublishDepositTxFromSellerMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@Override
protected void doRun() {
try {
RequestPublishDepositTxFromSellerMessage message = (RequestPublishDepositTxFromSellerMessage) processModel.getTradeMessage();
checkTradeId(processModel.getId(), message);
checkNotNull(message);
processModel.tradingPeer.setFiatAccount(checkNotNull(message.takerFiatAccount));
processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.takerAccountId));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey));
processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey));
processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.takerP2PEncryptPublicKey));
processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.takerContractAsJson));
processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.takerContractSignature));
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.takerPayoutAddressString));
processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.takersPreparedDepositTx));
processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.takerConnectedOutputsForAllInputs));
checkArgument(message.takerConnectedOutputsForAllInputs.size() > 0);
complete();
} catch (Throwable t) {
t.printStackTrace();
trade.setThrowable(t);
failed(t);
}
}
}

View File

@ -21,6 +21,7 @@ import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import org.bitcoinj.core.Coin;

View File

@ -15,12 +15,12 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.offerer.tasks;
package io.bitsquare.trade.protocol.trade.buyer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage;
import org.slf4j.Logger;
@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.*;
import static io.bitsquare.util.Validator.*;
public class OffererProcessRequestPublishDepositTxMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(OffererProcessRequestPublishDepositTxMessage.class);
public class BuyerProcessRequestPublishDepositTxMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(BuyerProcessRequestPublishDepositTxMessage.class);
public OffererProcessRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) {
public BuyerProcessRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -43,16 +43,17 @@ public class OffererProcessRequestPublishDepositTxMessage extends TradeTask {
checkTradeId(processModel.getId(), message);
checkNotNull(message);
processModel.tradingPeer.setFiatAccount(checkNotNull(message.takerFiatAccount));
processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.takerAccountId));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey));
processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.takerP2PEncryptPublicKey));
processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.takerContractAsJson));
processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.takerContractSignature));
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.takerPayoutAddressString));
processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.takersPreparedDepositTx));
processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.takerConnectedOutputsForAllInputs));
checkArgument(message.takerConnectedOutputsForAllInputs.size() > 0);
processModel.tradingPeer.setFiatAccount(checkNotNull(message.sellerFiatAccount));
processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.sellerAccountId));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.sellerP2pSigPublicKey));
processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey));
processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.sellerP2pEncryptPublicKey));
processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.sellerContractAsJson));
processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.sellerContractSignature));
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.sellerPayoutAddressString));
processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.sellersPreparedDepositTx));
processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.sellerConnectedOutputsForAllInputs));
checkArgument(message.sellerConnectedOutputsForAllInputs.size() > 0);
complete();
} catch (Throwable t) {

View File

@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage;

View File

@ -24,6 +24,7 @@ import io.bitsquare.trade.BuyerAsTakerTrade;
import io.bitsquare.trade.SellerAsOffererTrade;
import io.bitsquare.trade.SellerAsTakerTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage;
import io.bitsquare.trade.states.OffererState;

View File

@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage;

View File

@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.Contract;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.util.Utilities;

View File

@ -15,12 +15,12 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.offerer.tasks;
package io.bitsquare.trade.protocol.trade.buyer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil;
import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage;
import org.slf4j.Logger;
@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
import static io.bitsquare.util.Validator.*;
public class OffererProcessRequestDepositTxInputsMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(OffererProcessRequestDepositTxInputsMessage.class);
public class ProcessRequestDepositTxInputsMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(ProcessRequestDepositTxInputsMessage.class);
public OffererProcessRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) {
public ProcessRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -44,8 +44,8 @@ public class OffererProcessRequestDepositTxInputsMessage extends TradeTask {
checkNotNull(message);
trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(message.tradeAmount)));
processModel.setTakeOfferFeeTxId(nonEmptyStringOf(message.takeOfferFeeTxId));
processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.takerTradeWalletPubKey));
processModel.setTakeOfferFeeTxId(nonEmptyStringOf(message.sellerOfferFeeTxId));
processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey));
complete();
} catch (Throwable t) {

View File

@ -29,13 +29,13 @@ public class RequestDepositTxInputsMessage extends TradeMessage implements Seria
private static final long serialVersionUID = 1L;
public final Coin tradeAmount;
public final String takeOfferFeeTxId;
public final byte[] takerTradeWalletPubKey;
public final String sellerOfferFeeTxId;
public final byte[] sellerTradeWalletPubKey;
public RequestDepositTxInputsMessage(String tradeId, String takeOfferFeeTxId, Coin tradeAmount, byte[] takerTradeWalletPubKey) {
public RequestDepositTxInputsMessage(String tradeId, String sellerOfferFeeTxId, Coin tradeAmount, byte[] sellerTradeWalletPubKey) {
super(tradeId);
this.takeOfferFeeTxId = takeOfferFeeTxId;
this.sellerOfferFeeTxId = sellerOfferFeeTxId;
this.tradeAmount = tradeAmount;
this.takerTradeWalletPubKey = takerTradeWalletPubKey;
this.sellerTradeWalletPubKey = sellerTradeWalletPubKey;
}
}

View File

@ -38,8 +38,8 @@ public class RequestPayDepositMessage extends TradeMessage implements Serializab
public final List<TransactionOutput> buyerConnectedOutputsForAllInputs;
public final List<TransactionOutput> buyerOutputs;
public final byte[] buyerTradeWalletPubKey;
public final PublicKey buyerP2PSigPublicKey;
public final PublicKey buyerP2PEncryptPublicKey;
public final PublicKey buyerP2pSigPublicKey;
public final PublicKey buyerP2pEncryptPublicKey;
public final FiatAccount buyerFiatAccount;
public final String buyerAccountId;
public final Coin tradeAmount;
@ -49,14 +49,14 @@ public class RequestPayDepositMessage extends TradeMessage implements Serializab
List<TransactionOutput> buyerConnectedOutputsForAllInputs,
List<TransactionOutput> buyerOutputs,
byte[] buyerTradeWalletPubKey,
PublicKey buyerP2PSigPublicKey,
PublicKey buyerP2PEncryptPublicKey,
PublicKey buyerP2pSigPublicKey,
PublicKey buyerP2pEncryptPublicKey,
FiatAccount buyerFiatAccount,
String buyerAccountId) {
super(tradeId);
this.tradeAmount = tradeAmount;
this.buyerP2PSigPublicKey = buyerP2PSigPublicKey;
this.buyerP2PEncryptPublicKey = buyerP2PEncryptPublicKey;
this.buyerP2pSigPublicKey = buyerP2pSigPublicKey;
this.buyerP2pEncryptPublicKey = buyerP2pEncryptPublicKey;
this.buyerConnectedOutputsForAllInputs = buyerConnectedOutputsForAllInputs;
this.buyerOutputs = buyerOutputs;
this.buyerTradeWalletPubKey = buyerTradeWalletPubKey;

View File

@ -1,63 +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.trade.messages;
import io.bitsquare.fiat.FiatAccount;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionOutput;
import java.io.Serializable;
import java.security.PublicKey;
import java.util.List;
import javax.annotation.concurrent.Immutable;
@Immutable
public class RequestPublishDepositTxFromSellerMessage extends RequestPublishDepositTxMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L;
public byte[] sellerTradeWalletPubKey;
public RequestPublishDepositTxFromSellerMessage(String tradeId,
FiatAccount takerFiatAccount,
String takerAccountId,
byte[] sellerTradeWalletPubKey,
PublicKey takerP2PSigPublicKey,
PublicKey takerP2PEncryptPublicKey,
String takerContractAsJson,
String takerContractSignature,
String takerPayoutAddressString,
Transaction takersPreparedDepositTx,
List<TransactionOutput> takerConnectedOutputsForAllInputs) {
super(tradeId,
takerFiatAccount,
takerAccountId,
takerP2PSigPublicKey,
takerP2PEncryptPublicKey,
takerContractAsJson,
takerContractSignature,
takerPayoutAddressString,
takersPreparedDepositTx,
takerConnectedOutputsForAllInputs);
this.sellerTradeWalletPubKey = sellerTradeWalletPubKey;
}
}

View File

@ -35,35 +35,38 @@ public class RequestPublishDepositTxMessage extends TradeMessage implements Seri
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L;
public final FiatAccount takerFiatAccount;
public final String takerAccountId;
public final PublicKey takerP2PSigPublicKey;
public final PublicKey takerP2PEncryptPublicKey;
public final String takerContractAsJson;
public final String takerContractSignature;
public final String takerPayoutAddressString;
public final Transaction takersPreparedDepositTx;
public final List<TransactionOutput> takerConnectedOutputsForAllInputs;
public final FiatAccount sellerFiatAccount;
public final String sellerAccountId;
public final PublicKey sellerP2pSigPublicKey;
public final PublicKey sellerP2pEncryptPublicKey;
public final String sellerContractAsJson;
public final String sellerContractSignature;
public final String sellerPayoutAddressString;
public final Transaction sellersPreparedDepositTx;
public final List<TransactionOutput> sellerConnectedOutputsForAllInputs;
public byte[] sellerTradeWalletPubKey;
public RequestPublishDepositTxMessage(String tradeId,
FiatAccount takerFiatAccount,
String takerAccountId,
PublicKey takerP2PSigPublicKey,
PublicKey takerP2PEncryptPublicKey,
String takerContractAsJson,
String takerContractSignature,
String takerPayoutAddressString,
Transaction takersPreparedDepositTx,
List<TransactionOutput> takerConnectedOutputsForAllInputs) {
FiatAccount sellerFiatAccount,
String sellerAccountId,
byte[] sellerTradeWalletPubKey,
PublicKey sellerP2pSigPublicKey,
PublicKey sellerP2pEncryptPublicKey,
String sellerContractAsJson,
String sellerContractSignature,
String sellerPayoutAddressString,
Transaction sellersPreparedDepositTx,
List<TransactionOutput> sellerConnectedOutputsForAllInputs) {
super(tradeId);
this.takerFiatAccount = takerFiatAccount;
this.takerAccountId = takerAccountId;
this.takerP2PSigPublicKey = takerP2PSigPublicKey;
this.takerP2PEncryptPublicKey = takerP2PEncryptPublicKey;
this.takerContractAsJson = takerContractAsJson;
this.takerContractSignature = takerContractSignature;
this.takerPayoutAddressString = takerPayoutAddressString;
this.takersPreparedDepositTx = takersPreparedDepositTx;
this.takerConnectedOutputsForAllInputs = takerConnectedOutputsForAllInputs;
this.sellerFiatAccount = sellerFiatAccount;
this.sellerAccountId = sellerAccountId;
this.sellerTradeWalletPubKey = sellerTradeWalletPubKey;
this.sellerP2pSigPublicKey = sellerP2pSigPublicKey;
this.sellerP2pEncryptPublicKey = sellerP2pEncryptPublicKey;
this.sellerContractAsJson = sellerContractAsJson;
this.sellerContractSignature = sellerContractSignature;
this.sellerPayoutAddressString = sellerPayoutAddressString;
this.sellersPreparedDepositTx = sellersPreparedDepositTx;
this.sellerConnectedOutputsForAllInputs = sellerConnectedOutputsForAllInputs;
}
}

View File

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.seller.offerer;
package io.bitsquare.trade.protocol.trade.seller;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.MailboxMessage;
@ -31,15 +31,15 @@ import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSendsRequestPublishDepositTxFromTakerMessage;
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsContract;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.shared.models.ProcessModel;
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakeOfferFeePayment;
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakerAccount;
@ -149,7 +149,7 @@ public class SellerAsOffererProtocol implements TradeProtocol {
VerifyTakerAccount.class,
SellerCreatesAndSignsContract.class,
SellerCreatesAndSignsDepositTx.class,
OffererSendsRequestPublishDepositTxFromTakerMessage.class
SellerSendsRequestPublishDepositTxMessage.class
);
taskRunner.run();
}
@ -199,8 +199,8 @@ public class SellerAsOffererProtocol implements TradeProtocol {
taskRunner.addTasks(
VerifyTakeOfferFeePayment.class,
OffererSignsAndPublishPayoutTx.class,
OffererSendsPayoutTxPublishedMessage.class
SellerSignsAndPublishPayoutTx.class,
SellerSendsPayoutTxPublishedMessage.class
);
taskRunner.run();
}

View File

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.seller.taker;
package io.bitsquare.trade.protocol.trade.seller;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.MailboxMessage;
@ -25,20 +25,20 @@ import io.bitsquare.p2p.Peer;
import io.bitsquare.trade.SellerAsTakerTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeProtocol;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsContract;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsRequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.seller.tasks.SendRequestDepositTxInputsMessage;
import io.bitsquare.trade.protocol.trade.shared.models.ProcessModel;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
@ -104,7 +104,7 @@ public class SellerAsTakerProtocol implements TradeProtocol {
taskRunner.addTasks(
CreateTakeOfferFeeTx.class,
BroadcastTakeOfferFeeTx.class,
TakerSendsRequestDepositTxInputsMessage.class
SendRequestDepositTxInputsMessage.class
);
taskRunner.run();
}
@ -126,7 +126,7 @@ public class SellerAsTakerProtocol implements TradeProtocol {
VerifyOffererAccount.class,
SellerCreatesAndSignsContract.class,
SellerCreatesAndSignsDepositTx.class,
TakerSendsRequestPublishDepositTxMessage.class
SellerSendsRequestPublishDepositTxMessage.class
);
taskRunner.run();
}
@ -176,8 +176,8 @@ public class SellerAsTakerProtocol implements TradeProtocol {
taskRunner.addTasks(
VerifyOfferFeePayment.class,
TakerSignsAndPublishPayoutTx.class,
TakerSendsPayoutTxPublishedMessage.class
SellerSignsAndPublishPayoutTx.class,
SellerSendsPayoutTxPublishedMessage.class
);
taskRunner.run();
}

View File

@ -1,73 +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.trade.seller.offerer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.SellerAsOffererTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage;
import io.bitsquare.trade.states.OffererState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OffererSendsPayoutTxPublishedMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(OffererSendsPayoutTxPublishedMessage.class);
public OffererSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@Override
protected void doRun() {
try {
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(processModel.getId(), processModel.getPayoutTx());
processModel.getMessageService().sendMessage(trade.getTradingPeer(),
tradeMessage,
processModel.getP2pSigPubKey(),
processModel.getP2pEncryptPubKey(),
new SendMessageListener() {
@Override
public void handleResult() {
log.trace("PayoutTxPublishedMessage successfully arrived at peer");
complete();
}
@Override
public void handleFault() {
appendToErrorMessage("Sending PayoutTxPublishedMessage failed");
trade.setErrorMessage(errorMessage);
if (trade instanceof BuyerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED);
else if (trade instanceof SellerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED);
failed();
}
});
} catch (Throwable t) {
t.printStackTrace();
trade.setThrowable(t);
failed(t);
}
}
}

View File

@ -1,81 +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.trade.seller.offerer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.SellerAsOffererTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxFromSellerMessage;
import io.bitsquare.trade.states.OffererState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OffererSendsRequestPublishDepositTxFromTakerMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(OffererSendsRequestPublishDepositTxFromTakerMessage.class);
public OffererSendsRequestPublishDepositTxFromTakerMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@Override
protected void doRun() {
try {
RequestPublishDepositTxFromSellerMessage tradeMessage = new RequestPublishDepositTxFromSellerMessage(
processModel.getId(),
processModel.getFiatAccount(),
processModel.getAccountId(),
processModel.getTradeWalletPubKey(),
processModel.getP2pSigPubKey(),
processModel.getP2pEncryptPublicKey(),
trade.getContractAsJson(),
trade.getBuyerContractSignature(),
processModel.getAddressEntry().getAddressString(),
processModel.getPreparedDepositTx(),
processModel.getConnectedOutputsForAllInputs()
);
processModel.getMessageService().sendMessage(trade.getTradingPeer(), tradeMessage, new SendMessageListener() {
@Override
public void handleResult() {
complete();
}
@Override
public void handleFault() {
appendToErrorMessage("Sending RequestOffererPublishDepositTxMessage failed");
trade.setErrorMessage(errorMessage);
if (trade instanceof BuyerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED);
else if (trade instanceof SellerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED);
failed();
}
});
} catch (Throwable t) {
t.printStackTrace();
trade.setThrowable(t);
failed(t);
}
}
}

View File

@ -1,82 +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.trade.seller.offerer.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.SellerAsOffererTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.states.OffererState;
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;
public class OffererSignsAndPublishPayoutTx extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(OffererSignsAndPublishPayoutTx.class);
public OffererSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@Override
protected void doRun() {
try {
processModel.getTradeWalletService().signAndPublishPayoutTx(
trade.getDepositTx(),
processModel.tradingPeer.getSignature(),
processModel.tradingPeer.getPayoutAmount(),
processModel.getPayoutAmount(),
processModel.tradingPeer.getPayoutAddressString(),
processModel.getAddressEntry(),
processModel.tradingPeer.getTradeWalletPubKey(),
processModel.getTradeWalletPubKey(),
processModel.getArbitratorPubKey(),
new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
processModel.setPayoutTx(transaction);
if (trade instanceof BuyerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED);
else if (trade instanceof SellerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED);
complete();
}
@Override
public void onFailure(@NotNull Throwable t) {
t.printStackTrace();
trade.setThrowable(t);
failed(t);
}
});
} catch (Throwable t) {
t.printStackTrace();
trade.setThrowable(t);
failed(t);
}
}
}

View File

@ -45,7 +45,7 @@ public class SellerCreatesAndSignsContract extends TradeTask {
processModel.getAccountId(),
processModel.tradingPeer.getFiatAccount(),
processModel.getFiatAccount(),
processModel.tradingPeer.getP2PSigPubKey(),
processModel.tradingPeer.getP2pSigPubKey(),
processModel.getP2pSigPubKey());
String contractAsJson = Utilities.objectToJson(contract);
String signature = processModel.getSignatureService().signMessage(processModel.getRegistrationKeyPair(), contractAsJson);

View File

@ -46,8 +46,8 @@ public class SellerProcessRequestPayDepositMessage extends TradeTask {
checkArgument(message.buyerConnectedOutputsForAllInputs.size() > 0);
processModel.tradingPeer.setOutputs(checkNotNull(message.buyerOutputs));
processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.buyerTradeWalletPubKey));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.buyerP2PSigPublicKey));
processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.buyerP2PEncryptPublicKey));
processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.buyerP2pSigPublicKey));
processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.buyerP2pEncryptPublicKey));
processModel.tradingPeer.setFiatAccount(checkNotNull(message.buyerFiatAccount));
processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.buyerAccountId));
trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(message.tradeAmount)));

View File

@ -15,24 +15,22 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.seller.taker.tasks;
package io.bitsquare.trade.protocol.trade.seller.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.BuyerAsTakerTrade;
import io.bitsquare.trade.SellerAsTakerTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage;
import io.bitsquare.trade.states.TakerState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TakerSendsPayoutTxPublishedMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(TakerSendsPayoutTxPublishedMessage.class);
public class SellerSendsPayoutTxPublishedMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(SellerSendsPayoutTxPublishedMessage.class);
public TakerSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
public SellerSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -55,12 +53,7 @@ public class TakerSendsPayoutTxPublishedMessage extends TradeTask {
public void handleFault() {
appendToErrorMessage("Sending PayoutTxPublishedMessage failed");
trade.setErrorMessage(errorMessage);
if (trade instanceof BuyerAsTakerTrade)
trade.setProcessState(TakerState.ProcessState.MESSAGE_SENDING_FAILED);
else if (trade instanceof SellerAsTakerTrade)
trade.setProcessState(TakerState.ProcessState.MESSAGE_SENDING_FAILED);
StateUtil.setSendFailedState(trade);
failed();
}
});

View File

@ -15,22 +15,22 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.taker.tasks;
package io.bitsquare.trade.protocol.trade.seller.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TakerSendsRequestPublishDepositTxMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(TakerSendsRequestPublishDepositTxMessage.class);
public class SellerSendsRequestPublishDepositTxMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(SellerSendsRequestPublishDepositTxMessage.class);
public TakerSendsRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) {
public SellerSendsRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -41,8 +41,9 @@ public class TakerSendsRequestPublishDepositTxMessage extends TradeTask {
processModel.getId(),
processModel.getFiatAccount(),
processModel.getAccountId(),
processModel.getTradeWalletPubKey(),
processModel.getP2pSigPubKey(),
processModel.getP2pEncryptPublicKey(),
processModel.getP2pEncryptPubKey(),
trade.getContractAsJson(),
trade.getSellerContractSignature(),
processModel.getAddressEntry().getAddressString(),
@ -60,7 +61,9 @@ public class TakerSendsRequestPublishDepositTxMessage extends TradeTask {
public void handleFault() {
appendToErrorMessage("Sending RequestOffererPublishDepositTxMessage failed");
trade.setErrorMessage(errorMessage);
StateUtil.setSendFailedState(trade);
failed();
}
});

View File

@ -15,13 +15,16 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.seller.taker.tasks;
package io.bitsquare.trade.protocol.trade.seller.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.trade.BuyerAsOffererTrade;
import io.bitsquare.trade.BuyerAsTakerTrade;
import io.bitsquare.trade.SellerAsOffererTrade;
import io.bitsquare.trade.SellerAsTakerTrade;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.states.OffererState;
import io.bitsquare.trade.states.TakerState;
import org.bitcoinj.core.Transaction;
@ -33,10 +36,10 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TakerSignsAndPublishPayoutTx extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(TakerSignsAndPublishPayoutTx.class);
public class SellerSignsAndPublishPayoutTx extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(SellerSignsAndPublishPayoutTx.class);
public TakerSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) {
public SellerSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -58,10 +61,10 @@ public class TakerSignsAndPublishPayoutTx extends TradeTask {
public void onSuccess(Transaction transaction) {
processModel.setPayoutTx(transaction);
if (trade instanceof BuyerAsTakerTrade)
trade.setProcessState(TakerState.ProcessState.PAYOUT_PUBLISHED);
else if (trade instanceof SellerAsTakerTrade)
if (trade instanceof BuyerAsTakerTrade || trade instanceof SellerAsTakerTrade)
trade.setProcessState(TakerState.ProcessState.PAYOUT_PUBLISHED);
else if (trade instanceof BuyerAsOffererTrade || trade instanceof SellerAsOffererTrade)
trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED);
complete();
}

View File

@ -15,13 +15,13 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.trade.protocol.trade.buyer.taker.tasks;
package io.bitsquare.trade.protocol.trade.seller.tasks;
import io.bitsquare.common.taskrunner.TaskRunner;
import io.bitsquare.p2p.listener.SendMessageListener;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.StateUtil;
import io.bitsquare.trade.protocol.trade.TradeTask;
import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil;
import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage;
import javafx.application.Platform;
@ -29,10 +29,10 @@ import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TakerSendsRequestDepositTxInputsMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(TakerSendsRequestDepositTxInputsMessage.class);
public class SendRequestDepositTxInputsMessage extends TradeTask {
private static final Logger log = LoggerFactory.getLogger(SendRequestDepositTxInputsMessage.class);
public TakerSendsRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) {
public SendRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) {
super(taskHandler, trade);
}
@ -62,7 +62,7 @@ public class TakerSendsRequestDepositTxInputsMessage extends TradeTask {
// We try to repeat once and if that fails as well we persist the state for a later retry.
if (retryCounter == 0) {
retryCounter++;
Platform.runLater(TakerSendsRequestDepositTxInputsMessage.this::doRun);
Platform.runLater(SendRequestDepositTxInputsMessage.this::doRun);
}
else {
appendToErrorMessage("Sending TakeOfferFeePayedMessage to offerer failed. Maybe the network connection was " +

View File

@ -206,11 +206,7 @@ public class ProcessModel extends Model implements Serializable {
}
public PublicKey getP2pSigPubKey() {
return user.getP2PSigPubKey();
}
public PublicKey getP2pEncryptPublicKey() {
return user.getP2PEncryptPubKey();
return user.getP2pSigPubKey();
}
public byte[] getRegistrationPubKey() {
@ -226,7 +222,7 @@ public class ProcessModel extends Model implements Serializable {
}
public PublicKey getP2pEncryptPubKey() {
return user.getP2PEncryptPubKey();
return user.getP2pEncryptPubKey();
}
@Nullable

View File

@ -55,7 +55,6 @@ public class TradingPeer implements Serializable {
private byte[] signature;
private String contractAsJson;
private String contractSignature;
private PublicKey p2PSigPubKey;
///////////////////////////////////////////////////////////////////////////////////////////
@ -199,11 +198,4 @@ public class TradingPeer implements Serializable {
'}';
}
public PublicKey getP2PSigPubKey() {
return p2PSigPubKey;
}
public void setP2PSigPubKey(PublicKey p2PSigPubKey) {
this.p2PSigPubKey = p2PSigPubKey;
}
}

View File

@ -200,11 +200,11 @@ public class User implements Serializable {
return p2pSigKeyPair;
}
public PublicKey getP2PSigPubKey() {
public PublicKey getP2pSigPubKey() {
return p2pSigKeyPair.getPublic();
}
public PublicKey getP2PEncryptPubKey() {
public PublicKey getP2pEncryptPubKey() {
return p2pEncryptKeyPair.getPublic();
}