mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 23:56:30 -04:00
Merge TradingPeer models
This commit is contained in:
parent
33bd09e82c
commit
238f36cffd
@ -90,8 +90,8 @@ public class OffererAsBuyerTrade extends OffererTrade implements Serializable {
|
||||
lifeCycleState = LifeCycleState.OFFER_OPEN;
|
||||
initStateProperties();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Fiat
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -101,7 +101,7 @@ public class OffererAsBuyerTrade extends OffererTrade implements Serializable {
|
||||
((BuyerAsOffererProtocol) protocol).onFiatPaymentStarted();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setter for Mutable objects
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -96,13 +96,12 @@ public abstract class TakerTrade extends Trade implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
abstract public void takeAvailableOffer();
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter only
|
||||
|
@ -37,7 +37,7 @@ public class OffererCommitsPayoutTx extends OffererTradeTask {
|
||||
protected void doRun() {
|
||||
try {
|
||||
Transaction transaction = offererTradeProcessModel.getTradeWalletService().commitTx(offererTrade.getPayoutTx());
|
||||
|
||||
|
||||
offererTrade.setPayoutTx(transaction);
|
||||
|
||||
complete();
|
||||
|
@ -40,7 +40,7 @@ public class OffererCreatesAndSignPayoutTx extends OffererTradeTask {
|
||||
Coin securityDeposit = offererTrade.getSecurityDeposit();
|
||||
Coin offererPayoutAmount = securityDeposit.add(offererTrade.getTradeAmount());
|
||||
Coin takerPayoutAmount = securityDeposit;
|
||||
|
||||
|
||||
byte[] offererPayoutTxSignature = offererTradeProcessModel.getTradeWalletService().createAndSignPayoutTx(
|
||||
offererTrade.getDepositTx(),
|
||||
offererPayoutAmount,
|
||||
|
@ -50,7 +50,7 @@ public class OffererProcessPayoutTxPublishedMessage extends OffererTradeTask {
|
||||
offererTrade.setProcessState(OffererAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED);
|
||||
else if (offererTrade instanceof OffererAsSellerTrade)
|
||||
offererTrade.setProcessState(OffererAsSellerTrade.ProcessState.PAYOUT_PUBLISHED);
|
||||
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
@ -52,7 +52,7 @@ public class OffererProcessRequestDepositTxInputsMessage extends OffererTradeTas
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
offererTrade.setThrowable(t);
|
||||
|
||||
|
||||
if (offererTrade instanceof OffererAsBuyerTrade)
|
||||
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
|
||||
else if (offererTrade instanceof OffererAsSellerTrade)
|
||||
|
@ -58,7 +58,7 @@ public class OffererSendsFiatTransferStartedMessage extends OffererTradeTask {
|
||||
else if (offererTrade instanceof OffererAsSellerTrade) {
|
||||
((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.FIAT_PAYMENT_STARTED);
|
||||
}
|
||||
|
||||
|
||||
complete();
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class OffererSendsFiatTransferStartedMessage extends OffererTradeTask {
|
||||
else if (offererTrade instanceof OffererAsSellerTrade) {
|
||||
((OffererAsSellerTrade) offererTrade).setProcessState(OffererAsSellerTrade.ProcessState.MESSAGE_SENDING_FAILED);
|
||||
}
|
||||
|
||||
|
||||
failed();
|
||||
}
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ public class OffererSendsRequestSellerDepositPaymentMessage extends OffererTrade
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
offererTrade.setThrowable(t);
|
||||
|
||||
|
||||
if (offererTrade instanceof OffererAsBuyerTrade) {
|
||||
((OffererAsBuyerTrade) offererTrade).setProcessState(OffererAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED);
|
||||
((OffererAsSellerTrade) offererTrade).setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);
|
||||
|
@ -66,7 +66,7 @@ public class OffererVerifiesAndSignsContract extends OffererTradeTask {
|
||||
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
|
||||
else if (offererTrade instanceof OffererAsSellerTrade)
|
||||
offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);
|
||||
|
||||
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,6 @@ import io.bitsquare.p2p.MessageHandler;
|
||||
import io.bitsquare.p2p.Peer;
|
||||
import io.bitsquare.trade.TakerAsBuyerTrade;
|
||||
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.TakerCreatesAndSignsPayoutTx;
|
||||
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.TakerSignsAndPublishDepositTx;
|
||||
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.VerifyOffererAccount;
|
||||
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -37,7 +37,7 @@ public class TakerCommitsPayoutTx extends TakerTradeTask {
|
||||
protected void doRun() {
|
||||
try {
|
||||
Transaction transaction = takerTradeProcessModel.getTradeWalletService().commitTx(takerTrade.getPayoutTx());
|
||||
|
||||
|
||||
takerTrade.setPayoutTx(transaction);
|
||||
|
||||
complete();
|
||||
|
@ -42,7 +42,7 @@ public class TakerCreatesAndSignsPayoutTx extends TakerTradeTask {
|
||||
Coin offererPayoutAmount = securityDeposit;
|
||||
Coin takerPayoutAmount = securityDeposit.add(takerTrade.getTradeAmount());
|
||||
|
||||
|
||||
|
||||
byte[] takerPayoutTxSignature = takerTradeProcessModel.getTradeWalletService().createAndSignPayoutTx(
|
||||
takerTrade.getDepositTx(),
|
||||
takerPayoutAmount,
|
||||
|
@ -50,7 +50,7 @@ public class TakerProcessPayoutTxPublishedMessage extends TakerTradeTask {
|
||||
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.PAYOUT_PUBLISHED);
|
||||
else if (takerTrade instanceof TakerAsSellerTrade)
|
||||
takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.PAYOUT_PUBLISHED);
|
||||
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
@ -71,7 +71,7 @@ public class TakerSendsRequestDepositTxInputsMessage extends TakerTradeTask {
|
||||
"or cancel that trade.");
|
||||
|
||||
takerTrade.setErrorMessage(errorMessage);
|
||||
|
||||
|
||||
if (takerTrade instanceof TakerAsBuyerTrade)
|
||||
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.MESSAGE_SENDING_FAILED);
|
||||
else if (takerTrade instanceof TakerAsSellerTrade)
|
||||
|
@ -45,7 +45,7 @@ public class TakerSignsAndPublishDepositTx extends TakerTradeTask {
|
||||
protected void doRun() {
|
||||
try {
|
||||
Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE);
|
||||
|
||||
|
||||
takerTradeProcessModel.getTradeWalletService().signAndPublishDepositTx(
|
||||
takerTradeProcessModel.tradingPeer.getPreparedDepositTx(),
|
||||
takerTradeProcessModel.getConnectedOutputsForAllInputs(),
|
||||
|
@ -27,6 +27,7 @@ import io.bitsquare.fiat.FiatAccount;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.p2p.MessageService;
|
||||
import io.bitsquare.trade.protocol.trade.ProcessModel;
|
||||
import io.bitsquare.trade.protocol.trade.shared.models.TradingPeer;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -48,7 +48,7 @@ public class OffererCreatesAndSignsContract extends OffererTradeTask {
|
||||
offererTradeProcessModel.getOffer().getP2PSigPubKey(),
|
||||
offererTradeProcessModel.getP2pSigPubKey());
|
||||
String contractAsJson = Utilities.objectToJson(contract);
|
||||
String signature = offererTradeProcessModel.getSignatureService().signMessage(offererTradeProcessModel.getRegistrationKeyPair(),
|
||||
String signature = offererTradeProcessModel.getSignatureService().signMessage(offererTradeProcessModel.getRegistrationKeyPair(),
|
||||
contractAsJson);
|
||||
|
||||
model.setContract(contract);
|
||||
|
@ -41,7 +41,7 @@ public class OffererCreatesAndSignsDepositTx extends OffererTradeTask {
|
||||
assert offererTrade.getTradeAmount() != null;
|
||||
Coin inputAmount = offererTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(offererTrade.getTradeAmount());
|
||||
Coin msOutputAmount = inputAmount.add(offererTrade.getSecurityDeposit());
|
||||
|
||||
|
||||
TradeWalletService.Result result = offererTradeProcessModel.getTradeWalletService().createAndSignDepositTx(
|
||||
inputAmount,
|
||||
msOutputAmount,
|
||||
|
@ -25,25 +25,25 @@ import io.bitsquare.p2p.Peer;
|
||||
import io.bitsquare.trade.TakerAsSellerTrade;
|
||||
import io.bitsquare.trade.TakerTrade;
|
||||
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.FiatTransferStartedMessage;
|
||||
import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage;
|
||||
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.TakerCreatesAndSignContract;
|
||||
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.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.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.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.VerifyOffererAccount;
|
||||
import io.bitsquare.trade.protocol.trade.taker.models.TakerProcessModel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -41,7 +41,7 @@ public class TakerCreatesAndSignsDepositTx extends TakerTradeTask {
|
||||
assert takerTrade.getTradeAmount() != null;
|
||||
Coin inputAmount = takerTrade.getSecurityDeposit().add(FeePolicy.TX_FEE).add(takerTrade.getTradeAmount());
|
||||
Coin msOutputAmount = inputAmount.add(takerTrade.getSecurityDeposit());
|
||||
|
||||
|
||||
TradeWalletService.Result result = takerTradeProcessModel.getTradeWalletService().createAndSignDepositTx(
|
||||
inputAmount,
|
||||
msOutputAmount,
|
||||
|
@ -15,7 +15,7 @@
|
||||
* 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;
|
||||
|
||||
@ -43,18 +43,19 @@ public class TradingPeer implements Serializable {
|
||||
|
||||
// Mutable
|
||||
private String accountId;
|
||||
private FiatAccount fiatAccount;
|
||||
private PublicKey p2pSigPubKey;
|
||||
private PublicKey p2pEncryptPubKey;
|
||||
private String contractAsJson;
|
||||
private String contractSignature;
|
||||
private Coin payoutAmount;
|
||||
private byte[] tradeWalletPubKey;
|
||||
private FiatAccount fiatAccount;
|
||||
private Transaction preparedDepositTx;
|
||||
private List<TransactionOutput> connectedOutputsForAllInputs;
|
||||
private String payoutAddressString;
|
||||
private byte[] tradeWalletPubKey;
|
||||
private List<TransactionOutput> outputs;
|
||||
private Coin payoutAmount;
|
||||
private String payoutAddressString;
|
||||
private byte[] signature;
|
||||
private String contractAsJson;
|
||||
private String contractSignature;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, initialization
|
||||
@ -82,14 +83,6 @@ public class TradingPeer implements Serializable {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public FiatAccount getFiatAccount() {
|
||||
return fiatAccount;
|
||||
}
|
||||
|
||||
public void setFiatAccount(FiatAccount fiatAccount) {
|
||||
this.fiatAccount = fiatAccount;
|
||||
}
|
||||
|
||||
public PublicKey getP2pSigPubKey() {
|
||||
return p2pSigPubKey;
|
||||
}
|
||||
@ -106,28 +99,20 @@ public class TradingPeer implements Serializable {
|
||||
this.p2pEncryptPubKey = p2pEncryptPubKey;
|
||||
}
|
||||
|
||||
public String getContractAsJson() {
|
||||
return contractAsJson;
|
||||
public byte[] getTradeWalletPubKey() {
|
||||
return tradeWalletPubKey;
|
||||
}
|
||||
|
||||
public void setContractAsJson(String contractAsJson) {
|
||||
this.contractAsJson = contractAsJson;
|
||||
public void setTradeWalletPubKey(byte[] tradeWalletPubKey) {
|
||||
this.tradeWalletPubKey = tradeWalletPubKey;
|
||||
}
|
||||
|
||||
public String getContractSignature() {
|
||||
return contractSignature;
|
||||
public FiatAccount getFiatAccount() {
|
||||
return fiatAccount;
|
||||
}
|
||||
|
||||
public void setContractSignature(String contractSignature) {
|
||||
this.contractSignature = contractSignature;
|
||||
}
|
||||
|
||||
public Coin getPayoutAmount() {
|
||||
return payoutAmount;
|
||||
}
|
||||
|
||||
public void setPayoutAmount(Coin payoutAmount) {
|
||||
this.payoutAmount = payoutAmount;
|
||||
public void setFiatAccount(FiatAccount fiatAccount) {
|
||||
this.fiatAccount = fiatAccount;
|
||||
}
|
||||
|
||||
public Transaction getPreparedDepositTx() {
|
||||
@ -146,22 +131,6 @@ public class TradingPeer implements Serializable {
|
||||
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() {
|
||||
return outputs;
|
||||
}
|
||||
@ -170,6 +139,22 @@ public class TradingPeer implements Serializable {
|
||||
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() {
|
||||
return signature;
|
||||
}
|
||||
@ -178,22 +163,38 @@ public class TradingPeer implements Serializable {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
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 String getContractAsJson() {
|
||||
return contractAsJson;
|
||||
}
|
||||
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -38,7 +38,8 @@ public class VerifyTakerAccount extends OffererTradeTask {
|
||||
try {
|
||||
//TODO mocked yet
|
||||
if (offererTradeProcessModel.getBlockChainService().verifyAccountRegistration()) {
|
||||
if (offererTradeProcessModel.getBlockChainService().isAccountBlackListed(offererTradeProcessModel.tradingPeer.getAccountId(), offererTradeProcessModel
|
||||
if (offererTradeProcessModel.getBlockChainService().isAccountBlackListed(offererTradeProcessModel.tradingPeer.getAccountId(),
|
||||
offererTradeProcessModel
|
||||
.tradingPeer
|
||||
.getFiatAccount())) {
|
||||
log.error("Taker is blacklisted");
|
||||
@ -59,12 +60,12 @@ public class VerifyTakerAccount extends OffererTradeTask {
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
offererTrade.setThrowable(t);
|
||||
|
||||
|
||||
if (offererTrade instanceof OffererAsBuyerTrade)
|
||||
offererTrade.setLifeCycleState(OffererAsBuyerTrade.LifeCycleState.OFFER_OPEN);
|
||||
else if (offererTrade instanceof OffererAsSellerTrade)
|
||||
offererTrade.setLifeCycleState(OffererAsSellerTrade.LifeCycleState.OFFER_OPEN);
|
||||
|
||||
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class BroadcastTakeOfferFeeTx extends TakerTradeTask {
|
||||
takerTrade.setProcessState(TakerAsBuyerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED);
|
||||
else if (takerTrade instanceof TakerAsSellerTrade)
|
||||
takerTrade.setProcessState(TakerAsSellerTrade.ProcessState.TAKE_OFFER_FEE_PUBLISHED);
|
||||
complete();
|
||||
complete();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import io.bitsquare.fiat.FiatAccount;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.p2p.MessageService;
|
||||
import io.bitsquare.trade.protocol.trade.ProcessModel;
|
||||
import io.bitsquare.trade.protocol.trade.shared.models.TradingPeer;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user