mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Unified Seller tasks (WIP)
This commit is contained in:
parent
0a4e082e44
commit
06c06b1244
@ -46,7 +46,7 @@ import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignC
|
||||
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.TakerProcessRequestSellerDepositPaymentMessage;
|
||||
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.shared.offerer.tasks.VerifyTakeOfferFeePayment;
|
||||
@ -122,7 +122,7 @@ public class DebugView extends InitializableView {
|
||||
CreateTakeOfferFeeTx.class,
|
||||
TakerSendsRequestDepositTxInputsMessage.class,
|
||||
|
||||
TakerProcessRequestSellerDepositPaymentMessage.class,
|
||||
TakerProcessRequestPayDepositMessage.class,
|
||||
VerifyOffererAccount.class,
|
||||
TakerCreatesAndSignContract.class,
|
||||
TakerCreatesAndSignsDepositTx.class,
|
||||
|
@ -99,8 +99,8 @@ abstract public class Trade extends Model implements Serializable {
|
||||
protected Transaction depositTx;
|
||||
private Contract contract;
|
||||
private String contractAsJson;
|
||||
private String takerContractSignature;
|
||||
private String offererContractSignature;
|
||||
private String sellerContractSignature;
|
||||
private String buyerContractSignature;
|
||||
private Transaction payoutTx;
|
||||
|
||||
// Transient/Mutable
|
||||
@ -354,22 +354,22 @@ abstract public class Trade extends Model implements Serializable {
|
||||
// Getter/Setter for Mutable objects
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setTakerContractSignature(String takerSignature) {
|
||||
this.takerContractSignature = takerSignature;
|
||||
public void setSellerContractSignature(String takerSignature) {
|
||||
this.sellerContractSignature = takerSignature;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTakerContractSignature() {
|
||||
return takerContractSignature;
|
||||
public String getSellerContractSignature() {
|
||||
return sellerContractSignature;
|
||||
}
|
||||
|
||||
public void setOffererContractSignature(String offererContractSignature) {
|
||||
this.offererContractSignature = offererContractSignature;
|
||||
public void setBuyerContractSignature(String buyerContractSignature) {
|
||||
this.buyerContractSignature = buyerContractSignature;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getOffererContractSignature() {
|
||||
return offererContractSignature;
|
||||
public String getBuyerContractSignature() {
|
||||
return buyerContractSignature;
|
||||
}
|
||||
|
||||
public void setContractAsJson(String contractAsJson) {
|
||||
@ -430,8 +430,8 @@ abstract public class Trade extends Model implements Serializable {
|
||||
", depositTx=" + depositTx +
|
||||
", contract=" + contract +
|
||||
", contractAsJson='" + contractAsJson + '\'' +
|
||||
", takerContractSignature='" + takerContractSignature + '\'' +
|
||||
", offererContractSignature='" + offererContractSignature + '\'' +
|
||||
", takerContractSignature='" + sellerContractSignature + '\'' +
|
||||
", offererContractSignature='" + buyerContractSignature + '\'' +
|
||||
", payoutTx=" + payoutTx +
|
||||
", errorMessage='" + errorMessage + '\'' +
|
||||
", throwable=" + throwable +
|
||||
|
@ -44,7 +44,7 @@ public class TakerSendsRequestPublishDepositTxMessage extends TradeTask {
|
||||
processModel.getP2pSigPubKey(),
|
||||
processModel.getP2pEncryptPublicKey(),
|
||||
trade.getContractAsJson(),
|
||||
trade.getTakerContractSignature(),
|
||||
trade.getSellerContractSignature(),
|
||||
processModel.getAddressEntry().getAddressString(),
|
||||
processModel.getPreparedDepositTx(),
|
||||
processModel.getConnectedOutputsForAllInputs()
|
||||
|
@ -50,8 +50,8 @@ public class BuyerVerifiesAndSignsContract extends TradeTask {
|
||||
String signature = processModel.getSignatureService().signMessage(processModel.getRegistrationKeyPair(), contractAsJson);
|
||||
trade.setContract(contract);
|
||||
trade.setContractAsJson(contractAsJson);
|
||||
trade.setOffererContractSignature(signature);
|
||||
trade.setOffererContractSignature(processModel.tradingPeer.getContractSignature());
|
||||
trade.setBuyerContractSignature(signature);
|
||||
trade.setBuyerContractSignature(processModel.tradingPeer.getContractSignature());
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
@ -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.OffererCommitDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererCreatesAndSignsContract;
|
||||
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererCreatesAndSignsDepositTx;
|
||||
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererProcessDepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererProcessFiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererProcessRequestPayDepositFromOffererMessage;
|
||||
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.shared.models.ProcessModel;
|
||||
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakeOfferFeePayment;
|
||||
import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakerAccount;
|
||||
@ -145,10 +145,10 @@ public class SellerAsOffererProtocol implements TradeProtocol {
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(
|
||||
OffererProcessRequestPayDepositFromOffererMessage.class,
|
||||
SellerProcessRequestPayDepositMessage.class,
|
||||
VerifyTakerAccount.class,
|
||||
OffererCreatesAndSignsContract.class,
|
||||
OffererCreatesAndSignsDepositTx.class,
|
||||
SellerCreatesAndSignsContract.class,
|
||||
SellerCreatesAndSignsDepositTx.class,
|
||||
OffererSendsRequestPublishDepositTxFromTakerMessage.class
|
||||
);
|
||||
taskRunner.run();
|
||||
@ -162,8 +162,8 @@ public class SellerAsOffererProtocol implements TradeProtocol {
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(
|
||||
OffererProcessDepositTxPublishedMessage.class,
|
||||
OffererCommitDepositTx.class
|
||||
SellerProcessDepositTxPublishedMessage.class,
|
||||
SellerCommitDepositTx.class
|
||||
);
|
||||
taskRunner.run();
|
||||
}
|
||||
@ -175,7 +175,7 @@ public class SellerAsOffererProtocol implements TradeProtocol {
|
||||
() -> log.debug("taskRunner at handleFiatTransferStartedMessage completed"),
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(OffererProcessFiatTransferStartedMessage.class);
|
||||
taskRunner.addTasks(SellerProcessFiatTransferStartedMessage.class);
|
||||
taskRunner.run();
|
||||
}
|
||||
|
||||
|
@ -1,51 +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.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.TradeTask;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OffererCommitDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererCommitDepositTx.class);
|
||||
|
||||
public OffererCommitDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
// To access tx confidence we need to add that tx into our wallet.
|
||||
Transaction depositTx = processModel.getTradeWalletService().commitTx(trade.getDepositTx());
|
||||
|
||||
trade.setDepositTx(depositTx);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +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.Contract;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.TradeTask;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OffererCreatesAndSignsContract extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererCreatesAndSignsContract.class);
|
||||
|
||||
public OffererCreatesAndSignsContract(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
assert processModel.getTakeOfferFeeTxId() != null;
|
||||
Contract contract = new Contract(
|
||||
processModel.getOffer(),
|
||||
model.getTradeAmount(),
|
||||
processModel.getTakeOfferFeeTxId(),
|
||||
processModel.getAccountId(),
|
||||
processModel.getAccountId(),
|
||||
processModel.getFiatAccount(),
|
||||
processModel.getFiatAccount(),
|
||||
processModel.getOffer().getP2PSigPubKey(),
|
||||
processModel.getP2pSigPubKey());
|
||||
String contractAsJson = Utilities.objectToJson(contract);
|
||||
String signature = processModel.getSignatureService().signMessage(processModel.getRegistrationKeyPair(),
|
||||
contractAsJson);
|
||||
|
||||
model.setContract(contract);
|
||||
model.setContractAsJson(contractAsJson);
|
||||
model.setOffererContractSignature(signature);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -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.seller.offerer.tasks;
|
||||
|
||||
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.TradeTask;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OffererCreatesAndSignsDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererCreatesAndSignsDepositTx.class);
|
||||
|
||||
public OffererCreatesAndSignsDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
assert trade.getTradeAmount() != null;
|
||||
Coin inputAmount = trade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(trade.getTradeAmount());
|
||||
Coin msOutputAmount = inputAmount.add(trade.getSecurityDeposit());
|
||||
|
||||
TradeWalletService.Result result = processModel.getTradeWalletService().createAndSignDepositTx(
|
||||
inputAmount,
|
||||
msOutputAmount,
|
||||
processModel.tradingPeer.getConnectedOutputsForAllInputs(),
|
||||
processModel.tradingPeer.getOutputs(),
|
||||
processModel.getAddressEntry(),
|
||||
processModel.tradingPeer.getTradeWalletPubKey(),
|
||||
processModel.getTradeWalletPubKey(),
|
||||
processModel.getArbitratorPubKey());
|
||||
|
||||
|
||||
processModel.setConnectedOutputsForAllInputs(result.getConnectedOutputsForAllInputs());
|
||||
processModel.setPreparedDepositTx(result.getDepositTx());
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class OffererSendsRequestPublishDepositTxFromTakerMessage extends TradeTa
|
||||
processModel.getP2pSigPubKey(),
|
||||
processModel.getP2pEncryptPublicKey(),
|
||||
trade.getContractAsJson(),
|
||||
trade.getOffererContractSignature(),
|
||||
trade.getBuyerContractSignature(),
|
||||
processModel.getAddressEntry().getAddressString(),
|
||||
processModel.getPreparedDepositTx(),
|
||||
processModel.getConnectedOutputsForAllInputs()
|
||||
|
@ -31,14 +31,14 @@ 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.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.TakerProcessRequestSellerDepositPaymentMessage;
|
||||
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.shared.models.ProcessModel;
|
||||
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
|
||||
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
|
||||
@ -122,10 +122,10 @@ public class SellerAsTakerProtocol implements TradeProtocol {
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(
|
||||
TakerProcessRequestSellerDepositPaymentMessage.class,
|
||||
SellerProcessRequestPayDepositMessage.class,
|
||||
VerifyOffererAccount.class,
|
||||
TakerCreatesAndSignContract.class,
|
||||
TakerCreatesAndSignsDepositTx.class,
|
||||
SellerCreatesAndSignsContract.class,
|
||||
SellerCreatesAndSignsDepositTx.class,
|
||||
TakerSendsRequestPublishDepositTxMessage.class
|
||||
);
|
||||
taskRunner.run();
|
||||
@ -139,8 +139,8 @@ public class SellerAsTakerProtocol implements TradeProtocol {
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(
|
||||
TakerProcessDepositTxPublishedMessage.class,
|
||||
TakerCommitDepositTx.class
|
||||
SellerProcessDepositTxPublishedMessage.class,
|
||||
SellerCommitDepositTx.class
|
||||
);
|
||||
taskRunner.run();
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class SellerAsTakerProtocol implements TradeProtocol {
|
||||
() -> log.debug("taskRunner at handleFiatTransferStartedMessage completed"),
|
||||
this::handleTaskRunnerFault);
|
||||
|
||||
taskRunner.addTasks(TakerProcessFiatTransferStartedMessage.class);
|
||||
taskRunner.addTasks(SellerProcessFiatTransferStartedMessage.class);
|
||||
taskRunner.run();
|
||||
}
|
||||
|
||||
|
@ -1,62 +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.taker.tasks;
|
||||
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.trade.BuyerAsTakerTrade;
|
||||
import io.bitsquare.trade.SellerAsTakerTrade;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.TradeTask;
|
||||
import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.states.TakerState;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.bitsquare.util.Validator.checkTradeId;
|
||||
|
||||
public class TakerProcessDepositTxPublishedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerProcessDepositTxPublishedMessage.class);
|
||||
|
||||
public TakerProcessDepositTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
DepositTxPublishedMessage message = (DepositTxPublishedMessage) processModel.getTradeMessage();
|
||||
checkTradeId(processModel.getId(), message);
|
||||
checkNotNull(message);
|
||||
|
||||
trade.setDepositTx(checkNotNull(message.depositTx));
|
||||
|
||||
if (trade instanceof BuyerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.DEPOSIT_PUBLISHED);
|
||||
else if (trade instanceof SellerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.DEPOSIT_PUBLISHED);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +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.taker.tasks;
|
||||
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.trade.BuyerAsTakerTrade;
|
||||
import io.bitsquare.trade.SellerAsTakerTrade;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.TradeTask;
|
||||
import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.states.TakerState;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.bitsquare.util.Validator.*;
|
||||
|
||||
public class TakerProcessFiatTransferStartedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerProcessFiatTransferStartedMessage.class);
|
||||
|
||||
public TakerProcessFiatTransferStartedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
FiatTransferStartedMessage message = (FiatTransferStartedMessage) processModel.getTradeMessage();
|
||||
checkTradeId(processModel.getId(), message);
|
||||
checkNotNull(message);
|
||||
|
||||
processModel.tradingPeer.setSignature(checkNotNull(message.buyerSignature));
|
||||
processModel.tradingPeer.setPayoutAmount(positiveCoinOf(nonZeroCoinOf(message.buyerPayoutAmount)));
|
||||
processModel.setPayoutAmount(positiveCoinOf(nonZeroCoinOf(message.sellerPayoutAmount)));
|
||||
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.buyerPayoutAddress));
|
||||
|
||||
if (trade instanceof BuyerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
else if (trade instanceof SellerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +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.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.RequestPayDepositMessage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
import static io.bitsquare.util.Validator.*;
|
||||
|
||||
public class TakerProcessRequestSellerDepositPaymentMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerProcessRequestSellerDepositPaymentMessage.class);
|
||||
|
||||
public TakerProcessRequestSellerDepositPaymentMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
RequestPayDepositMessage message = (RequestPayDepositMessage) processModel.getTradeMessage();
|
||||
checkTradeId(processModel.getId(), message);
|
||||
checkNotNull(message);
|
||||
|
||||
processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.buyerConnectedOutputsForAllInputs));
|
||||
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.setFiatAccount(checkNotNull(message.buyerFiatAccount));
|
||||
processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.buyerAccountId));
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
trade.setThrowable(t);
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* 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.Trade;
|
||||
@ -26,10 +26,10 @@ import org.bitcoinj.core.Transaction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TakerCommitDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerCommitDepositTx.class);
|
||||
public class SellerCommitDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerCommitDepositTx.class);
|
||||
|
||||
public TakerCommitDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerCommitDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* 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.Contract;
|
||||
@ -26,33 +26,33 @@ import io.bitsquare.util.Utilities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TakerCreatesAndSignContract extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerCreatesAndSignContract.class);
|
||||
public class SellerCreatesAndSignsContract extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerCreatesAndSignsContract.class);
|
||||
|
||||
public TakerCreatesAndSignContract(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerCreatesAndSignsContract(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
assert processModel.getTakeOfferFeeTx() != null;
|
||||
assert processModel.getTakeOfferFeeTxId() != null;
|
||||
Contract contract = new Contract(
|
||||
processModel.getOffer(),
|
||||
model.getTradeAmount(),
|
||||
processModel.getTakeOfferFeeTx().getHashAsString(),
|
||||
processModel.getTakeOfferFeeTxId(),
|
||||
processModel.tradingPeer.getAccountId(),
|
||||
processModel.getAccountId(),
|
||||
processModel.tradingPeer.getFiatAccount(),
|
||||
processModel.getFiatAccount(),
|
||||
processModel.getOffer().getP2PSigPubKey(),
|
||||
processModel.tradingPeer.getP2PSigPubKey(),
|
||||
processModel.getP2pSigPubKey());
|
||||
String contractAsJson = Utilities.objectToJson(contract);
|
||||
String signature = processModel.getSignatureService().signMessage(processModel.getRegistrationKeyPair(), contractAsJson);
|
||||
|
||||
model.setContract(contract);
|
||||
model.setContractAsJson(contractAsJson);
|
||||
model.setTakerContractSignature(signature);
|
||||
model.setSellerContractSignature(signature);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
@ -15,7 +15,7 @@
|
||||
* 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.btc.FeePolicy;
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
@ -28,10 +28,10 @@ import org.bitcoinj.core.Coin;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TakerCreatesAndSignsDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakerCreatesAndSignsDepositTx.class);
|
||||
public class SellerCreatesAndSignsDepositTx extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerCreatesAndSignsDepositTx.class);
|
||||
|
||||
public TakerCreatesAndSignsDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerCreatesAndSignsDepositTx(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ public class TakerCreatesAndSignsDepositTx extends TradeTask {
|
||||
processModel.getTradeWalletPubKey(),
|
||||
processModel.getArbitratorPubKey());
|
||||
|
||||
|
||||
processModel.setConnectedOutputsForAllInputs(result.getConnectedOutputsForAllInputs());
|
||||
processModel.setPreparedDepositTx(result.getDepositTx());
|
||||
|
@ -15,15 +15,18 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.seller.offerer.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.protocol.trade.messages.DepositTxPublishedMessage;
|
||||
import io.bitsquare.trade.states.OffererState;
|
||||
import io.bitsquare.trade.states.TakerState;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -31,10 +34,10 @@ import org.slf4j.LoggerFactory;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.bitsquare.util.Validator.checkTradeId;
|
||||
|
||||
public class OffererProcessDepositTxPublishedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererProcessDepositTxPublishedMessage.class);
|
||||
public class SellerProcessDepositTxPublishedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerProcessDepositTxPublishedMessage.class);
|
||||
|
||||
public OffererProcessDepositTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerProcessDepositTxPublishedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@ -47,10 +50,10 @@ public class OffererProcessDepositTxPublishedMessage extends TradeTask {
|
||||
|
||||
trade.setDepositTx(checkNotNull(message.depositTx));
|
||||
|
||||
if (trade instanceof BuyerAsOffererTrade)
|
||||
trade.setProcessState(OffererState.ProcessState.DEPOSIT_PUBLISHED);
|
||||
else if (trade instanceof SellerAsOffererTrade)
|
||||
if (trade instanceof BuyerAsOffererTrade || trade instanceof SellerAsOffererTrade)
|
||||
trade.setProcessState(OffererState.ProcessState.DEPOSIT_PUBLISHED);
|
||||
else if (trade instanceof BuyerAsTakerTrade || trade instanceof SellerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.DEPOSIT_PUBLISHED);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
@ -15,15 +15,18 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.seller.offerer.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.protocol.trade.messages.FiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.states.OffererState;
|
||||
import io.bitsquare.trade.states.TakerState;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -31,10 +34,10 @@ import org.slf4j.LoggerFactory;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.bitsquare.util.Validator.*;
|
||||
|
||||
public class OffererProcessFiatTransferStartedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererProcessFiatTransferStartedMessage.class);
|
||||
public class SellerProcessFiatTransferStartedMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerProcessFiatTransferStartedMessage.class);
|
||||
|
||||
public OffererProcessFiatTransferStartedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerProcessFiatTransferStartedMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@ -50,10 +53,10 @@ public class OffererProcessFiatTransferStartedMessage extends TradeTask {
|
||||
processModel.tradingPeer.setPayoutAmount(positiveCoinOf(nonZeroCoinOf(message.buyerPayoutAmount)));
|
||||
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.buyerPayoutAddress));
|
||||
|
||||
if (trade instanceof BuyerAsOffererTrade)
|
||||
trade.setProcessState(OffererState.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
else if (trade instanceof SellerAsOffererTrade)
|
||||
if (trade instanceof BuyerAsOffererTrade || trade instanceof SellerAsOffererTrade)
|
||||
trade.setProcessState(OffererState.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
else if (trade instanceof BuyerAsTakerTrade || trade instanceof SellerAsTakerTrade)
|
||||
trade.setProcessState(TakerState.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.seller.offerer.tasks;
|
||||
package io.bitsquare.trade.protocol.trade.seller.tasks;
|
||||
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.trade.Trade;
|
||||
@ -28,10 +28,10 @@ import org.slf4j.LoggerFactory;
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
import static io.bitsquare.util.Validator.*;
|
||||
|
||||
public class OffererProcessRequestPayDepositFromOffererMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffererProcessRequestPayDepositFromOffererMessage.class);
|
||||
public class SellerProcessRequestPayDepositMessage extends TradeTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(SellerProcessRequestPayDepositMessage.class);
|
||||
|
||||
public OffererProcessRequestPayDepositFromOffererMessage(TaskRunner taskHandler, Trade trade) {
|
||||
public SellerProcessRequestPayDepositMessage(TaskRunner taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class TradingPeer implements Serializable {
|
||||
private byte[] signature;
|
||||
private String contractAsJson;
|
||||
private String contractSignature;
|
||||
private PublicKey p2PSigPubKey;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -197,4 +198,12 @@ public class TradingPeer implements Serializable {
|
||||
", contractSignature='" + contractSignature + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public PublicKey getP2PSigPubKey() {
|
||||
return p2PSigPubKey;
|
||||
}
|
||||
|
||||
public void setP2PSigPubKey(PublicKey p2PSigPubKey) {
|
||||
this.p2PSigPubKey = p2PSigPubKey;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user