diff --git a/core/src/main/java/io/bitsquare/gui/main/debug/DebugView.java b/core/src/main/java/io/bitsquare/gui/main/debug/DebugView.java index 07803a6ad0..d4461ba103 100644 --- a/core/src/main/java/io/bitsquare/gui/main/debug/DebugView.java +++ b/core/src/main/java/io/bitsquare/gui/main/debug/DebugView.java @@ -28,27 +28,25 @@ import io.bitsquare.trade.protocol.placeoffer.tasks.AddOfferToRemoteOfferBook; import io.bitsquare.trade.protocol.placeoffer.tasks.BroadcastCreateOfferFeeTx; import io.bitsquare.trade.protocol.placeoffer.tasks.CreateOfferFeeTx; import io.bitsquare.trade.protocol.placeoffer.tasks.ValidateOffer; -import io.bitsquare.trade.protocol.trade.buyer.offerer.BuyerAsOffererProtocol; -import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestDepositTxInputsMessage; -import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestPublishDepositTxMessage; -import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestDepositTxInputsMessage; -import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPublishDepositTxMessage; +import io.bitsquare.trade.protocol.trade.buyer.BuyerAsOffererProtocol; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSignsAndPublishDepositTx; -import io.bitsquare.trade.protocol.trade.seller.taker.SellerAsTakerProtocol; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCommitDepositTx; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignContract; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerCreatesAndSignsDepositTx; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessDepositTxPublishedMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessFiatTransferStartedMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerProcessRequestPayDepositMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSendsPayoutTxPublishedMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSignsAndPublishPayoutTx; +import io.bitsquare.trade.protocol.trade.buyer.tasks.ProcessRequestDepositTxInputsMessage; +import io.bitsquare.trade.protocol.trade.seller.SellerAsTakerProtocol; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx; +import io.bitsquare.trade.protocol.trade.seller.tasks.SendRequestDepositTxInputsMessage; import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakeOfferFeePayment; import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakerAccount; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx; @@ -100,11 +98,11 @@ public class DebugView extends InitializableView { /*---- Protocol ----*/ BuyerAsOffererProtocol.class, - OffererProcessRequestDepositTxInputsMessage.class, + ProcessRequestDepositTxInputsMessage.class, BuyerCreatesDepositTxInputs.class, BuyerSendsRequestPayDepositMessage.class, - OffererProcessRequestPublishDepositTxMessage.class, + BuyerProcessRequestPublishDepositTxMessage.class, VerifyTakerAccount.class, BuyerSignsAndPublishDepositTx.class, BuyerSendsDepositTxPublishedMessage.class, @@ -120,22 +118,20 @@ public class DebugView extends InitializableView { /*---- Protocol ----*/ SellerAsTakerProtocol.class, CreateTakeOfferFeeTx.class, - TakerSendsRequestDepositTxInputsMessage.class, + SendRequestDepositTxInputsMessage.class, - TakerProcessRequestPayDepositMessage.class, + SellerProcessRequestPayDepositMessage.class, VerifyOffererAccount.class, - TakerCreatesAndSignContract.class, - TakerCreatesAndSignsDepositTx.class, - TakerSendsRequestPublishDepositTxMessage.class, + SellerCreatesAndSignsDepositTx.class, - TakerProcessDepositTxPublishedMessage.class, - TakerCommitDepositTx.class, + SellerProcessDepositTxPublishedMessage.class, + SellerCommitDepositTx.class, - TakerProcessFiatTransferStartedMessage.class, + SellerProcessFiatTransferStartedMessage.class, - TakerSignsAndPublishPayoutTx.class, + SellerSignsAndPublishPayoutTx.class, VerifyOfferFeePayment.class, - TakerSendsPayoutTxPublishedMessage.class + SellerSendsPayoutTxPublishedMessage.class ) ); diff --git a/core/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesDataModel.java b/core/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesDataModel.java index dfe522eceb..219f04f890 100644 --- a/core/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesDataModel.java +++ b/core/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesDataModel.java @@ -64,7 +64,7 @@ class ClosedTradesDataModel implements Activatable, DataModel { } public Offer.Direction getDirection(Offer offer) { - return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ? + return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ? offer.getDirection() : offer.getMirroredDirection(); } diff --git a/core/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersDataModel.java b/core/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersDataModel.java index ed0ea81cfb..afd467db94 100644 --- a/core/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersDataModel.java +++ b/core/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersDataModel.java @@ -75,7 +75,7 @@ class OffersDataModel implements Activatable, DataModel { } public Offer.Direction getDirection(Offer offer) { - return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ? + return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ? offer.getDirection() : offer.getMirroredDirection(); } diff --git a/core/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesDataModel.java b/core/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesDataModel.java index d4b3ad002b..9f08bd923e 100644 --- a/core/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesDataModel.java +++ b/core/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesDataModel.java @@ -135,7 +135,7 @@ class PendingTradesDataModel implements Activatable, DataModel { currentTrade.set(item.getTrade()); Trade trade = item.getTrade(); - isOfferer = trade.getOffer().getP2PSigPubKey().equals(user.getP2PSigPubKey()); + isOfferer = trade.getOffer().getP2pSigPubKey().equals(user.getP2pSigPubKey()); if (trade instanceof SellerAsTakerTrade) takerAsSellerProcessState.bind(trade.processStateProperty()); else if (trade instanceof BuyerAsOffererTrade) @@ -248,7 +248,7 @@ class PendingTradesDataModel implements Activatable, DataModel { } public Offer.Direction getDirection(Offer offer) { - return offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()) ? + return offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()) ? offer.getDirection() : offer.getMirroredDirection(); } diff --git a/core/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookDataModel.java b/core/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookDataModel.java index 2decfdf69d..a5b0f55fe8 100644 --- a/core/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookDataModel.java +++ b/core/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookDataModel.java @@ -211,7 +211,7 @@ class OfferBookDataModel implements Activatable, DataModel { } boolean isMyOffer(Offer offer) { - return offer.getP2PSigPubKey() != null && offer.getP2PSigPubKey().equals(user.getP2PSigPubKey()); + return offer.getP2pSigPubKey() != null && offer.getP2pSigPubKey().equals(user.getP2pSigPubKey()); } Coin getAmountAsCoin() { diff --git a/core/src/main/java/io/bitsquare/offer/Offer.java b/core/src/main/java/io/bitsquare/offer/Offer.java index 2deff1a0a4..6868f2a2e8 100644 --- a/core/src/main/java/io/bitsquare/offer/Offer.java +++ b/core/src/main/java/io/bitsquare/offer/Offer.java @@ -144,7 +144,7 @@ public class Offer implements Serializable { checkNotNull(getCurrencyCode(), "Currency is null"); checkNotNull(getDirection(), "Direction is null"); checkNotNull(getId(), "Id is null"); - checkNotNull(getP2PSigPubKey(), "p2pSigPubKey is null"); + checkNotNull(getP2pSigPubKey(), "p2pSigPubKey is null"); checkNotNull(getMinAmount(), "MinAmount is null"); checkNotNull(getPrice(), "Price is null"); @@ -255,7 +255,7 @@ public class Offer implements Serializable { return bankAccountUID; } - public PublicKey getP2PSigPubKey() { + public PublicKey getP2pSigPubKey() { return p2pSigPubKey; } diff --git a/core/src/main/java/io/bitsquare/trade/BuyerAsOffererTrade.java b/core/src/main/java/io/bitsquare/trade/BuyerAsOffererTrade.java index f7e893d439..14525b0f7e 100644 --- a/core/src/main/java/io/bitsquare/trade/BuyerAsOffererTrade.java +++ b/core/src/main/java/io/bitsquare/trade/BuyerAsOffererTrade.java @@ -19,7 +19,7 @@ package io.bitsquare.trade; import io.bitsquare.offer.Offer; import io.bitsquare.storage.Storage; -import io.bitsquare.trade.protocol.trade.buyer.offerer.BuyerAsOffererProtocol; +import io.bitsquare.trade.protocol.trade.buyer.BuyerAsOffererProtocol; import io.bitsquare.trade.states.OffererState; import io.bitsquare.trade.states.TradeState; diff --git a/core/src/main/java/io/bitsquare/trade/BuyerAsTakerTrade.java b/core/src/main/java/io/bitsquare/trade/BuyerAsTakerTrade.java index 482e2c05bc..8f24935048 100644 --- a/core/src/main/java/io/bitsquare/trade/BuyerAsTakerTrade.java +++ b/core/src/main/java/io/bitsquare/trade/BuyerAsTakerTrade.java @@ -20,7 +20,7 @@ package io.bitsquare.trade; import io.bitsquare.offer.Offer; import io.bitsquare.p2p.Peer; import io.bitsquare.storage.Storage; -import io.bitsquare.trade.protocol.trade.buyer.taker.BuyerAsTakerProtocol; +import io.bitsquare.trade.protocol.trade.buyer.BuyerAsTakerProtocol; import io.bitsquare.trade.states.TakerState; import io.bitsquare.trade.states.TradeState; diff --git a/core/src/main/java/io/bitsquare/trade/Contract.java b/core/src/main/java/io/bitsquare/trade/Contract.java index af1bb8fc76..a29afa7275 100644 --- a/core/src/main/java/io/bitsquare/trade/Contract.java +++ b/core/src/main/java/io/bitsquare/trade/Contract.java @@ -42,8 +42,8 @@ public class Contract implements Serializable { public final String sellerAccountID; public final FiatAccount buyerFiatAccount; public final FiatAccount sellerFiatAccount; - public final String buyerP2PSigPubKeyAsString; - public final String sellerP2PSigPubKeyAsString; + public final String buyerP2pSigPubKeyAsString; + public final String sellerP2pSigPubKeyAsString; public Contract(Offer offer, Coin tradeAmount, @@ -52,8 +52,8 @@ public class Contract implements Serializable { String sellerAccountID, FiatAccount buyerFiatAccount, FiatAccount sellerFiatAccount, - PublicKey buyerP2PSigPubKey, - PublicKey sellerP2PSigPubKey) { + PublicKey buyerP2pSigPubKey, + PublicKey sellerP2pSigPubKey) { this.offer = offer; this.tradeAmount = tradeAmount; this.takeOfferFeeTxID = takeOfferFeeTxID; @@ -61,8 +61,8 @@ public class Contract implements Serializable { this.sellerAccountID = sellerAccountID; this.buyerFiatAccount = buyerFiatAccount; this.sellerFiatAccount = sellerFiatAccount; - this.buyerP2PSigPubKeyAsString = Utilities.getHexFromPubKey(buyerP2PSigPubKey); - this.sellerP2PSigPubKeyAsString = Utilities.getHexFromPubKey(sellerP2PSigPubKey); + this.buyerP2pSigPubKeyAsString = Utilities.getHexFromPubKey(buyerP2pSigPubKey); + this.sellerP2pSigPubKeyAsString = Utilities.getHexFromPubKey(sellerP2pSigPubKey); } @Override @@ -75,8 +75,8 @@ public class Contract implements Serializable { ", sellerAccountID='" + sellerAccountID + '\'' + ", buyerFiatAccount=" + buyerFiatAccount + ", sellerFiatAccount=" + sellerFiatAccount + - ", buyerP2PSigPubKeyAsString='" + buyerP2PSigPubKeyAsString + '\'' + - ", sellerP2PSigPubKeyAsString='" + sellerP2PSigPubKeyAsString + '\'' + + ", buyerP2pSigPubKeyAsString='" + buyerP2pSigPubKeyAsString + '\'' + + ", sellerP2pSigPubKeyAsString='" + sellerP2pSigPubKeyAsString + '\'' + '}'; } } diff --git a/core/src/main/java/io/bitsquare/trade/SellerAsOffererTrade.java b/core/src/main/java/io/bitsquare/trade/SellerAsOffererTrade.java index 5a997010e4..317e0ce236 100644 --- a/core/src/main/java/io/bitsquare/trade/SellerAsOffererTrade.java +++ b/core/src/main/java/io/bitsquare/trade/SellerAsOffererTrade.java @@ -19,7 +19,7 @@ package io.bitsquare.trade; import io.bitsquare.offer.Offer; import io.bitsquare.storage.Storage; -import io.bitsquare.trade.protocol.trade.seller.offerer.SellerAsOffererProtocol; +import io.bitsquare.trade.protocol.trade.seller.SellerAsOffererProtocol; import io.bitsquare.trade.states.OffererState; import io.bitsquare.trade.states.TradeState; diff --git a/core/src/main/java/io/bitsquare/trade/SellerAsTakerTrade.java b/core/src/main/java/io/bitsquare/trade/SellerAsTakerTrade.java index 69f272d545..b5e4702a6e 100644 --- a/core/src/main/java/io/bitsquare/trade/SellerAsTakerTrade.java +++ b/core/src/main/java/io/bitsquare/trade/SellerAsTakerTrade.java @@ -20,7 +20,7 @@ package io.bitsquare.trade; import io.bitsquare.offer.Offer; import io.bitsquare.p2p.Peer; import io.bitsquare.storage.Storage; -import io.bitsquare.trade.protocol.trade.seller.taker.SellerAsTakerProtocol; +import io.bitsquare.trade.protocol.trade.seller.SellerAsTakerProtocol; import io.bitsquare.trade.states.TakerState; import io.bitsquare.trade.states.TradeState; diff --git a/core/src/main/java/io/bitsquare/trade/TradeManager.java b/core/src/main/java/io/bitsquare/trade/TradeManager.java index 0189aac617..37d29c2b27 100644 --- a/core/src/main/java/io/bitsquare/trade/TradeManager.java +++ b/core/src/main/java/io/bitsquare/trade/TradeManager.java @@ -190,7 +190,7 @@ public class TradeManager { } // if there are messages in our mailbox we apply it and remove them from the DHT - mailboxService.getAllMessages(user.getP2PSigPubKey(), + mailboxService.getAllMessages(user.getP2pSigPubKey(), (encryptedMailboxMessages) -> { setMailboxMessagesToTrades(encryptedMailboxMessages); emptyMailbox(); @@ -217,7 +217,7 @@ public class TradeManager { } private void emptyMailbox() { - mailboxService.removeAllMessages(user.getP2PSigPubKey(), + mailboxService.removeAllMessages(user.getP2pSigPubKey(), () -> log.debug("All mailbox entries removed"), (errorMessage, fault) -> { log.error(errorMessage); @@ -252,7 +252,7 @@ public class TradeManager { FiatAccount fiatAccount = user.currentFiatAccountProperty().get(); Offer offer = new Offer(id, - user.getP2PSigPubKey(), + user.getP2pSigPubKey(), direction, price.getValue(), amount, diff --git a/core/src/main/java/io/bitsquare/trade/protocol/availability/tasks/GetPeerAddress.java b/core/src/main/java/io/bitsquare/trade/protocol/availability/tasks/GetPeerAddress.java index 85d8b18376..3032fe6653 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/availability/tasks/GetPeerAddress.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/availability/tasks/GetPeerAddress.java @@ -39,7 +39,7 @@ public class GetPeerAddress extends Task { @Override protected void doRun() { try { - model.addressService.findPeerAddress(model.offer.getP2PSigPubKey(), new GetPeerAddressListener() { + model.addressService.findPeerAddress(model.offer.getP2pSigPubKey(), new GetPeerAddressListener() { @Override public void onResult(Peer peer) { model.setPeer(peer); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/StateUtil.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/StateUtil.java similarity index 97% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/StateUtil.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/StateUtil.java index acf7391988..1ff02a34a7 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/StateUtil.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/StateUtil.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.tasks; +package io.bitsquare.trade.protocol.trade; import io.bitsquare.trade.BuyerAsOffererTrade; import io.bitsquare.trade.BuyerAsTakerTrade; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/BuyerAsOffererProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsOffererProtocol.java similarity index 96% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/BuyerAsOffererProtocol.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsOffererProtocol.java index cc2cde9f7a..4f77c9e543 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/BuyerAsOffererProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsOffererProtocol.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.offerer; +package io.bitsquare.trade.protocol.trade.buyer; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.MailboxMessage; @@ -27,17 +27,17 @@ import io.bitsquare.trade.BuyerAsOffererTrade; import io.bitsquare.trade.protocol.availability.messages.ReportOfferAvailabilityMessage; import io.bitsquare.trade.protocol.availability.messages.RequestIsOfferAvailableMessage; import io.bitsquare.trade.protocol.trade.TradeProtocol; -import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestDepositTxInputsMessage; -import io.bitsquare.trade.protocol.trade.buyer.offerer.tasks.OffererProcessRequestPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCommitsPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSignsAndPublishDepositTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerVerifiesAndSignsContract; +import io.bitsquare.trade.protocol.trade.buyer.tasks.ProcessRequestDepositTxInputsMessage; import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage; import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage; import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage; @@ -143,7 +143,7 @@ public class BuyerAsOffererProtocol implements TradeProtocol { () -> log.debug("taskRunner at handleRequestDepositTxInputsMessage completed"), this::handleTaskRunnerFault); taskRunner.addTasks( - OffererProcessRequestDepositTxInputsMessage.class, + ProcessRequestDepositTxInputsMessage.class, BuyerCreatesDepositTxInputs.class, BuyerSendsRequestPayDepositMessage.class ); @@ -157,7 +157,7 @@ public class BuyerAsOffererProtocol implements TradeProtocol { () -> log.debug("taskRunner at handleRequestPublishDepositTxMessage completed"), this::handleTaskRunnerFault); taskRunner.addTasks( - OffererProcessRequestPublishDepositTxMessage.class, + BuyerProcessRequestPublishDepositTxMessage.class, VerifyTakerAccount.class, BuyerVerifiesAndSignsContract.class, BuyerSignsAndPublishDepositTx.class, diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/BuyerAsTakerProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsTakerProtocol.java similarity index 97% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/BuyerAsTakerProtocol.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsTakerProtocol.java index e2f70084a2..336ef1b2d2 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/BuyerAsTakerProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/BuyerAsTakerProtocol.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.taker; +package io.bitsquare.trade.protocol.trade.buyer; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.MailboxMessage; @@ -24,11 +24,11 @@ import io.bitsquare.p2p.MessageHandler; import io.bitsquare.p2p.Peer; import io.bitsquare.trade.BuyerAsTakerTrade; import io.bitsquare.trade.protocol.trade.TradeProtocol; -import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerProcessRequestPublishDepositTxFromSellerMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCommitsPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesAndSignPayoutTx; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerCreatesDepositTxInputs; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerProcessRequestPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsDepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsFiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.buyer.tasks.BuyerSendsRequestPayDepositMessage; @@ -119,7 +119,7 @@ public class BuyerAsTakerProtocol implements TradeProtocol { () -> log.debug("taskRunner at handleRequestPublishDepositTxMessage completed"), this::handleTaskRunnerFault); taskRunner.addTasks( - TakerProcessRequestPublishDepositTxFromSellerMessage.class, + BuyerProcessRequestPublishDepositTxMessage.class, VerifyOffererAccount.class, BuyerVerifiesAndSignsContract.class, BuyerSignsAndPublishDepositTx.class, diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerProcessRequestPublishDepositTxFromSellerMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerProcessRequestPublishDepositTxFromSellerMessage.java deleted file mode 100644 index d8aa790c82..0000000000 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerProcessRequestPublishDepositTxFromSellerMessage.java +++ /dev/null @@ -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 . - */ - -package io.bitsquare.trade.protocol.trade.buyer.taker.tasks; - -import io.bitsquare.common.taskrunner.TaskRunner; -import io.bitsquare.trade.Trade; -import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxFromSellerMessage; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static com.google.common.base.Preconditions.*; -import static io.bitsquare.util.Validator.*; - -public class TakerProcessRequestPublishDepositTxFromSellerMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(TakerProcessRequestPublishDepositTxFromSellerMessage.class); - - public TakerProcessRequestPublishDepositTxFromSellerMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void doRun() { - try { - RequestPublishDepositTxFromSellerMessage message = (RequestPublishDepositTxFromSellerMessage) processModel.getTradeMessage(); - checkTradeId(processModel.getId(), message); - checkNotNull(message); - - processModel.tradingPeer.setFiatAccount(checkNotNull(message.takerFiatAccount)); - processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.takerAccountId)); - processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey)); - processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey)); - processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey)); - processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.takerP2PEncryptPublicKey)); - processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.takerContractAsJson)); - processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.takerContractSignature)); - processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.takerPayoutAddressString)); - processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.takersPreparedDepositTx)); - processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.takerConnectedOutputsForAllInputs)); - checkArgument(message.takerConnectedOutputsForAllInputs.size() > 0); - - complete(); - } catch (Throwable t) { - t.printStackTrace(); - trade.setThrowable(t); - - failed(t); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerCreatesDepositTxInputs.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerCreatesDepositTxInputs.java index 18a823bc66..e52116528c 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerCreatesDepositTxInputs.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerCreatesDepositTxInputs.java @@ -21,6 +21,7 @@ import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.TradeWalletService; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import org.bitcoinj.core.Coin; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestPublishDepositTxMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerProcessRequestPublishDepositTxMessage.java similarity index 69% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestPublishDepositTxMessage.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerProcessRequestPublishDepositTxMessage.java index 78ce090958..18287049c1 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestPublishDepositTxMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerProcessRequestPublishDepositTxMessage.java @@ -15,12 +15,12 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.offerer.tasks; +package io.bitsquare.trade.protocol.trade.buyer.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil; import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage; import org.slf4j.Logger; @@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory; import static com.google.common.base.Preconditions.*; import static io.bitsquare.util.Validator.*; -public class OffererProcessRequestPublishDepositTxMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(OffererProcessRequestPublishDepositTxMessage.class); +public class BuyerProcessRequestPublishDepositTxMessage extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(BuyerProcessRequestPublishDepositTxMessage.class); - public OffererProcessRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) { + public BuyerProcessRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -43,16 +43,17 @@ public class OffererProcessRequestPublishDepositTxMessage extends TradeTask { checkTradeId(processModel.getId(), message); checkNotNull(message); - processModel.tradingPeer.setFiatAccount(checkNotNull(message.takerFiatAccount)); - processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.takerAccountId)); - processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.takerP2PSigPublicKey)); - processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.takerP2PEncryptPublicKey)); - processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.takerContractAsJson)); - processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.takerContractSignature)); - processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.takerPayoutAddressString)); - processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.takersPreparedDepositTx)); - processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.takerConnectedOutputsForAllInputs)); - checkArgument(message.takerConnectedOutputsForAllInputs.size() > 0); + processModel.tradingPeer.setFiatAccount(checkNotNull(message.sellerFiatAccount)); + processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.sellerAccountId)); + processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.sellerP2pSigPublicKey)); + processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey)); + processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.sellerP2pEncryptPublicKey)); + processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(message.sellerContractAsJson)); + processModel.tradingPeer.setContractSignature(nonEmptyStringOf(message.sellerContractSignature)); + processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.sellerPayoutAddressString)); + processModel.tradingPeer.setPreparedDepositTx(checkNotNull(message.sellersPreparedDepositTx)); + processModel.tradingPeer.setConnectedOutputsForAllInputs(checkNotNull(message.sellerConnectedOutputsForAllInputs)); + checkArgument(message.sellerConnectedOutputsForAllInputs.size() > 0); complete(); } catch (Throwable t) { diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsDepositTxPublishedMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsDepositTxPublishedMessage.java index c955ced0f1..5b97bab99c 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsDepositTxPublishedMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsDepositTxPublishedMessage.java @@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.listener.SendMessageListener; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsFiatTransferStartedMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsFiatTransferStartedMessage.java index 8d6f4f819a..f13238d774 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsFiatTransferStartedMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsFiatTransferStartedMessage.java @@ -24,6 +24,7 @@ import io.bitsquare.trade.BuyerAsTakerTrade; import io.bitsquare.trade.SellerAsOffererTrade; import io.bitsquare.trade.SellerAsTakerTrade; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage; import io.bitsquare.trade.states.OffererState; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsRequestPayDepositMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsRequestPayDepositMessage.java index bd4cd2c7c3..20571ca5b4 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsRequestPayDepositMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerSendsRequestPayDepositMessage.java @@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.listener.SendMessageListener; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerVerifiesAndSignsContract.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerVerifiesAndSignsContract.java index 2ed5c84adb..5bbabf2203 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerVerifiesAndSignsContract.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/BuyerVerifiesAndSignsContract.java @@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.trade.buyer.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.trade.Contract; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import io.bitsquare.util.Utilities; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestDepositTxInputsMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/ProcessRequestDepositTxInputsMessage.java similarity index 79% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestDepositTxInputsMessage.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/ProcessRequestDepositTxInputsMessage.java index 33ca4d24b3..3eae783f11 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/offerer/tasks/OffererProcessRequestDepositTxInputsMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/tasks/ProcessRequestDepositTxInputsMessage.java @@ -15,12 +15,12 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.offerer.tasks; +package io.bitsquare.trade.protocol.trade.buyer.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil; import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage; import org.slf4j.Logger; @@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory; import static com.google.common.base.Preconditions.checkNotNull; import static io.bitsquare.util.Validator.*; -public class OffererProcessRequestDepositTxInputsMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(OffererProcessRequestDepositTxInputsMessage.class); +public class ProcessRequestDepositTxInputsMessage extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(ProcessRequestDepositTxInputsMessage.class); - public OffererProcessRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) { + public ProcessRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -44,8 +44,8 @@ public class OffererProcessRequestDepositTxInputsMessage extends TradeTask { checkNotNull(message); trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(message.tradeAmount))); - processModel.setTakeOfferFeeTxId(nonEmptyStringOf(message.takeOfferFeeTxId)); - processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.takerTradeWalletPubKey)); + processModel.setTakeOfferFeeTxId(nonEmptyStringOf(message.sellerOfferFeeTxId)); + processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.sellerTradeWalletPubKey)); complete(); } catch (Throwable t) { diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestDepositTxInputsMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestDepositTxInputsMessage.java index e118856ef9..5b6aa58bbf 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestDepositTxInputsMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestDepositTxInputsMessage.java @@ -29,13 +29,13 @@ public class RequestDepositTxInputsMessage extends TradeMessage implements Seria private static final long serialVersionUID = 1L; public final Coin tradeAmount; - public final String takeOfferFeeTxId; - public final byte[] takerTradeWalletPubKey; + public final String sellerOfferFeeTxId; + public final byte[] sellerTradeWalletPubKey; - public RequestDepositTxInputsMessage(String tradeId, String takeOfferFeeTxId, Coin tradeAmount, byte[] takerTradeWalletPubKey) { + public RequestDepositTxInputsMessage(String tradeId, String sellerOfferFeeTxId, Coin tradeAmount, byte[] sellerTradeWalletPubKey) { super(tradeId); - this.takeOfferFeeTxId = takeOfferFeeTxId; + this.sellerOfferFeeTxId = sellerOfferFeeTxId; this.tradeAmount = tradeAmount; - this.takerTradeWalletPubKey = takerTradeWalletPubKey; + this.sellerTradeWalletPubKey = sellerTradeWalletPubKey; } } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPayDepositMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPayDepositMessage.java index 4140a1ff85..2bc444c84a 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPayDepositMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPayDepositMessage.java @@ -38,8 +38,8 @@ public class RequestPayDepositMessage extends TradeMessage implements Serializab public final List buyerConnectedOutputsForAllInputs; public final List buyerOutputs; public final byte[] buyerTradeWalletPubKey; - public final PublicKey buyerP2PSigPublicKey; - public final PublicKey buyerP2PEncryptPublicKey; + public final PublicKey buyerP2pSigPublicKey; + public final PublicKey buyerP2pEncryptPublicKey; public final FiatAccount buyerFiatAccount; public final String buyerAccountId; public final Coin tradeAmount; @@ -49,14 +49,14 @@ public class RequestPayDepositMessage extends TradeMessage implements Serializab List buyerConnectedOutputsForAllInputs, List buyerOutputs, byte[] buyerTradeWalletPubKey, - PublicKey buyerP2PSigPublicKey, - PublicKey buyerP2PEncryptPublicKey, + PublicKey buyerP2pSigPublicKey, + PublicKey buyerP2pEncryptPublicKey, FiatAccount buyerFiatAccount, String buyerAccountId) { super(tradeId); this.tradeAmount = tradeAmount; - this.buyerP2PSigPublicKey = buyerP2PSigPublicKey; - this.buyerP2PEncryptPublicKey = buyerP2PEncryptPublicKey; + this.buyerP2pSigPublicKey = buyerP2pSigPublicKey; + this.buyerP2pEncryptPublicKey = buyerP2pEncryptPublicKey; this.buyerConnectedOutputsForAllInputs = buyerConnectedOutputsForAllInputs; this.buyerOutputs = buyerOutputs; this.buyerTradeWalletPubKey = buyerTradeWalletPubKey; diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxFromSellerMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxFromSellerMessage.java deleted file mode 100644 index 49802b56ba..0000000000 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxFromSellerMessage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.trade.protocol.trade.messages; - -import io.bitsquare.fiat.FiatAccount; - -import org.bitcoinj.core.Transaction; -import org.bitcoinj.core.TransactionOutput; - -import java.io.Serializable; - -import java.security.PublicKey; - -import java.util.List; - -import javax.annotation.concurrent.Immutable; - -@Immutable -public class RequestPublishDepositTxFromSellerMessage extends RequestPublishDepositTxMessage implements Serializable { - // That object is sent over the wire, so we need to take care of version compatibility. - private static final long serialVersionUID = 1L; - public byte[] sellerTradeWalletPubKey; - - public RequestPublishDepositTxFromSellerMessage(String tradeId, - FiatAccount takerFiatAccount, - String takerAccountId, - byte[] sellerTradeWalletPubKey, - PublicKey takerP2PSigPublicKey, - PublicKey takerP2PEncryptPublicKey, - String takerContractAsJson, - String takerContractSignature, - String takerPayoutAddressString, - Transaction takersPreparedDepositTx, - List takerConnectedOutputsForAllInputs) { - super(tradeId, - takerFiatAccount, - takerAccountId, - takerP2PSigPublicKey, - takerP2PEncryptPublicKey, - takerContractAsJson, - takerContractSignature, - takerPayoutAddressString, - takersPreparedDepositTx, - takerConnectedOutputsForAllInputs); - - this.sellerTradeWalletPubKey = sellerTradeWalletPubKey; - } -} diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxMessage.java index 3ed27b8822..ca3175d422 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/messages/RequestPublishDepositTxMessage.java @@ -35,35 +35,38 @@ public class RequestPublishDepositTxMessage extends TradeMessage implements Seri // That object is sent over the wire, so we need to take care of version compatibility. private static final long serialVersionUID = 1L; - public final FiatAccount takerFiatAccount; - public final String takerAccountId; - public final PublicKey takerP2PSigPublicKey; - public final PublicKey takerP2PEncryptPublicKey; - public final String takerContractAsJson; - public final String takerContractSignature; - public final String takerPayoutAddressString; - public final Transaction takersPreparedDepositTx; - public final List takerConnectedOutputsForAllInputs; - + public final FiatAccount sellerFiatAccount; + public final String sellerAccountId; + public final PublicKey sellerP2pSigPublicKey; + public final PublicKey sellerP2pEncryptPublicKey; + public final String sellerContractAsJson; + public final String sellerContractSignature; + public final String sellerPayoutAddressString; + public final Transaction sellersPreparedDepositTx; + public final List sellerConnectedOutputsForAllInputs; + public byte[] sellerTradeWalletPubKey; + public RequestPublishDepositTxMessage(String tradeId, - FiatAccount takerFiatAccount, - String takerAccountId, - PublicKey takerP2PSigPublicKey, - PublicKey takerP2PEncryptPublicKey, - String takerContractAsJson, - String takerContractSignature, - String takerPayoutAddressString, - Transaction takersPreparedDepositTx, - List takerConnectedOutputsForAllInputs) { + FiatAccount sellerFiatAccount, + String sellerAccountId, + byte[] sellerTradeWalletPubKey, + PublicKey sellerP2pSigPublicKey, + PublicKey sellerP2pEncryptPublicKey, + String sellerContractAsJson, + String sellerContractSignature, + String sellerPayoutAddressString, + Transaction sellersPreparedDepositTx, + List sellerConnectedOutputsForAllInputs) { super(tradeId); - this.takerFiatAccount = takerFiatAccount; - this.takerAccountId = takerAccountId; - this.takerP2PSigPublicKey = takerP2PSigPublicKey; - this.takerP2PEncryptPublicKey = takerP2PEncryptPublicKey; - this.takerContractAsJson = takerContractAsJson; - this.takerContractSignature = takerContractSignature; - this.takerPayoutAddressString = takerPayoutAddressString; - this.takersPreparedDepositTx = takersPreparedDepositTx; - this.takerConnectedOutputsForAllInputs = takerConnectedOutputsForAllInputs; + this.sellerFiatAccount = sellerFiatAccount; + this.sellerAccountId = sellerAccountId; + this.sellerTradeWalletPubKey = sellerTradeWalletPubKey; + this.sellerP2pSigPublicKey = sellerP2pSigPublicKey; + this.sellerP2pEncryptPublicKey = sellerP2pEncryptPublicKey; + this.sellerContractAsJson = sellerContractAsJson; + this.sellerContractSignature = sellerContractSignature; + this.sellerPayoutAddressString = sellerPayoutAddressString; + this.sellersPreparedDepositTx = sellersPreparedDepositTx; + this.sellerConnectedOutputsForAllInputs = sellerConnectedOutputsForAllInputs; } } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/SellerAsOffererProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsOffererProtocol.java similarity index 95% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/SellerAsOffererProtocol.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsOffererProtocol.java index df53518eda..f81a49abd5 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/SellerAsOffererProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsOffererProtocol.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.seller.offerer; +package io.bitsquare.trade.protocol.trade.seller; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.MailboxMessage; @@ -31,15 +31,15 @@ import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.messages.TradeMessage; -import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSendsPayoutTxPublishedMessage; -import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSendsRequestPublishDepositTxFromTakerMessage; -import io.bitsquare.trade.protocol.trade.seller.offerer.tasks.OffererSignsAndPublishPayoutTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsContract; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsRequestPublishDepositTxMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx; import io.bitsquare.trade.protocol.trade.shared.models.ProcessModel; import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakeOfferFeePayment; import io.bitsquare.trade.protocol.trade.shared.offerer.tasks.VerifyTakerAccount; @@ -149,7 +149,7 @@ public class SellerAsOffererProtocol implements TradeProtocol { VerifyTakerAccount.class, SellerCreatesAndSignsContract.class, SellerCreatesAndSignsDepositTx.class, - OffererSendsRequestPublishDepositTxFromTakerMessage.class + SellerSendsRequestPublishDepositTxMessage.class ); taskRunner.run(); } @@ -199,8 +199,8 @@ public class SellerAsOffererProtocol implements TradeProtocol { taskRunner.addTasks( VerifyTakeOfferFeePayment.class, - OffererSignsAndPublishPayoutTx.class, - OffererSendsPayoutTxPublishedMessage.class + SellerSignsAndPublishPayoutTx.class, + SellerSendsPayoutTxPublishedMessage.class ); taskRunner.run(); } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/SellerAsTakerProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsTakerProtocol.java similarity index 93% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/SellerAsTakerProtocol.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsTakerProtocol.java index e6e6f6a772..069f8986e2 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/SellerAsTakerProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/SellerAsTakerProtocol.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.seller.taker; +package io.bitsquare.trade.protocol.trade.seller; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.MailboxMessage; @@ -25,20 +25,20 @@ import io.bitsquare.p2p.Peer; import io.bitsquare.trade.SellerAsTakerTrade; import io.bitsquare.trade.Trade; import io.bitsquare.trade.protocol.trade.TradeProtocol; -import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestDepositTxInputsMessage; -import io.bitsquare.trade.protocol.trade.buyer.taker.tasks.TakerSendsRequestPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.messages.RequestPayDepositMessage; import io.bitsquare.trade.protocol.trade.messages.TradeMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSendsPayoutTxPublishedMessage; -import io.bitsquare.trade.protocol.trade.seller.taker.tasks.TakerSignsAndPublishPayoutTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCommitDepositTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsContract; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerCreatesAndSignsDepositTx; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessDepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessFiatTransferStartedMessage; import io.bitsquare.trade.protocol.trade.seller.tasks.SellerProcessRequestPayDepositMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsPayoutTxPublishedMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSendsRequestPublishDepositTxMessage; +import io.bitsquare.trade.protocol.trade.seller.tasks.SellerSignsAndPublishPayoutTx; +import io.bitsquare.trade.protocol.trade.seller.tasks.SendRequestDepositTxInputsMessage; import io.bitsquare.trade.protocol.trade.shared.models.ProcessModel; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.BroadcastTakeOfferFeeTx; import io.bitsquare.trade.protocol.trade.shared.taker.tasks.CreateTakeOfferFeeTx; @@ -104,7 +104,7 @@ public class SellerAsTakerProtocol implements TradeProtocol { taskRunner.addTasks( CreateTakeOfferFeeTx.class, BroadcastTakeOfferFeeTx.class, - TakerSendsRequestDepositTxInputsMessage.class + SendRequestDepositTxInputsMessage.class ); taskRunner.run(); } @@ -126,7 +126,7 @@ public class SellerAsTakerProtocol implements TradeProtocol { VerifyOffererAccount.class, SellerCreatesAndSignsContract.class, SellerCreatesAndSignsDepositTx.class, - TakerSendsRequestPublishDepositTxMessage.class + SellerSendsRequestPublishDepositTxMessage.class ); taskRunner.run(); } @@ -176,8 +176,8 @@ public class SellerAsTakerProtocol implements TradeProtocol { taskRunner.addTasks( VerifyOfferFeePayment.class, - TakerSignsAndPublishPayoutTx.class, - TakerSendsPayoutTxPublishedMessage.class + SellerSignsAndPublishPayoutTx.class, + SellerSendsPayoutTxPublishedMessage.class ); taskRunner.run(); } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsPayoutTxPublishedMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsPayoutTxPublishedMessage.java deleted file mode 100644 index 350c86e2b3..0000000000 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsPayoutTxPublishedMessage.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.trade.protocol.trade.seller.offerer.tasks; - -import io.bitsquare.common.taskrunner.TaskRunner; -import io.bitsquare.p2p.listener.SendMessageListener; -import io.bitsquare.trade.BuyerAsOffererTrade; -import io.bitsquare.trade.SellerAsOffererTrade; -import io.bitsquare.trade.Trade; -import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage; -import io.bitsquare.trade.states.OffererState; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OffererSendsPayoutTxPublishedMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(OffererSendsPayoutTxPublishedMessage.class); - - public OffererSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void doRun() { - try { - PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(processModel.getId(), processModel.getPayoutTx()); - processModel.getMessageService().sendMessage(trade.getTradingPeer(), - tradeMessage, - processModel.getP2pSigPubKey(), - processModel.getP2pEncryptPubKey(), - new SendMessageListener() { - @Override - public void handleResult() { - log.trace("PayoutTxPublishedMessage successfully arrived at peer"); - complete(); - } - - @Override - public void handleFault() { - appendToErrorMessage("Sending PayoutTxPublishedMessage failed"); - trade.setErrorMessage(errorMessage); - - if (trade instanceof BuyerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED); - else if (trade instanceof SellerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED); - - failed(); - } - }); - } catch (Throwable t) { - t.printStackTrace(); - trade.setThrowable(t); - failed(t); - } - } -} diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsRequestPublishDepositTxFromTakerMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsRequestPublishDepositTxFromTakerMessage.java deleted file mode 100644 index 8c3e84726f..0000000000 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSendsRequestPublishDepositTxFromTakerMessage.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.trade.protocol.trade.seller.offerer.tasks; - -import io.bitsquare.common.taskrunner.TaskRunner; -import io.bitsquare.p2p.listener.SendMessageListener; -import io.bitsquare.trade.BuyerAsOffererTrade; -import io.bitsquare.trade.SellerAsOffererTrade; -import io.bitsquare.trade.Trade; -import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxFromSellerMessage; -import io.bitsquare.trade.states.OffererState; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OffererSendsRequestPublishDepositTxFromTakerMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(OffererSendsRequestPublishDepositTxFromTakerMessage.class); - - public OffererSendsRequestPublishDepositTxFromTakerMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void doRun() { - try { - RequestPublishDepositTxFromSellerMessage tradeMessage = new RequestPublishDepositTxFromSellerMessage( - processModel.getId(), - processModel.getFiatAccount(), - processModel.getAccountId(), - processModel.getTradeWalletPubKey(), - processModel.getP2pSigPubKey(), - processModel.getP2pEncryptPublicKey(), - trade.getContractAsJson(), - trade.getBuyerContractSignature(), - processModel.getAddressEntry().getAddressString(), - processModel.getPreparedDepositTx(), - processModel.getConnectedOutputsForAllInputs() - ); - - processModel.getMessageService().sendMessage(trade.getTradingPeer(), tradeMessage, new SendMessageListener() { - @Override - public void handleResult() { - complete(); - } - - @Override - public void handleFault() { - appendToErrorMessage("Sending RequestOffererPublishDepositTxMessage failed"); - trade.setErrorMessage(errorMessage); - - if (trade instanceof BuyerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED); - else if (trade instanceof SellerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.MESSAGE_SENDING_FAILED); - - failed(); - } - }); - } catch (Throwable t) { - t.printStackTrace(); - trade.setThrowable(t); - failed(t); - } - } -} diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSignsAndPublishPayoutTx.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSignsAndPublishPayoutTx.java deleted file mode 100644 index 71d982345f..0000000000 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/offerer/tasks/OffererSignsAndPublishPayoutTx.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.trade.protocol.trade.seller.offerer.tasks; - -import io.bitsquare.common.taskrunner.TaskRunner; -import io.bitsquare.trade.BuyerAsOffererTrade; -import io.bitsquare.trade.SellerAsOffererTrade; -import io.bitsquare.trade.Trade; -import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.states.OffererState; - -import org.bitcoinj.core.Transaction; - -import com.google.common.util.concurrent.FutureCallback; - -import org.jetbrains.annotations.NotNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OffererSignsAndPublishPayoutTx extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(OffererSignsAndPublishPayoutTx.class); - - public OffererSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void doRun() { - try { - processModel.getTradeWalletService().signAndPublishPayoutTx( - trade.getDepositTx(), - processModel.tradingPeer.getSignature(), - processModel.tradingPeer.getPayoutAmount(), - processModel.getPayoutAmount(), - processModel.tradingPeer.getPayoutAddressString(), - processModel.getAddressEntry(), - processModel.tradingPeer.getTradeWalletPubKey(), - processModel.getTradeWalletPubKey(), - processModel.getArbitratorPubKey(), - new FutureCallback() { - @Override - public void onSuccess(Transaction transaction) { - processModel.setPayoutTx(transaction); - - if (trade instanceof BuyerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED); - else if (trade instanceof SellerAsOffererTrade) - trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED); - - complete(); - } - - @Override - public void onFailure(@NotNull Throwable t) { - t.printStackTrace(); - trade.setThrowable(t); - failed(t); - } - }); - } catch (Throwable t) { - t.printStackTrace(); - trade.setThrowable(t); - failed(t); - } - } -} diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerCreatesAndSignsContract.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerCreatesAndSignsContract.java index 66bfd906ec..507e83d73e 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerCreatesAndSignsContract.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerCreatesAndSignsContract.java @@ -45,7 +45,7 @@ public class SellerCreatesAndSignsContract extends TradeTask { processModel.getAccountId(), processModel.tradingPeer.getFiatAccount(), processModel.getFiatAccount(), - processModel.tradingPeer.getP2PSigPubKey(), + processModel.tradingPeer.getP2pSigPubKey(), processModel.getP2pSigPubKey()); String contractAsJson = Utilities.objectToJson(contract); String signature = processModel.getSignatureService().signMessage(processModel.getRegistrationKeyPair(), contractAsJson); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerProcessRequestPayDepositMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerProcessRequestPayDepositMessage.java index 636b10fd55..c0b3e081e8 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerProcessRequestPayDepositMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerProcessRequestPayDepositMessage.java @@ -46,8 +46,8 @@ public class SellerProcessRequestPayDepositMessage extends TradeTask { checkArgument(message.buyerConnectedOutputsForAllInputs.size() > 0); processModel.tradingPeer.setOutputs(checkNotNull(message.buyerOutputs)); processModel.tradingPeer.setTradeWalletPubKey(checkNotNull(message.buyerTradeWalletPubKey)); - processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.buyerP2PSigPublicKey)); - processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.buyerP2PEncryptPublicKey)); + processModel.tradingPeer.setP2pSigPubKey(checkNotNull(message.buyerP2pSigPublicKey)); + processModel.tradingPeer.setP2pEncryptPubKey(checkNotNull(message.buyerP2pEncryptPublicKey)); processModel.tradingPeer.setFiatAccount(checkNotNull(message.buyerFiatAccount)); processModel.tradingPeer.setAccountId(nonEmptyStringOf(message.buyerAccountId)); trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(message.tradeAmount))); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSendsPayoutTxPublishedMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsPayoutTxPublishedMessage.java similarity index 73% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSendsPayoutTxPublishedMessage.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsPayoutTxPublishedMessage.java index 4225309759..e2f9b37517 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSendsPayoutTxPublishedMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsPayoutTxPublishedMessage.java @@ -15,24 +15,22 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.seller.taker.tasks; +package io.bitsquare.trade.protocol.trade.seller.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.listener.SendMessageListener; -import io.bitsquare.trade.BuyerAsTakerTrade; -import io.bitsquare.trade.SellerAsTakerTrade; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; import io.bitsquare.trade.protocol.trade.messages.PayoutTxPublishedMessage; -import io.bitsquare.trade.states.TakerState; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TakerSendsPayoutTxPublishedMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(TakerSendsPayoutTxPublishedMessage.class); +public class SellerSendsPayoutTxPublishedMessage extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(SellerSendsPayoutTxPublishedMessage.class); - public TakerSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) { + public SellerSendsPayoutTxPublishedMessage(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -55,12 +53,7 @@ public class TakerSendsPayoutTxPublishedMessage extends TradeTask { public void handleFault() { appendToErrorMessage("Sending PayoutTxPublishedMessage failed"); trade.setErrorMessage(errorMessage); - - if (trade instanceof BuyerAsTakerTrade) - trade.setProcessState(TakerState.ProcessState.MESSAGE_SENDING_FAILED); - else if (trade instanceof SellerAsTakerTrade) - trade.setProcessState(TakerState.ProcessState.MESSAGE_SENDING_FAILED); - + StateUtil.setSendFailedState(trade); failed(); } }); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestPublishDepositTxMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsRequestPublishDepositTxMessage.java similarity index 83% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestPublishDepositTxMessage.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsRequestPublishDepositTxMessage.java index fd0f8150be..1786b8ca18 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestPublishDepositTxMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSendsRequestPublishDepositTxMessage.java @@ -15,22 +15,22 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.taker.tasks; +package io.bitsquare.trade.protocol.trade.seller.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.listener.SendMessageListener; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil; import io.bitsquare.trade.protocol.trade.messages.RequestPublishDepositTxMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TakerSendsRequestPublishDepositTxMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(TakerSendsRequestPublishDepositTxMessage.class); +public class SellerSendsRequestPublishDepositTxMessage extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(SellerSendsRequestPublishDepositTxMessage.class); - public TakerSendsRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) { + public SellerSendsRequestPublishDepositTxMessage(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -41,8 +41,9 @@ public class TakerSendsRequestPublishDepositTxMessage extends TradeTask { processModel.getId(), processModel.getFiatAccount(), processModel.getAccountId(), + processModel.getTradeWalletPubKey(), processModel.getP2pSigPubKey(), - processModel.getP2pEncryptPublicKey(), + processModel.getP2pEncryptPubKey(), trade.getContractAsJson(), trade.getSellerContractSignature(), processModel.getAddressEntry().getAddressString(), @@ -60,7 +61,9 @@ public class TakerSendsRequestPublishDepositTxMessage extends TradeTask { public void handleFault() { appendToErrorMessage("Sending RequestOffererPublishDepositTxMessage failed"); trade.setErrorMessage(errorMessage); + StateUtil.setSendFailedState(trade); + failed(); } }); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSignsAndPublishPayoutTx.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSignsAndPublishPayoutTx.java similarity index 79% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSignsAndPublishPayoutTx.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSignsAndPublishPayoutTx.java index ad4397289d..8870dea8dd 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/taker/tasks/TakerSignsAndPublishPayoutTx.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SellerSignsAndPublishPayoutTx.java @@ -15,13 +15,16 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.seller.taker.tasks; +package io.bitsquare.trade.protocol.trade.seller.tasks; import io.bitsquare.common.taskrunner.TaskRunner; +import io.bitsquare.trade.BuyerAsOffererTrade; import io.bitsquare.trade.BuyerAsTakerTrade; +import io.bitsquare.trade.SellerAsOffererTrade; import io.bitsquare.trade.SellerAsTakerTrade; import io.bitsquare.trade.Trade; import io.bitsquare.trade.protocol.trade.TradeTask; +import io.bitsquare.trade.states.OffererState; import io.bitsquare.trade.states.TakerState; import org.bitcoinj.core.Transaction; @@ -33,10 +36,10 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TakerSignsAndPublishPayoutTx extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(TakerSignsAndPublishPayoutTx.class); +public class SellerSignsAndPublishPayoutTx extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(SellerSignsAndPublishPayoutTx.class); - public TakerSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) { + public SellerSignsAndPublishPayoutTx(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -58,10 +61,10 @@ public class TakerSignsAndPublishPayoutTx extends TradeTask { public void onSuccess(Transaction transaction) { processModel.setPayoutTx(transaction); - if (trade instanceof BuyerAsTakerTrade) - trade.setProcessState(TakerState.ProcessState.PAYOUT_PUBLISHED); - else if (trade instanceof SellerAsTakerTrade) + if (trade instanceof BuyerAsTakerTrade || trade instanceof SellerAsTakerTrade) trade.setProcessState(TakerState.ProcessState.PAYOUT_PUBLISHED); + else if (trade instanceof BuyerAsOffererTrade || trade instanceof SellerAsOffererTrade) + trade.setProcessState(OffererState.ProcessState.PAYOUT_PUBLISHED); complete(); } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestDepositTxInputsMessage.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SendRequestDepositTxInputsMessage.java similarity index 86% rename from core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestDepositTxInputsMessage.java rename to core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SendRequestDepositTxInputsMessage.java index 25e05ac491..9a5377cee2 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/buyer/taker/tasks/TakerSendsRequestDepositTxInputsMessage.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/seller/tasks/SendRequestDepositTxInputsMessage.java @@ -15,13 +15,13 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.trade.protocol.trade.buyer.taker.tasks; +package io.bitsquare.trade.protocol.trade.seller.tasks; import io.bitsquare.common.taskrunner.TaskRunner; import io.bitsquare.p2p.listener.SendMessageListener; import io.bitsquare.trade.Trade; +import io.bitsquare.trade.protocol.trade.StateUtil; import io.bitsquare.trade.protocol.trade.TradeTask; -import io.bitsquare.trade.protocol.trade.buyer.tasks.StateUtil; import io.bitsquare.trade.protocol.trade.messages.RequestDepositTxInputsMessage; import javafx.application.Platform; @@ -29,10 +29,10 @@ import javafx.application.Platform; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TakerSendsRequestDepositTxInputsMessage extends TradeTask { - private static final Logger log = LoggerFactory.getLogger(TakerSendsRequestDepositTxInputsMessage.class); +public class SendRequestDepositTxInputsMessage extends TradeTask { + private static final Logger log = LoggerFactory.getLogger(SendRequestDepositTxInputsMessage.class); - public TakerSendsRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) { + public SendRequestDepositTxInputsMessage(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -62,7 +62,7 @@ public class TakerSendsRequestDepositTxInputsMessage extends TradeTask { // We try to repeat once and if that fails as well we persist the state for a later retry. if (retryCounter == 0) { retryCounter++; - Platform.runLater(TakerSendsRequestDepositTxInputsMessage.this::doRun); + Platform.runLater(SendRequestDepositTxInputsMessage.this::doRun); } else { appendToErrorMessage("Sending TakeOfferFeePayedMessage to offerer failed. Maybe the network connection was " + diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/ProcessModel.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/ProcessModel.java index b920daa86b..f6494cabe5 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/ProcessModel.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/ProcessModel.java @@ -206,11 +206,7 @@ public class ProcessModel extends Model implements Serializable { } public PublicKey getP2pSigPubKey() { - return user.getP2PSigPubKey(); - } - - public PublicKey getP2pEncryptPublicKey() { - return user.getP2PEncryptPubKey(); + return user.getP2pSigPubKey(); } public byte[] getRegistrationPubKey() { @@ -226,7 +222,7 @@ public class ProcessModel extends Model implements Serializable { } public PublicKey getP2pEncryptPubKey() { - return user.getP2PEncryptPubKey(); + return user.getP2pEncryptPubKey(); } @Nullable diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/TradingPeer.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/TradingPeer.java index 8bcd1dfef0..650219d7cc 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/TradingPeer.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/shared/models/TradingPeer.java @@ -55,7 +55,6 @@ public class TradingPeer implements Serializable { private byte[] signature; private String contractAsJson; private String contractSignature; - private PublicKey p2PSigPubKey; /////////////////////////////////////////////////////////////////////////////////////////// @@ -199,11 +198,4 @@ public class TradingPeer implements Serializable { '}'; } - public PublicKey getP2PSigPubKey() { - return p2PSigPubKey; - } - - public void setP2PSigPubKey(PublicKey p2PSigPubKey) { - this.p2PSigPubKey = p2PSigPubKey; - } } diff --git a/core/src/main/java/io/bitsquare/user/User.java b/core/src/main/java/io/bitsquare/user/User.java index 2aeb8b59eb..37b2165b37 100644 --- a/core/src/main/java/io/bitsquare/user/User.java +++ b/core/src/main/java/io/bitsquare/user/User.java @@ -200,11 +200,11 @@ public class User implements Serializable { return p2pSigKeyPair; } - public PublicKey getP2PSigPubKey() { + public PublicKey getP2pSigPubKey() { return p2pSigKeyPair.getPublic(); } - public PublicKey getP2PEncryptPubKey() { + public PublicKey getP2pEncryptPubKey() { return p2pEncryptKeyPair.getPublic(); }