Merge TradingPeer models

This commit is contained in:
Manfred Karrer 2015-04-02 12:24:04 +02:00
parent 33bd09e82c
commit 238f36cffd
25 changed files with 101 additions and 313 deletions

View file

@ -90,8 +90,8 @@ public class OffererAsBuyerTrade extends OffererTrade implements Serializable {
lifeCycleState = LifeCycleState.OFFER_OPEN; lifeCycleState = LifeCycleState.OFFER_OPEN;
initStateProperties(); initStateProperties();
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Fiat // Fiat
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -101,7 +101,7 @@ public class OffererAsBuyerTrade extends OffererTrade implements Serializable {
((BuyerAsOffererProtocol) protocol).onFiatPaymentStarted(); ((BuyerAsOffererProtocol) protocol).onFiatPaymentStarted();
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Setter for Mutable objects // Setter for Mutable objects
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -96,13 +96,12 @@ public abstract class TakerTrade extends Trade implements Serializable {
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// API // API
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
abstract public void takeAvailableOffer(); abstract public void takeAvailableOffer();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getter only // Getter only

View file

@ -37,7 +37,7 @@ public class OffererCommitsPayoutTx extends OffererTradeTask {
protected void doRun() { protected void doRun() {
try { try {
Transaction transaction = offererTradeProcessModel.getTradeWalletService().commitTx(offererTrade.getPayoutTx()); Transaction transaction = offererTradeProcessModel.getTradeWalletService().commitTx(offererTrade.getPayoutTx());
offererTrade.setPayoutTx(transaction); offererTrade.setPayoutTx(transaction);
complete(); complete();

View file

@ -40,7 +40,7 @@ public class OffererCreatesAndSignPayoutTx extends OffererTradeTask {
Coin securityDeposit = offererTrade.getSecurityDeposit(); Coin securityDeposit = offererTrade.getSecurityDeposit();
Coin offererPayoutAmount = securityDeposit.add(offererTrade.getTradeAmount()); Coin offererPayoutAmount = securityDeposit.add(offererTrade.getTradeAmount());
Coin takerPayoutAmount = securityDeposit; Coin takerPayoutAmount = securityDeposit;
byte[] offererPayoutTxSignature = offererTradeProcessModel.getTradeWalletService().createAndSignPayoutTx( byte[] offererPayoutTxSignature = offererTradeProcessModel.getTradeWalletService().createAndSignPayoutTx(
offererTrade.getDepositTx(), offererTrade.getDepositTx(),
offererPayoutAmount, offererPayoutAmount,

View file

@ -50,7 +50,7 @@ public class OffererProcessPayoutTxPublishedMessage extends OffererTradeTask {
offererTrade.setProcessState(OffererAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED); offererTrade.setProcessState(OffererAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED);
else if (offererTrade instanceof OffererAsSellerTrade) else if (offererTrade instanceof OffererAsSellerTrade)
offererTrade.setProcessState(OffererAsSellerTrade.ProcessState.PAYOUT_PUBLISHED); offererTrade.setProcessState(OffererAsSellerTrade.ProcessState.PAYOUT_PUBLISHED);
complete(); complete();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();

View file

@ -52,7 +52,7 @@ public class OffererProcessRequestDepositTxInputsMessage extends OffererTradeTas
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
offererTrade.setThrowable(t); offererTrade.setThrowable(t);
if (offererTrade instanceof OffererAsBuyerTrade) if (offererTrade instanceof OffererAsBuyerTrade)
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN); offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
else if (offererTrade instanceof OffererAsSellerTrade) else if (offererTrade instanceof OffererAsSellerTrade)

View file

@ -58,7 +58,7 @@ public class OffererSendsFiatTransferStartedMessage extends OffererTradeTask {
else if (offererTrade instanceof OffererAsSellerTrade) { else if (offererTrade instanceof OffererAsSellerTrade) {
((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.FIAT_PAYMENT_STARTED); ((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.FIAT_PAYMENT_STARTED);
} }
complete(); complete();
} }
@ -73,7 +73,7 @@ public class OffererSendsFiatTransferStartedMessage extends OffererTradeTask {
else if (offererTrade instanceof OffererAsSellerTrade) { else if (offererTrade instanceof OffererAsSellerTrade) {
((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.MESSAGE_SENDING_FAILED); ((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.MESSAGE_SENDING_FAILED);
} }
failed(); failed();
} }
}); });

View file

@ -74,7 +74,7 @@ public class OffererSendsRequestSellerDepositPaymentMessage extends OffererTrade
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
offererTrade.setThrowable(t); offererTrade.setThrowable(t);
if (offererTrade instanceof OffererAsBuyerTrade) { if (offererTrade instanceof OffererAsBuyerTrade) {
((OffererAsBuyerTrade) offererTrade).setProcessState(OffererAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED); ((OffererAsBuyerTrade) offererTrade).setProcessState(OffererAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED);
((OffererAsSellerTrade) offererTrade).setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN); ((OffererAsSellerTrade) offererTrade).setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);

View file

@ -66,7 +66,7 @@ public class OffererVerifiesAndSignsContract extends OffererTradeTask {
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN); offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
else if (offererTrade instanceof OffererAsSellerTrade) else if (offererTrade instanceof OffererAsSellerTrade)
offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN); offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);
failed(t); failed(t);
} }
} }

View file

@ -24,12 +24,6 @@ import io.bitsquare.p2p.MessageHandler;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.trade.TakerAsBuyerTrade; import io.bitsquare.trade.TakerAsBuyerTrade;
import io.bitsquare.trade.protocol.Protocol; import io.bitsquare.trade.protocol.Protocol;
import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCommitsPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCommitsPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCreatesAndSignsPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCreatesAndSignsPayoutTx;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCreatesDepositTxInputs; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerCreatesDepositTxInputs;
@ -40,8 +34,14 @@ import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsFiatTransfe
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSignsAndPublishDepositTx; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSignsAndPublishDepositTx;
import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerVerifiesAndSignsContract; import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerVerifiesAndSignsContract;
import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage;
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOfferFeePayment; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOfferFeePayment;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOffererAccount; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOffererAccount;
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View file

@ -37,7 +37,7 @@ public class TakerCommitsPayoutTx extends TakerTradeTask {
protected void doRun() { protected void doRun() {
try { try {
Transaction transaction = takerTradeProcessModel.getTradeWalletService().commitTx(takerTrade.getPayoutTx()); Transaction transaction = takerTradeProcessModel.getTradeWalletService().commitTx(takerTrade.getPayoutTx());
takerTrade.setPayoutTx(transaction); takerTrade.setPayoutTx(transaction);
complete(); complete();

View file

@ -42,7 +42,7 @@ public class TakerCreatesAndSignsPayoutTx extends TakerTradeTask {
Coin offererPayoutAmount = securityDeposit; Coin offererPayoutAmount = securityDeposit;
Coin takerPayoutAmount = securityDeposit.add(takerTrade.getTradeAmount()); Coin takerPayoutAmount = securityDeposit.add(takerTrade.getTradeAmount());
byte[] takerPayoutTxSignature = takerTradeProcessModel.getTradeWalletService().createAndSignPayoutTx( byte[] takerPayoutTxSignature = takerTradeProcessModel.getTradeWalletService().createAndSignPayoutTx(
takerTrade.getDepositTx(), takerTrade.getDepositTx(),
takerPayoutAmount, takerPayoutAmount,

View file

@ -50,7 +50,7 @@ public class TakerProcessPayoutTxPublishedMessage extends TakerTradeTask {
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED); takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED);
else if (takerTrade instanceof TakerAsSellerTrade) else if (takerTrade instanceof TakerAsSellerTrade)
takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.PAYOUT_PUBLISHED); takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.PAYOUT_PUBLISHED);
complete(); complete();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();

View file

@ -71,7 +71,7 @@ public class TakerSendsRequestDepositTxInputsMessage extends TakerTradeTask {
"or cancel that trade."); "or cancel that trade.");
takerTrade.setErrorMessage(errorMessage); takerTrade.setErrorMessage(errorMessage);
if (takerTrade instanceof TakerAsBuyerTrade) if (takerTrade instanceof TakerAsBuyerTrade)
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED); takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED);
else if (takerTrade instanceof TakerAsSellerTrade) else if (takerTrade instanceof TakerAsSellerTrade)

View file

@ -45,7 +45,7 @@ public class TakerSignsAndPublishDepositTx extends TakerTradeTask {
protected void doRun() { protected void doRun() {
try { try {
Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE); Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE);
takerTradeProcessModel.getTradeWalletService().signAndPublishDepositTx( takerTradeProcessModel.getTradeWalletService().signAndPublishDepositTx(
takerTradeProcessModel.tradingPeer.getPreparedDepositTx(), takerTradeProcessModel.tradingPeer.getPreparedDepositTx(),
takerTradeProcessModel.getConnectedOutputsForAllInputs(), takerTradeProcessModel.getConnectedOutputsForAllInputs(),

View file

@ -27,6 +27,7 @@ import io.bitsquare.fiat.FiatAccount;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.p2p.MessageService; import io.bitsquare.p2p.MessageService;
import io.bitsquare.trade.protocol.trade.ProcessModel; import io.bitsquare.trade.protocol.trade.ProcessModel;
import io.bitsquare.trade.protocol.trade.shared.models.TradingPeer;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;

View file

@ -48,7 +48,7 @@ public class OffererCreatesAndSignsContract extends OffererTradeTask {
offererTradeProcessModel.getOffer().getP2PSigPubKey(), offererTradeProcessModel.getOffer().getP2PSigPubKey(),
offererTradeProcessModel.getP2pSigPubKey()); offererTradeProcessModel.getP2pSigPubKey());
String contractAsJson = Utilities.objectToJson(contract); String contractAsJson = Utilities.objectToJson(contract);
String signature = offererTradeProcessModel.getSignatureService().signMessage(offererTradeProcessModel.getRegistrationKeyPair(), String signature = offererTradeProcessModel.getSignatureService().signMessage(offererTradeProcessModel.getRegistrationKeyPair(),
contractAsJson); contractAsJson);
model.setContract(contract); model.setContract(contract);

View file

@ -41,7 +41,7 @@ public class OffererCreatesAndSignsDepositTx extends OffererTradeTask {
assert offererTrade.getTradeAmount() != null; assert offererTrade.getTradeAmount() != null;
Coin inputAmount = offererTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(offererTrade.getTradeAmount()); Coin inputAmount = offererTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(offererTrade.getTradeAmount());
Coin msOutputAmount = inputAmount.add(offererTrade.getSecurityDeposit()); Coin msOutputAmount = inputAmount.add(offererTrade.getSecurityDeposit());
TradeWalletService.Result result = offererTradeProcessModel.getTradeWalletService().createAndSignDepositTx( TradeWalletService.Result result = offererTradeProcessModel.getTradeWalletService().createAndSignDepositTx(
inputAmount, inputAmount,
msOutputAmount, msOutputAmount,

View file

@ -25,25 +25,25 @@ import io.bitsquare.p2p.Peer;
import io.bitsquare.trade.TakerAsSellerTrade; import io.bitsquare.trade.TakerAsSellerTrade;
import io.bitsquare.trade.TakerTrade; import io.bitsquare.trade.TakerTrade;
import io.bitsquare.trade.protocol.Protocol; import io.bitsquare.trade.protocol.Protocol;
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.DepositTxPublishedMessage;
import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage;
import io.bitsquare.trade.protocol.trade.messages.TradeMessage; import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCommitDepositTx; 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.TakerCreatesAndSignContract;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignsDepositTx; import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignsDepositTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessDepositTxPublishedMessage; 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.TakerProcessFiatTransferStartedMessage;
import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessRequestSellerDepositPaymentMessage; 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.TakerSendsPayoutTxPublishedMessage;
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.seller.taker.tasks.TakerSignsAndPublishPayoutTx; import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSignsAndPublishPayoutTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOfferFeePayment; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOfferFeePayment;
import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOffererAccount; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.VerifyOffererAccount;
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View file

@ -41,7 +41,7 @@ public class TakerCreatesAndSignsDepositTx extends TakerTradeTask {
assert takerTrade.getTradeAmount() != null; assert takerTrade.getTradeAmount() != null;
Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(takerTrade.getTradeAmount()); Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(takerTrade.getTradeAmount());
Coin msOutputAmount = inputAmount.add(takerTrade.getSecurityDeposit()); Coin msOutputAmount = inputAmount.add(takerTrade.getSecurityDeposit());
TradeWalletService.Result result = takerTradeProcessModel.getTradeWalletService().createAndSignDepositTx( TradeWalletService.Result result = takerTradeProcessModel.getTradeWalletService().createAndSignDepositTx(
inputAmount, inputAmount,
msOutputAmount, msOutputAmount,

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.trade.protocol.trade.offerer.models; package io.bitsquare.trade.protocol.trade.shared.models;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
@ -43,18 +43,19 @@ public class TradingPeer implements Serializable {
// Mutable // Mutable
private String accountId; private String accountId;
private FiatAccount fiatAccount;
private PublicKey p2pSigPubKey; private PublicKey p2pSigPubKey;
private PublicKey p2pEncryptPubKey; private PublicKey p2pEncryptPubKey;
private String contractAsJson; private byte[] tradeWalletPubKey;
private String contractSignature; private FiatAccount fiatAccount;
private Coin payoutAmount;
private Transaction preparedDepositTx; private Transaction preparedDepositTx;
private List<TransactionOutput> connectedOutputsForAllInputs; private List<TransactionOutput> connectedOutputsForAllInputs;
private String payoutAddressString;
private byte[] tradeWalletPubKey;
private List<TransactionOutput> outputs; private List<TransactionOutput> outputs;
private Coin payoutAmount;
private String payoutAddressString;
private byte[] signature; private byte[] signature;
private String contractAsJson;
private String contractSignature;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialization // Constructor, initialization
@ -82,14 +83,6 @@ public class TradingPeer implements Serializable {
this.accountId = accountId; this.accountId = accountId;
} }
public FiatAccount getFiatAccount() {
return fiatAccount;
}
public void setFiatAccount(FiatAccount fiatAccount) {
this.fiatAccount = fiatAccount;
}
public PublicKey getP2pSigPubKey() { public PublicKey getP2pSigPubKey() {
return p2pSigPubKey; return p2pSigPubKey;
} }
@ -106,28 +99,20 @@ public class TradingPeer implements Serializable {
this.p2pEncryptPubKey = p2pEncryptPubKey; this.p2pEncryptPubKey = p2pEncryptPubKey;
} }
public String getContractAsJson() { public byte[] getTradeWalletPubKey() {
return contractAsJson; return tradeWalletPubKey;
} }
public void setContractAsJson(String contractAsJson) { public void setTradeWalletPubKey(byte[] tradeWalletPubKey) {
this.contractAsJson = contractAsJson; this.tradeWalletPubKey = tradeWalletPubKey;
} }
public String getContractSignature() { public FiatAccount getFiatAccount() {
return contractSignature; return fiatAccount;
} }
public void setContractSignature(String contractSignature) { public void setFiatAccount(FiatAccount fiatAccount) {
this.contractSignature = contractSignature; this.fiatAccount = fiatAccount;
}
public Coin getPayoutAmount() {
return payoutAmount;
}
public void setPayoutAmount(Coin payoutAmount) {
this.payoutAmount = payoutAmount;
} }
public Transaction getPreparedDepositTx() { public Transaction getPreparedDepositTx() {
@ -146,22 +131,6 @@ public class TradingPeer implements Serializable {
this.connectedOutputsForAllInputs = connectedOutputsForAllInputs; this.connectedOutputsForAllInputs = connectedOutputsForAllInputs;
} }
public String getPayoutAddressString() {
return payoutAddressString;
}
public void setPayoutAddressString(String payoutAddressString) {
this.payoutAddressString = payoutAddressString;
}
public byte[] getTradeWalletPubKey() {
return tradeWalletPubKey;
}
public void setTradeWalletPubKey(byte[] tradeWalletPubKey) {
this.tradeWalletPubKey = tradeWalletPubKey;
}
public List<TransactionOutput> getOutputs() { public List<TransactionOutput> getOutputs() {
return outputs; return outputs;
} }
@ -170,6 +139,22 @@ public class TradingPeer implements Serializable {
this.outputs = outputs; this.outputs = outputs;
} }
public Coin getPayoutAmount() {
return payoutAmount;
}
public void setPayoutAmount(Coin payoutAmount) {
this.payoutAmount = payoutAmount;
}
public String getPayoutAddressString() {
return payoutAddressString;
}
public void setPayoutAddressString(String payoutAddressString) {
this.payoutAddressString = payoutAddressString;
}
public byte[] getSignature() { public byte[] getSignature() {
return signature; return signature;
} }
@ -178,22 +163,38 @@ public class TradingPeer implements Serializable {
this.signature = signature; this.signature = signature;
} }
@Override public String getContractAsJson() {
public String toString() { return contractAsJson;
return "Taker{" +
"accountId='" + accountId + '\'' +
", fiatAccount=" + fiatAccount +
", p2pSigPubKey=" + p2pSigPubKey +
", p2pEncryptPubKey=" + p2pEncryptPubKey +
", contractAsJson='" + contractAsJson + '\'' +
", contractSignature='" + contractSignature + '\'' +
", payoutAmount=" + payoutAmount +
", preparedDepositTx=" + preparedDepositTx +
", connectedOutputsForAllInputs=" + connectedOutputsForAllInputs +
", payoutAddressString='" + payoutAddressString + '\'' +
", tradeWalletPubKey=" + Arrays.toString(tradeWalletPubKey) +
'}';
} }
public void setContractAsJson(String contractAsJson) {
this.contractAsJson = contractAsJson;
}
public String getContractSignature() {
return contractSignature;
}
public void setContractSignature(String contractSignature) {
this.contractSignature = contractSignature;
}
@Override
public String toString() {
return "TradingPeer{" +
"accountId='" + accountId + '\'' +
", p2pSigPubKey=" + p2pSigPubKey +
", p2pEncryptPubKey=" + p2pEncryptPubKey +
", tradeWalletPubKey=" + Arrays.toString(tradeWalletPubKey) +
", fiatAccount=" + fiatAccount +
", preparedDepositTx=" + preparedDepositTx +
", connectedOutputsForAllInputs=" + connectedOutputsForAllInputs +
", outputs=" + outputs +
", payoutAmount=" + payoutAmount +
", payoutAddressString='" + payoutAddressString + '\'' +
", signature=" + Arrays.toString(signature) +
", contractAsJson='" + contractAsJson + '\'' +
", contractSignature='" + contractSignature + '\'' +
'}';
}
} }

View file

@ -38,7 +38,8 @@ public class VerifyTakerAccount extends OffererTradeTask {
try { try {
//TODO mocked yet //TODO mocked yet
if (offererTradeProcessModel.getBlockChainService().verifyAccountRegistration()) { if (offererTradeProcessModel.getBlockChainService().verifyAccountRegistration()) {
if (offererTradeProcessModel.getBlockChainService().isAccountBlackListed(offererTradeProcessModel.tradingPeer.getAccountId(), offererTradeProcessModel if (offererTradeProcessModel.getBlockChainService().isAccountBlackListed(offererTradeProcessModel.tradingPeer.getAccountId(),
offererTradeProcessModel
.tradingPeer .tradingPeer
.getFiatAccount())) { .getFiatAccount())) {
log.error("Taker is blacklisted"); log.error("Taker is blacklisted");
@ -59,12 +60,12 @@ public class VerifyTakerAccount extends OffererTradeTask {
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
offererTrade.setThrowable(t); offererTrade.setThrowable(t);
if (offererTrade instanceof OffererAsBuyerTrade) if (offererTrade instanceof OffererAsBuyerTrade)
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN); offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
else if (offererTrade instanceof OffererAsSellerTrade) else if (offererTrade instanceof OffererAsSellerTrade)
offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN); offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);
failed(t); failed(t);
} }
} }

View file

@ -52,7 +52,7 @@ public class BroadcastTakeOfferFeeTx extends TakerTradeTask {
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED); takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED);
else if (takerTrade instanceof TakerAsSellerTrade) else if (takerTrade instanceof TakerAsSellerTrade)
takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED); takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED);
complete(); complete();
} }
@Override @Override

View file

@ -27,6 +27,7 @@ import io.bitsquare.fiat.FiatAccount;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.p2p.MessageService; import io.bitsquare.p2p.MessageService;
import io.bitsquare.trade.protocol.trade.ProcessModel; import io.bitsquare.trade.protocol.trade.ProcessModel;
import io.bitsquare.trade.protocol.trade.shared.models.TradingPeer;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;

View file

@ -1,215 +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.taker.models;
import io.bitsquare.fiat.FiatAccount;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionOutput;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Fully serializable, no transient fields
*/
public class TradingPeer implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L;
transient private static final Logger log = LoggerFactory.getLogger(TradingPeer.class);
// Mutable
private byte[] tradeWalletPubKey;
private Coin payoutAmount;
private String payoutAddressString;
private List<TransactionOutput> connectedOutputsForAllInputs;
private List<TransactionOutput> outputs;
private byte[] signature;
private FiatAccount fiatAccount;
private String accountId;
private PublicKey p2pEncryptPubKey;
private String contractAsJson;
private String contractSignature;
private Transaction preparedDepositTx;
private PublicKey p2pSigPubKey;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialization
///////////////////////////////////////////////////////////////////////////////////////////
public TradingPeer() {
log.trace("Created by constructor");
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
log.trace("Created from serialized form.");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getter/Setter for Mutable objects
///////////////////////////////////////////////////////////////////////////////////////////
@Nullable
public byte[] getTradeWalletPubKey() {
return tradeWalletPubKey;
}
public void setTradeWalletPubKey(byte[] tradeWalletPubKey) {
this.tradeWalletPubKey = tradeWalletPubKey;
}
@Nullable
public Coin getPayoutAmount() {
return payoutAmount;
}
public void setPayoutAmount(Coin payoutAmount) {
this.payoutAmount = payoutAmount;
}
@Nullable
public String getPayoutAddressString() {
return payoutAddressString;
}
public void setPayoutAddressString(String payoutAddressString) {
this.payoutAddressString = payoutAddressString;
}
@Nullable
public List<TransactionOutput> getConnectedOutputsForAllInputs() {
return connectedOutputsForAllInputs;
}
public void setConnectedOutputsForAllInputs(List<TransactionOutput> connectedOutputsForAllInputs) {
this.connectedOutputsForAllInputs = connectedOutputsForAllInputs;
}
@Nullable
public List<TransactionOutput> getOutputs() {
return outputs;
}
public void setOutputs(List<TransactionOutput> outputs) {
this.outputs = outputs;
}
@Nullable
public byte[] getSignature() {
return signature;
}
public void setSignature(byte[] signature) {
this.signature = signature;
}
@Nullable
public FiatAccount getFiatAccount() {
return fiatAccount;
}
public void setFiatAccount(FiatAccount fiatAccount) {
this.fiatAccount = fiatAccount;
}
@Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
@Nullable
public PublicKey getP2pEncryptPubKey() {
return p2pEncryptPubKey;
}
public void setP2pEncryptPubKey(PublicKey p2pEncryptPubKey) {
this.p2pEncryptPubKey = p2pEncryptPubKey;
}
@Nullable
public String getContractAsJson() {
return contractAsJson;
}
public void setContractAsJson(String contractAsJson) {
this.contractAsJson = contractAsJson;
}
@Nullable
public String getContractSignature() {
return contractSignature;
}
public void setContractSignature(String contractSignature) {
this.contractSignature = contractSignature;
}
@Nullable
public Transaction getPreparedDepositTx() {
return preparedDepositTx;
}
public void setPreparedDepositTx(Transaction preparedDepositTx) {
this.preparedDepositTx = preparedDepositTx;
}
@Nullable
public PublicKey getP2pSigPubKey() {
return p2pSigPubKey;
}
public void setP2pSigPubKey(PublicKey p2pSigPubKey) {
this.p2pSigPubKey = p2pSigPubKey;
}
@Override
public String toString() {
return "Offerer{" +
"tradeWalletPubKey=" + Arrays.toString(tradeWalletPubKey) +
", payoutAmount=" + payoutAmount +
", payoutAddressString='" + payoutAddressString + '\'' +
", connectedOutputsForAllInputs=" + connectedOutputsForAllInputs +
", outputs=" + outputs +
", signature=" + Arrays.toString(signature) +
", fiatAccount=" + fiatAccount +
", accountId='" + accountId + '\'' +
", p2pSigPubKey=" + p2pSigPubKey +
", p2pEncryptPubKey=" + p2pEncryptPubKey +
'}';
}
}