From 333b7421f59b85b1d887d8ddf0eaad6fb6391fa6 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 31 Jul 2022 10:38:52 -0400 Subject: [PATCH] cleanup trade states, consolidate protocol tasks, remove old tasks --- .../method/trade/AbstractTradeTest.java | 6 +- .../network/CoreNetworkProtoResolver.java | 21 -- core/src/main/java/bisq/core/trade/Trade.java | 72 ++---- .../java/bisq/core/trade/TradeManager.java | 5 +- .../DelayedPayoutTxSignatureRequest.java | 98 -------- .../DelayedPayoutTxSignatureResponse.java | 99 -------- .../DepositTxAndDelayedPayoutTxMessage.java | 98 -------- .../core/trade/messages/DepositTxMessage.java | 86 ------- .../messages/InputsForDepositTxRequest.java | 229 ------------------ .../messages/InputsForDepositTxResponse.java | 193 --------------- .../PeerPublishedDelayedPayoutTxMessage.java | 76 ------ .../trade/protocol/ArbitratorProtocol.java | 2 +- .../trade/protocol/BuyerAsMakerProtocol.java | 45 +--- .../trade/protocol/BuyerAsTakerProtocol.java | 71 ------ .../core/trade/protocol/BuyerProtocol.java | 62 +---- .../core/trade/protocol/DisputeProtocol.java | 23 -- .../trade/protocol/SellerAsMakerProtocol.java | 46 +--- .../trade/protocol/SellerAsTakerProtocol.java | 50 +--- .../core/trade/protocol/SellerProtocol.java | 15 +- .../taker => }/TakerReservesTradeFunds.java | 2 +- ...akerSendsInitTradeRequestToArbitrator.java | 2 +- .../TakerVerifyMakerFeePayment.java | 2 +- .../core/trade/protocol/TradeProtocol.java | 13 +- .../ArbitratorProcessesDepositRequest.java | 2 +- .../protocol/tasks/BroadcastPayoutTx.java | 76 ------ .../BuyerPreparesPaymentSentMessage.java | 4 +- .../BuyerProcessesPaymentReceivedMessage.java | 3 +- .../BuyerSendsPaymentSentMessage.java | 4 +- .../BuyerSetupDepositTxListener.java | 4 +- .../BuyerSetupPayoutTxListener.java | 4 +- ...akerSendsInitTradeRequestIfUnreserved.java | 4 +- .../tasks/{maker => }/MakerSetsLockTime.java | 4 +- .../{maker => }/MaybeRemoveOpenOffer.java | 4 +- .../tasks/ProcessDepositResponse.java | 2 +- ...ssPeerPublishedDelayedPayoutTxMessage.java | 56 ----- .../tasks/ProcessSignContractResponse.java | 2 +- .../SellerPreparesPaymentReceivedMessage.java | 4 +- .../SellerProcessesPaymentSentMessage.java | 3 +- .../SellerPublishesDepositTx.java | 4 +- .../SellerPublishesTradeStatistics.java | 4 +- .../SellerSendsPaymentReceivedMessage.java | 4 +- .../arbitration/PublishedDelayedPayoutTx.java | 65 ----- ...ndPeerPublishedDelayedPayoutTxMessage.java | 71 ------ .../buyer/BuyerFinalizesDelayedPayoutTx.java | 61 ----- ...rocessDelayedPayoutTxSignatureRequest.java | 65 ----- ...essDepositTxAndDelayedPayoutTxMessage.java | 72 ------ ...SendsDelayedPayoutTxSignatureResponse.java | 85 ------- .../buyer/BuyerSignsDelayedPayoutTx.java | 79 ------ .../BuyerVerifiesFinalDelayedPayoutTx.java | 43 ---- .../BuyerVerifiesPreparedDelayedPayoutTx.java | 71 ------ .../BuyerAsMakerCreatesAndSignsDepositTx.java | 109 --------- ...sMakerSendsInputsForDepositTxResponse.java | 42 ---- .../BuyerAsTakerCreatesDepositTxInputs.java | 60 ----- .../BuyerAsTakerSendsDepositTxMessage.java | 77 ------ .../BuyerAsTakerSignsDepositTx.java | 82 ------- .../MakerSendsInputsForDepositTxResponse.java | 125 ---------- .../maker/MakerVerifyTakerFeePayment.java | 49 ---- .../mediation/BroadcastMediatedPayoutTx.java | 50 ---- .../tasks/seller/SellerBroadcastPayoutTx.java | 49 ---- .../seller/SellerCreatesDelayedPayoutTx.java | 50 ---- .../SellerFinalizesDelayedPayoutTx.java | 78 ------ ...ocessDelayedPayoutTxSignatureResponse.java | 62 ----- ...erSendDelayedPayoutTxSignatureRequest.java | 86 ------- .../seller/SellerSignsDelayedPayoutTx.java | 80 ------ ...SellerAsMakerCreatesUnsignedDepositTx.java | 116 --------- .../SellerAsMakerFinalizesDepositTx.java | 59 ----- .../SellerAsMakerProcessDepositTxMessage.java | 58 ----- ...sMakerSendsInputsForDepositTxResponse.java | 50 ---- .../SellerAsTakerCreatesDepositTxInputs.java | 62 ----- .../SellerAsTakerSignsDepositTx.java | 104 -------- ...erProcessesInputsForDepositTxResponse.java | 93 ------- .../tasks/taker/TakerPublishFeeTx.java | 58 ----- .../bisq/desktop/main/debug/DebugView.java | 93 +------ .../pendingtrades/PendingTradesViewModel.java | 49 +--- .../steps/buyer/BuyerStep2View.java | 2 +- proto/src/main/proto/pb.proto | 62 +++-- 76 files changed, 114 insertions(+), 3807 deletions(-) delete mode 100644 core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureRequest.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/DepositTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/InputsForDepositTxRequest.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/InputsForDepositTxResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java rename core/src/main/java/bisq/core/trade/protocol/{tasks/taker => }/TakerReservesTradeFunds.java (98%) rename core/src/main/java/bisq/core/trade/protocol/{tasks/taker => }/TakerSendsInitTradeRequestToArbitrator.java (99%) rename core/src/main/java/bisq/core/trade/protocol/{tasks/taker => }/TakerVerifyMakerFeePayment.java (97%) delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/BroadcastPayoutTx.java rename core/src/main/java/bisq/core/trade/protocol/tasks/{buyer => }/BuyerPreparesPaymentSentMessage.java (98%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{buyer => }/BuyerProcessesPaymentReceivedMessage.java (97%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{buyer => }/BuyerSendsPaymentSentMessage.java (98%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{buyer => }/BuyerSetupDepositTxListener.java (98%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{buyer => }/BuyerSetupPayoutTxListener.java (92%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{maker => }/MakerSendsInitTradeRequestIfUnreserved.java (98%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{maker => }/MakerSetsLockTime.java (95%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{maker => }/MaybeRemoveOpenOffer.java (93%) delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPeerPublishedDelayedPayoutTxMessage.java rename core/src/main/java/bisq/core/trade/protocol/tasks/{seller => }/SellerPreparesPaymentReceivedMessage.java (95%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{seller => }/SellerProcessesPaymentSentMessage.java (97%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{seller => }/SellerPublishesDepositTx.java (96%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{seller => }/SellerPublishesTradeStatistics.java (96%) rename core/src/main/java/bisq/core/trade/protocol/tasks/{seller => }/SellerSendsPaymentReceivedMessage.java (97%) delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/PublishedDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/SendPeerPublishedDelayedPayoutTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerFinalizesDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDelayedPayoutTxSignatureRequest.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDepositTxAndDelayedPayoutTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsDelayedPayoutTxSignatureResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSignsDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesFinalDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesPreparedDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerCreatesAndSignsDepositTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerSendsInputsForDepositTxResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerCreatesDepositTxInputs.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSendsDepositTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInputsForDepositTxResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerVerifyTakerFeePayment.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/mediation/BroadcastMediatedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerBroadcastPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerCreatesDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerFinalizesDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessDelayedPayoutTxSignatureResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendDelayedPayoutTxSignatureRequest.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSignsDelayedPayoutTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerCreatesUnsignedDepositTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerProcessDepositTxMessage.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerSendsInputsForDepositTxResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerCreatesDepositTxInputs.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerSignsDepositTx.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerProcessesInputsForDepositTxResponse.java delete mode 100644 core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java diff --git a/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java b/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java index e3045aa41b..58d0ca0481 100644 --- a/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java +++ b/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java @@ -18,7 +18,7 @@ import static bisq.core.trade.Trade.Phase.DEPOSIT_UNLOCKED; import static bisq.core.trade.Trade.Phase.PAYMENT_SENT; import static bisq.core.trade.Trade.Phase.PAYOUT_PUBLISHED; import static bisq.core.trade.Trade.State.BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG; -import static bisq.core.trade.Trade.State.DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN; +import static bisq.core.trade.Trade.State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN; import static bisq.core.trade.Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG; import static java.lang.String.format; import static java.lang.System.out; @@ -79,7 +79,7 @@ public class AbstractTradeTest extends AbstractOfferTest { GrpcClient grpcClient, String tradeId) { Predicate isTradeInDepositUnlockedStateAndPhase = (t) -> - t.getState().equals(DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN.name()) + t.getState().equals(DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN.name()) && t.getPhase().equals(DEPOSIT_UNLOCKED.name()); String userName = toUserName.apply(grpcClient); @@ -94,7 +94,7 @@ public class AbstractTradeTest extends AbstractOfferTest { i); genBtcBlocksThenWait(1, 4_000); } else { - EXPECTED_PROTOCOL_STATUS.setState(DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN) + EXPECTED_PROTOCOL_STATUS.setState(DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN) .setPhase(DEPOSIT_UNLOCKED) .setDepositPublished(true) .setDepositConfirmed(true); diff --git a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java index 01a92e59da..b61e51bff3 100644 --- a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java @@ -40,21 +40,14 @@ import bisq.core.support.dispute.refund.refundagent.RefundAgent; import bisq.core.support.messages.ChatMessage; import bisq.core.trade.messages.PaymentSentMessage; import bisq.core.trade.messages.PayoutTxPublishedMessage; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; -import bisq.core.trade.messages.DelayedPayoutTxSignatureResponse; import bisq.core.trade.messages.DepositRequest; import bisq.core.trade.messages.DepositResponse; -import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage; -import bisq.core.trade.messages.DepositTxMessage; import bisq.core.trade.messages.InitMultisigRequest; import bisq.core.trade.messages.InitTradeRequest; -import bisq.core.trade.messages.InputsForDepositTxRequest; -import bisq.core.trade.messages.InputsForDepositTxResponse; import bisq.core.trade.messages.MediatedPayoutTxPublishedMessage; import bisq.core.trade.messages.MediatedPayoutTxSignatureMessage; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.PaymentReceivedMessage; -import bisq.core.trade.messages.PeerPublishedDelayedPayoutTxMessage; import bisq.core.trade.messages.RefreshTradeStateRequest; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; @@ -170,18 +163,6 @@ public class CoreNetworkProtoResolver extends CoreProtoResolver implements Netwo return UpdateMultisigRequest.fromProto(proto.getUpdateMultisigRequest(), this, messageVersion); case UPDATE_MULTISIG_RESPONSE: return UpdateMultisigResponse.fromProto(proto.getUpdateMultisigResponse(), this, messageVersion); - case INPUTS_FOR_DEPOSIT_TX_REQUEST: - return InputsForDepositTxRequest.fromProto(proto.getInputsForDepositTxRequest(), this, messageVersion); - case INPUTS_FOR_DEPOSIT_TX_RESPONSE: - return InputsForDepositTxResponse.fromProto(proto.getInputsForDepositTxResponse(), this, messageVersion); - case DEPOSIT_TX_MESSAGE: - return DepositTxMessage.fromProto(proto.getDepositTxMessage(), messageVersion); - case DELAYED_PAYOUT_TX_SIGNATURE_REQUEST: - return DelayedPayoutTxSignatureRequest.fromProto(proto.getDelayedPayoutTxSignatureRequest(), messageVersion); - case DELAYED_PAYOUT_TX_SIGNATURE_RESPONSE: - return DelayedPayoutTxSignatureResponse.fromProto(proto.getDelayedPayoutTxSignatureResponse(), messageVersion); - case DEPOSIT_TX_AND_DELAYED_PAYOUT_TX_MESSAGE: - return DepositTxAndDelayedPayoutTxMessage.fromProto(proto.getDepositTxAndDelayedPayoutTxMessage(), messageVersion); case PAYMENT_SENT_MESSAGE: return PaymentSentMessage.fromProto(proto.getPaymentSentMessage(), messageVersion); @@ -190,8 +171,6 @@ public class CoreNetworkProtoResolver extends CoreProtoResolver implements Netwo case PAYOUT_TX_PUBLISHED_MESSAGE: return PayoutTxPublishedMessage.fromProto(proto.getPayoutTxPublishedMessage(), messageVersion); - case PEER_PUBLISHED_DELAYED_PAYOUT_TX_MESSAGE: - return PeerPublishedDelayedPayoutTxMessage.fromProto(proto.getPeerPublishedDelayedPayoutTxMessage(), messageVersion); case TRADER_SIGNED_WITNESS_MESSAGE: return TraderSignedWitnessMessage.fromProto(proto.getTraderSignedWitnessMessage(), messageVersion); diff --git a/core/src/main/java/bisq/core/trade/Trade.java b/core/src/main/java/bisq/core/trade/Trade.java index 9d2fbd63a7..4024d43a1f 100644 --- a/core/src/main/java/bisq/core/trade/Trade.java +++ b/core/src/main/java/bisq/core/trade/Trade.java @@ -104,8 +104,8 @@ public abstract class Trade implements Tradable, Model { /////////////////////////////////////////////////////////////////////////////////////////// public enum State { - // #################### Phase INIT - // When trade protocol starts no funds are on stake + + // trade initialization PREPARATION(Phase.INIT), MULTISIG_PREPARED(Phase.INIT), MULTISIG_MADE(Phase.INIT), @@ -113,79 +113,47 @@ public abstract class Trade implements Tradable, Model { CONTRACT_SIGNATURE_REQUESTED(Phase.INIT), CONTRACT_SIGNED(Phase.INIT), - // At first part maker/taker have different roles - // taker perspective - // #################### Phase TAKER_FEE_PUBLISHED - TAKER_PUBLISHED_TAKER_FEE_TX(Phase.TAKER_FEE_PUBLISHED), + // deposit requested + SENT_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), + SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), + STORED_IN_MAILBOX_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), //not a mailbox msg, not used... + SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), - // PUBLISH_DEPOSIT_TX_REQUEST - // maker perspective - MAKER_SENT_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), - MAKER_SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), - MAKER_STORED_IN_MAILBOX_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), //not a mailbox msg, not used... - MAKER_SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), + // deposit published + SAW_DEPOSIT_TXS_IN_NETWORK(Phase.DEPOSIT_PUBLISHED), // TODO: seeing in network usually happens after arbitrator publishes + ARBITRATOR_PUBLISHED_DEPOSIT_TXS(Phase.DEPOSIT_PUBLISHED), - // taker perspective - TAKER_RECEIVED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), // Not used anymore + // deposit confirmed (TODO) - // Alternatively the taker could have seen the deposit tx earlier before he received the DEPOSIT_TX_PUBLISHED_MSG - TAKER_SAW_DEPOSIT_TX_IN_NETWORK(Phase.DEPOSIT_PUBLISHED), + // deposit unlocked + DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN(Phase.DEPOSIT_UNLOCKED), - // #################### Phase DEPOSIT_PUBLISHED - // We changes order in trade protocol of publishing deposit tx and sending it to the peer. - // Now we send it first to the peer and only if that succeeds we publish it to avoid likelihood of - // failed trades. We do not want to change the order of the enum though so we keep it here as it was originally. - ARBITRATOR_PUBLISHED_DEPOSIT_TX(Phase.DEPOSIT_PUBLISHED), - - // DEPOSIT_TX_PUBLISHED_MSG - // taker perspective - TAKER_SENT_DEPOSIT_TX_PUBLISHED_MSG(Phase.DEPOSIT_PUBLISHED), - TAKER_SAW_ARRIVED_DEPOSIT_TX_PUBLISHED_MSG(Phase.DEPOSIT_PUBLISHED), - TAKER_STORED_IN_MAILBOX_DEPOSIT_TX_PUBLISHED_MSG(Phase.DEPOSIT_PUBLISHED), - TAKER_SEND_FAILED_DEPOSIT_TX_PUBLISHED_MSG(Phase.DEPOSIT_PUBLISHED), - - // maker perspective - MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG(Phase.DEPOSIT_PUBLISHED), - - // Alternatively the maker could have seen the deposit tx earlier before he received the DEPOSIT_TX_PUBLISHED_MSG - MAKER_SAW_DEPOSIT_TX_IN_NETWORK(Phase.DEPOSIT_PUBLISHED), - - - // #################### Phase DEPOSIT_CONFIRMED - DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN(Phase.DEPOSIT_UNLOCKED), - - - // #################### Phase PAYMENT_SENT + // payment sent BUYER_CONFIRMED_IN_UI_PAYMENT_SENT(Phase.PAYMENT_SENT), BUYER_SENT_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT), BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT), BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT), BUYER_SEND_FAILED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT), - SELLER_RECEIVED_PAYMENT_SENT_MSG(Phase.PAYMENT_SENT), - // #################### Phase PAYMENT_RECEIVED - // note that this state can also be triggered by auto confirmation feature + // payment received SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT(Phase.PAYMENT_RECEIVED), SELLER_SENT_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED), SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED), SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED), SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG(Phase.PAYMENT_RECEIVED), - // #################### Phase PAYOUT_PUBLISHED + // payout published SELLER_PUBLISHED_PAYOUT_TX(Phase.PAYOUT_PUBLISHED), // TODO (woodser): this enum is over used, like during arbitration SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED), SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED), SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED), SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED), - BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG(Phase.PAYOUT_PUBLISHED), - // Alternatively the maker could have seen the payout tx earlier before he received the PAYOUT_TX_PUBLISHED_MSG BUYER_SAW_PAYOUT_TX_IN_NETWORK(Phase.PAYOUT_PUBLISHED), BUYER_PUBLISHED_PAYOUT_TX(Phase.PAYOUT_PUBLISHED), - - // #################### Phase WITHDRAWN + // trade completed WITHDRAW_COMPLETED(Phase.WITHDRAWN); @NotNull @@ -891,7 +859,7 @@ public abstract class Trade implements Tradable, Model { return; } } else { - setStateIfValidTransitionTo(this instanceof MakerTrade ? Trade.State.MAKER_SAW_DEPOSIT_TX_IN_NETWORK : Trade.State.TAKER_SAW_DEPOSIT_TX_IN_NETWORK); + setStateIfValidTransitionTo(Trade.State.SAW_DEPOSIT_TXS_IN_NETWORK); } } @@ -934,7 +902,7 @@ public abstract class Trade implements Tradable, Model { xmrWalletService.removeWalletListener(depositTxListener); // remove listener when notified depositTxListener = null; // prevent re-applying trade state in subsequent requests } else if (txs.size() == 2) { - setStateIfValidTransitionTo(this instanceof MakerTrade ? Trade.State.MAKER_SAW_DEPOSIT_TX_IN_NETWORK : Trade.State.TAKER_SAW_DEPOSIT_TX_IN_NETWORK); + setStateIfValidTransitionTo(Trade.State.SAW_DEPOSIT_TXS_IN_NETWORK); } } }; @@ -1488,7 +1456,7 @@ public abstract class Trade implements Tradable, Model { // As setState is called here from the trade itself we cannot trigger a requestPersistence call. // But as we get setupConfidenceListener called at startup anyway there is no issue if it would not be // persisted in case the shutdown routine did not persist the trade. - setStateIfValidTransitionTo(State.DEPOSIT_UNLOCKED_IN_BLOCK_CHAIN); // TODO (woodser): for xmr this means deposit txs have unlocked after 10 confirmations + setStateIfValidTransitionTo(State.DEPOSIT_TXS_UNLOCKED_IN_BLOCKCHAIN); // TODO (woodser): for xmr this means deposit txs have unlocked after 10 confirmations } } diff --git a/core/src/main/java/bisq/core/trade/TradeManager.java b/core/src/main/java/bisq/core/trade/TradeManager.java index 6cadaaaaed..e3eb1b3650 100644 --- a/core/src/main/java/bisq/core/trade/TradeManager.java +++ b/core/src/main/java/bisq/core/trade/TradeManager.java @@ -41,7 +41,6 @@ import bisq.core.trade.messages.DepositRequest; import bisq.core.trade.messages.DepositResponse; import bisq.core.trade.messages.InitMultisigRequest; import bisq.core.trade.messages.InitTradeRequest; -import bisq.core.trade.messages.InputsForDepositTxRequest; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; @@ -242,9 +241,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi @Override public void onDirectMessage(DecryptedMessageWithPubKey message, NodeAddress peer) { NetworkEnvelope networkEnvelope = message.getNetworkEnvelope(); - if (networkEnvelope instanceof InputsForDepositTxRequest) { - //handleTakeOfferRequest(peer, (InputsForDepositTxRequest) networkEnvelope); // ignore bisq requests - } else if (networkEnvelope instanceof InitTradeRequest) { + if (networkEnvelope instanceof InitTradeRequest) { handleInitTradeRequest((InitTradeRequest) networkEnvelope, peer); } else if (networkEnvelope instanceof InitMultisigRequest) { handleInitMultisigRequest((InitMultisigRequest) networkEnvelope, peer); diff --git a/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureRequest.java b/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureRequest.java deleted file mode 100644 index 26f64fb9ef..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; -import bisq.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -@EqualsAndHashCode(callSuper = true) -@Value -public final class DelayedPayoutTxSignatureRequest extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final byte[] delayedPayoutTx; - private final byte[] delayedPayoutTxSellerSignature; - - public DelayedPayoutTxSignatureRequest(String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] delayedPayoutTx, - byte[] delayedPayoutTxSellerSignature) { - this(Version.getP2PMessageVersion(), - uid, - tradeId, - senderNodeAddress, - delayedPayoutTx, - delayedPayoutTxSellerSignature); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private DelayedPayoutTxSignatureRequest(String messageVersion, - String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] delayedPayoutTx, - byte[] delayedPayoutTxSellerSignature) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.delayedPayoutTx = delayedPayoutTx; - this.delayedPayoutTxSellerSignature = delayedPayoutTxSellerSignature; - } - - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - return getNetworkEnvelopeBuilder() - .setDelayedPayoutTxSignatureRequest(protobuf.DelayedPayoutTxSignatureRequest.newBuilder() - .setUid(uid) - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setDelayedPayoutTx(ByteString.copyFrom(delayedPayoutTx)) - .setDelayedPayoutTxSellerSignature(ByteString.copyFrom(delayedPayoutTxSellerSignature))) - .build(); - } - - public static DelayedPayoutTxSignatureRequest fromProto(protobuf.DelayedPayoutTxSignatureRequest proto, - String messageVersion) { - return new DelayedPayoutTxSignatureRequest(messageVersion, - proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - proto.getDelayedPayoutTx().toByteArray(), - proto.getDelayedPayoutTxSellerSignature().toByteArray()); - } - - @Override - public String toString() { - return "DelayedPayoutTxSignatureRequest{" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n delayedPayoutTx=" + Utilities.bytesAsHexString(delayedPayoutTx) + - ",\n delayedPayoutTxSellerSignature=" + Utilities.bytesAsHexString(delayedPayoutTxSellerSignature) + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureResponse.java b/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureResponse.java deleted file mode 100644 index eb5e69ec51..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/DelayedPayoutTxSignatureResponse.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; -import bisq.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -@EqualsAndHashCode(callSuper = true) -@Value -public final class DelayedPayoutTxSignatureResponse extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final byte[] delayedPayoutTxBuyerSignature; - private final byte[] depositTx; - - public DelayedPayoutTxSignatureResponse(String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] delayedPayoutTxBuyerSignature, - byte[] depositTx) { - this(Version.getP2PMessageVersion(), - uid, - tradeId, - senderNodeAddress, - delayedPayoutTxBuyerSignature, - depositTx); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private DelayedPayoutTxSignatureResponse(String messageVersion, - String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] delayedPayoutTxBuyerSignature, - byte[] depositTx) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.delayedPayoutTxBuyerSignature = delayedPayoutTxBuyerSignature; - this.depositTx = depositTx; - } - - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - return getNetworkEnvelopeBuilder() - .setDelayedPayoutTxSignatureResponse(protobuf.DelayedPayoutTxSignatureResponse.newBuilder() - .setUid(uid) - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setDelayedPayoutTxBuyerSignature(ByteString.copyFrom(delayedPayoutTxBuyerSignature)) - .setDepositTx(ByteString.copyFrom(depositTx)) - ) - .build(); - } - - public static DelayedPayoutTxSignatureResponse fromProto(protobuf.DelayedPayoutTxSignatureResponse proto, - String messageVersion) { - return new DelayedPayoutTxSignatureResponse(messageVersion, - proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - proto.getDelayedPayoutTxBuyerSignature().toByteArray(), - proto.getDepositTx().toByteArray()); - } - - @Override - public String toString() { - return "DelayedPayoutTxSignatureResponse{" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n delayedPayoutTxBuyerSignature=" + Utilities.bytesAsHexString(delayedPayoutTxBuyerSignature) + - ",\n depositTx=" + Utilities.bytesAsHexString(depositTx) + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java deleted file mode 100644 index 9d68782c1b..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; -import bisq.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -// It is the last message in the take offer phase. We use MailboxMessage instead of DirectMessage to add more tolerance -// in case of network issues and as the message does not trigger further protocol execution. -@EqualsAndHashCode(callSuper = true) -@Value -public final class DepositTxAndDelayedPayoutTxMessage extends TradeMailboxMessage { - private final NodeAddress senderNodeAddress; - private final byte[] depositTx; - private final byte[] delayedPayoutTx; - - public DepositTxAndDelayedPayoutTxMessage(String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] depositTx, - byte[] delayedPayoutTx) { - this(Version.getP2PMessageVersion(), - uid, - tradeId, - senderNodeAddress, - depositTx, - delayedPayoutTx); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private DepositTxAndDelayedPayoutTxMessage(String messageVersion, - String uid, - String tradeId, - NodeAddress senderNodeAddress, - byte[] depositTx, - byte[] delayedPayoutTx) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.depositTx = depositTx; - this.delayedPayoutTx = delayedPayoutTx; - } - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - return getNetworkEnvelopeBuilder() - .setDepositTxAndDelayedPayoutTxMessage(protobuf.DepositTxAndDelayedPayoutTxMessage.newBuilder() - .setUid(uid) - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setDepositTx(ByteString.copyFrom(depositTx)) - .setDelayedPayoutTx(ByteString.copyFrom(delayedPayoutTx))) - .build(); - } - - public static DepositTxAndDelayedPayoutTxMessage fromProto(protobuf.DepositTxAndDelayedPayoutTxMessage proto, - String messageVersion) { - return new DepositTxAndDelayedPayoutTxMessage(messageVersion, - proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - proto.getDepositTx().toByteArray(), - proto.getDelayedPayoutTx().toByteArray()); - } - - @Override - public String toString() { - return "DepositTxAndDelayedPayoutTxMessage{" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n depositTx=" + Utilities.bytesAsHexString(depositTx) + - ",\n delayedPayoutTx=" + Utilities.bytesAsHexString(delayedPayoutTx) + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/DepositTxMessage.java b/core/src/main/java/bisq/core/trade/messages/DepositTxMessage.java deleted file mode 100644 index 6b31b6205c..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/DepositTxMessage.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; -import bisq.common.proto.ProtoUtil; - -import java.util.Optional; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -import javax.annotation.Nullable; - -// It is the last message in the take offer phase. We use MailboxMessage instead of DirectMessage to add more tolerance -// in case of network issues and as the message does not trigger further protocol execution. -@EqualsAndHashCode(callSuper = true) -@Value -public final class DepositTxMessage extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - @Nullable - private final String tradeFeeTxId; - @Nullable - private final String depositTxId; - - public DepositTxMessage(String uid, - String tradeId, - NodeAddress senderNodeAddress, - String tradeFeeTxId, - String depositTxId) { - super(Version.getP2PMessageVersion(), tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.tradeFeeTxId = tradeFeeTxId; - this.depositTxId = depositTxId; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - protobuf.DepositTxMessage.Builder builder = protobuf.DepositTxMessage.newBuilder() - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setUid(uid); - Optional.ofNullable(tradeFeeTxId).ifPresent(e -> builder.setTradeFeeTxId(tradeFeeTxId)); - Optional.ofNullable(depositTxId).ifPresent(e -> builder.setDepositTxId(depositTxId)); - return getNetworkEnvelopeBuilder().setDepositTxMessage(builder).build(); - } - - public static DepositTxMessage fromProto(protobuf.DepositTxMessage proto, String messageVersion) { - return new DepositTxMessage(proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - ProtoUtil.stringOrNullFromProto(proto.getTradeFeeTxId()), - ProtoUtil.stringOrNullFromProto(proto.getDepositTxId())); - } - - @Override - public String toString() { - return "DepositTxMessage{" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n tradeFeeTxId=" + tradeFeeTxId + - ",\n depositTxId=" + depositTxId + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxRequest.java b/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxRequest.java deleted file mode 100644 index 0dd61d9f71..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxRequest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.core.btc.model.RawTransactionInput; -import bisq.core.payment.payload.PaymentAccountPayload; -import bisq.core.proto.CoreProtoResolver; - -import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; - -import bisq.common.crypto.PubKeyRing; -import bisq.common.proto.ProtoUtil; -import bisq.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -import javax.annotation.Nullable; - -@EqualsAndHashCode(callSuper = true) -@Value -public final class InputsForDepositTxRequest extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final long tradeAmount; - private final long tradePrice; - private final long txFee; - private final long takerFee; - private final List rawTransactionInputs; - private final long changeOutputValue; - @Nullable - private final String changeOutputAddress; - private final byte[] takerMultiSigPubKey; - private final String takerPayoutAddressString; - private final PubKeyRing takerPubKeyRing; - private final PaymentAccountPayload takerPaymentAccountPayload; - private final String takerAccountId; - private final String takerFeeTxId; - private final List acceptedArbitratorNodeAddresses; - private final List acceptedMediatorNodeAddresses; - private final List acceptedRefundAgentNodeAddresses; - @Nullable - private final NodeAddress arbitratorNodeAddress; - private final NodeAddress mediatorNodeAddress; - private final NodeAddress refundAgentNodeAddress; - - private final byte[] accountAgeWitnessSignatureOfOfferId; - private final long currentDate; - - public InputsForDepositTxRequest(String tradeId, - NodeAddress senderNodeAddress, - long tradeAmount, - long tradePrice, - long txFee, - long takerFee, - List rawTransactionInputs, - long changeOutputValue, - @Nullable String changeOutputAddress, - byte[] takerMultiSigPubKey, - String takerPayoutAddressString, - PubKeyRing takerPubKeyRing, - PaymentAccountPayload takerPaymentAccountPayload, - String takerAccountId, - String takerFeeTxId, - List acceptedArbitratorNodeAddresses, - List acceptedMediatorNodeAddresses, - List acceptedRefundAgentNodeAddresses, - @Nullable NodeAddress arbitratorNodeAddress, - NodeAddress mediatorNodeAddress, - NodeAddress refundAgentNodeAddress, - String uid, - String messageVersion, - byte[] accountAgeWitnessSignatureOfOfferId, - long currentDate) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.tradeAmount = tradeAmount; - this.tradePrice = tradePrice; - this.txFee = txFee; - this.takerFee = takerFee; - this.rawTransactionInputs = rawTransactionInputs; - this.changeOutputValue = changeOutputValue; - this.changeOutputAddress = changeOutputAddress; - this.takerMultiSigPubKey = takerMultiSigPubKey; - this.takerPayoutAddressString = takerPayoutAddressString; - this.takerPubKeyRing = takerPubKeyRing; - this.takerPaymentAccountPayload = takerPaymentAccountPayload; - this.takerAccountId = takerAccountId; - this.takerFeeTxId = takerFeeTxId; - this.acceptedArbitratorNodeAddresses = acceptedArbitratorNodeAddresses; - this.acceptedMediatorNodeAddresses = acceptedMediatorNodeAddresses; - this.acceptedRefundAgentNodeAddresses = acceptedRefundAgentNodeAddresses; - this.arbitratorNodeAddress = arbitratorNodeAddress; - this.mediatorNodeAddress = mediatorNodeAddress; - this.refundAgentNodeAddress = refundAgentNodeAddress; - this.accountAgeWitnessSignatureOfOfferId = accountAgeWitnessSignatureOfOfferId; - this.currentDate = currentDate; - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - protobuf.InputsForDepositTxRequest.Builder builder = protobuf.InputsForDepositTxRequest.newBuilder() - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setTradeAmount(tradeAmount) - .setTradePrice(tradePrice) - .setTxFee(txFee) - .setTakerFee(takerFee) - .addAllRawTransactionInputs(rawTransactionInputs.stream() - .map(RawTransactionInput::toProtoMessage).collect(Collectors.toList())) - .setChangeOutputValue(changeOutputValue) - .setTakerMultiSigPubKey(ByteString.copyFrom(takerMultiSigPubKey)) - .setTakerPayoutAddressString(takerPayoutAddressString) - .setTakerPubKeyRing(takerPubKeyRing.toProtoMessage()) - .setTakerPaymentAccountPayload((protobuf.PaymentAccountPayload) takerPaymentAccountPayload.toProtoMessage()) - .setTakerAccountId(takerAccountId) - .setTakerFeeTxId(takerFeeTxId) - .addAllAcceptedArbitratorNodeAddresses(acceptedArbitratorNodeAddresses.stream() - .map(NodeAddress::toProtoMessage).collect(Collectors.toList())) - .addAllAcceptedMediatorNodeAddresses(acceptedMediatorNodeAddresses.stream() - .map(NodeAddress::toProtoMessage).collect(Collectors.toList())) - .addAllAcceptedRefundAgentNodeAddresses(acceptedRefundAgentNodeAddresses.stream() - .map(NodeAddress::toProtoMessage).collect(Collectors.toList())) - .setMediatorNodeAddress(mediatorNodeAddress.toProtoMessage()) - .setRefundAgentNodeAddress(refundAgentNodeAddress.toProtoMessage()) - .setUid(uid) - .setAccountAgeWitnessSignatureOfOfferId(ByteString.copyFrom(accountAgeWitnessSignatureOfOfferId)) - .setCurrentDate(currentDate); - - Optional.ofNullable(changeOutputAddress).ifPresent(builder::setChangeOutputAddress); - Optional.ofNullable(arbitratorNodeAddress).ifPresent(e -> builder.setArbitratorNodeAddress(arbitratorNodeAddress.toProtoMessage())); - return getNetworkEnvelopeBuilder().setInputsForDepositTxRequest(builder).build(); - } - - public static InputsForDepositTxRequest fromProto(protobuf.InputsForDepositTxRequest proto, - CoreProtoResolver coreProtoResolver, - String messageVersion) { - List rawTransactionInputs = proto.getRawTransactionInputsList().stream() - .map(rawTransactionInput -> new RawTransactionInput(rawTransactionInput.getIndex(), - rawTransactionInput.getParentTransaction().toByteArray(), rawTransactionInput.getValue())) - .collect(Collectors.toList()); - List acceptedArbitratorNodeAddresses = proto.getAcceptedArbitratorNodeAddressesList().stream() - .map(NodeAddress::fromProto).collect(Collectors.toList()); - List acceptedMediatorNodeAddresses = proto.getAcceptedMediatorNodeAddressesList().stream() - .map(NodeAddress::fromProto).collect(Collectors.toList()); - List acceptedRefundAgentNodeAddresses = proto.getAcceptedRefundAgentNodeAddressesList().stream() - .map(NodeAddress::fromProto).collect(Collectors.toList()); - - return new InputsForDepositTxRequest(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - proto.getTradeAmount(), - proto.getTradePrice(), - proto.getTxFee(), - proto.getTakerFee(), - rawTransactionInputs, - proto.getChangeOutputValue(), - ProtoUtil.stringOrNullFromProto(proto.getChangeOutputAddress()), - proto.getTakerMultiSigPubKey().toByteArray(), - proto.getTakerPayoutAddressString(), - PubKeyRing.fromProto(proto.getTakerPubKeyRing()), - coreProtoResolver.fromProto(proto.getTakerPaymentAccountPayload()), - proto.getTakerAccountId(), - proto.getTakerFeeTxId(), - acceptedArbitratorNodeAddresses, - acceptedMediatorNodeAddresses, - acceptedRefundAgentNodeAddresses, - NodeAddress.fromProto(proto.getArbitratorNodeAddress()), - NodeAddress.fromProto(proto.getMediatorNodeAddress()), - NodeAddress.fromProto(proto.getRefundAgentNodeAddress()), - proto.getUid(), - messageVersion, - ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessSignatureOfOfferId()), - proto.getCurrentDate()); - } - - @Override - public String toString() { - return "InputsForDepositTxRequest{" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n tradeAmount=" + tradeAmount + - ",\n tradePrice=" + tradePrice + - ",\n txFee=" + txFee + - ",\n takerFee=" + takerFee + - ",\n rawTransactionInputs=" + rawTransactionInputs + - ",\n changeOutputValue=" + changeOutputValue + - ",\n changeOutputAddress='" + changeOutputAddress + '\'' + - ",\n takerMultiSigPubKey=" + Utilities.bytesAsHexString(takerMultiSigPubKey) + - ",\n takerPayoutAddressString='" + takerPayoutAddressString + '\'' + - ",\n takerPubKeyRing=" + takerPubKeyRing + - ",\n takerPaymentAccountPayload=" + takerPaymentAccountPayload + - ",\n takerAccountId='" + takerAccountId + '\'' + - ",\n takerFeeTxId='" + takerFeeTxId + '\'' + - ",\n acceptedArbitratorNodeAddresses=" + acceptedArbitratorNodeAddresses + - ",\n acceptedMediatorNodeAddresses=" + acceptedMediatorNodeAddresses + - ",\n acceptedRefundAgentNodeAddresses=" + acceptedRefundAgentNodeAddresses + - ",\n arbitratorNodeAddress=" + arbitratorNodeAddress + - ",\n mediatorNodeAddress=" + mediatorNodeAddress + - ",\n refundAgentNodeAddress=" + refundAgentNodeAddress + - ",\n accountAgeWitnessSignatureOfOfferId=" + Utilities.bytesAsHexString(accountAgeWitnessSignatureOfOfferId) + - ",\n currentDate=" + currentDate + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxResponse.java b/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxResponse.java deleted file mode 100644 index 159b74236b..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/InputsForDepositTxResponse.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.core.btc.model.RawTransactionInput; -import bisq.core.payment.payload.PaymentAccountPayload; -import bisq.core.proto.CoreProtoResolver; - -import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; -import bisq.common.proto.ProtoUtil; -import bisq.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import java.util.Date; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -import javax.annotation.Nullable; - -@EqualsAndHashCode(callSuper = true) -@Value -public final class InputsForDepositTxResponse extends TradeMessage implements DirectMessage { - private final PaymentAccountPayload makerPaymentAccountPayload; - private final String makerAccountId; - private final byte[] makerMultiSigPubKey; - private final String makerContractAsJson; - private final String makerContractSignature; - private final String makerPayoutAddressString; - private final byte[] preparedDepositTx; - private final List makerInputs; - private final NodeAddress senderNodeAddress; - - // added in v 0.6. can be null if we trade with an older peer - @Nullable - private final byte[] accountAgeWitnessSignatureOfPreparedDepositTx; - private final long currentDate; - private final long lockTime; - - public InputsForDepositTxResponse(String tradeId, - PaymentAccountPayload makerPaymentAccountPayload, - String makerAccountId, - byte[] makerMultiSigPubKey, - String makerContractAsJson, - String makerContractSignature, - String makerPayoutAddressString, - byte[] preparedDepositTx, - List makerInputs, - NodeAddress senderNodeAddress, - String uid, - @Nullable byte[] accountAgeWitnessSignatureOfPreparedDepositTx, - long currentDate, - long lockTime) { - this(tradeId, - makerPaymentAccountPayload, - makerAccountId, - makerMultiSigPubKey, - makerContractAsJson, - makerContractSignature, - makerPayoutAddressString, - preparedDepositTx, - makerInputs, - senderNodeAddress, - uid, - Version.getP2PMessageVersion(), - accountAgeWitnessSignatureOfPreparedDepositTx, - currentDate, - lockTime); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private InputsForDepositTxResponse(String tradeId, - PaymentAccountPayload makerPaymentAccountPayload, - String makerAccountId, - byte[] makerMultiSigPubKey, - String makerContractAsJson, - String makerContractSignature, - String makerPayoutAddressString, - byte[] preparedDepositTx, - List makerInputs, - NodeAddress senderNodeAddress, - String uid, - String messageVersion, - @Nullable byte[] accountAgeWitnessSignatureOfPreparedDepositTx, - long currentDate, - long lockTime) { - super(messageVersion, tradeId, uid); - this.makerPaymentAccountPayload = makerPaymentAccountPayload; - this.makerAccountId = makerAccountId; - this.makerMultiSigPubKey = makerMultiSigPubKey; - this.makerContractAsJson = makerContractAsJson; - this.makerContractSignature = makerContractSignature; - this.makerPayoutAddressString = makerPayoutAddressString; - this.preparedDepositTx = preparedDepositTx; - this.makerInputs = makerInputs; - this.senderNodeAddress = senderNodeAddress; - this.accountAgeWitnessSignatureOfPreparedDepositTx = accountAgeWitnessSignatureOfPreparedDepositTx; - this.currentDate = currentDate; - this.lockTime = lockTime; - } - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - final protobuf.InputsForDepositTxResponse.Builder builder = protobuf.InputsForDepositTxResponse.newBuilder() - .setTradeId(tradeId) - .setMakerPaymentAccountPayload((protobuf.PaymentAccountPayload) makerPaymentAccountPayload.toProtoMessage()) - .setMakerAccountId(makerAccountId) - .setMakerMultiSigPubKey(ByteString.copyFrom(makerMultiSigPubKey)) - .setMakerContractAsJson(makerContractAsJson) - .setMakerContractSignature(makerContractSignature) - .setMakerPayoutAddressString(makerPayoutAddressString) - .setPreparedDepositTx(ByteString.copyFrom(preparedDepositTx)) - .addAllMakerInputs(makerInputs.stream().map(RawTransactionInput::toProtoMessage).collect(Collectors.toList())) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setUid(uid) - .setLockTime(lockTime); - - Optional.ofNullable(accountAgeWitnessSignatureOfPreparedDepositTx).ifPresent(e -> builder.setAccountAgeWitnessSignatureOfPreparedDepositTx(ByteString.copyFrom(e))); - builder.setCurrentDate(currentDate); - - return getNetworkEnvelopeBuilder() - .setInputsForDepositTxResponse(builder) - .build(); - } - - public static InputsForDepositTxResponse fromProto(protobuf.InputsForDepositTxResponse proto, CoreProtoResolver coreProtoResolver, String messageVersion) { - List makerInputs = proto.getMakerInputsList().stream() - .map(RawTransactionInput::fromProto) - .collect(Collectors.toList()); - - return new InputsForDepositTxResponse(proto.getTradeId(), - coreProtoResolver.fromProto(proto.getMakerPaymentAccountPayload()), - proto.getMakerAccountId(), - proto.getMakerMultiSigPubKey().toByteArray(), - proto.getMakerContractAsJson(), - proto.getMakerContractSignature(), - proto.getMakerPayoutAddressString(), - proto.getPreparedDepositTx().toByteArray(), - makerInputs, - NodeAddress.fromProto(proto.getSenderNodeAddress()), - proto.getUid(), - messageVersion, - ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessSignatureOfPreparedDepositTx()), - proto.getCurrentDate(), - proto.getLockTime()); - } - - - @Override - public String toString() { - return "InputsForDepositTxResponse{" + - "\n makerPaymentAccountPayload=" + makerPaymentAccountPayload + - ",\n makerAccountId='" + makerAccountId + '\'' + - ",\n makerMultiSigPubKey=" + Utilities.bytesAsHexString(makerMultiSigPubKey) + - ",\n makerContractAsJson='" + makerContractAsJson + '\'' + - ",\n makerContractSignature='" + makerContractSignature + '\'' + - ",\n makerPayoutAddressString='" + makerPayoutAddressString + '\'' + - ",\n preparedDepositTx=" + Utilities.bytesAsHexString(preparedDepositTx) + - ",\n makerInputs=" + makerInputs + - ",\n senderNodeAddress=" + senderNodeAddress + - ",\n uid='" + uid + '\'' + - ",\n accountAgeWitnessSignatureOfPreparedDepositTx=" + Utilities.bytesAsHexString(accountAgeWitnessSignatureOfPreparedDepositTx) + - ",\n currentDate=" + new Date(currentDate) + - ",\n lockTime=" + lockTime + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java deleted file mode 100644 index d9a885bd74..0000000000 --- a/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.messages; - -import bisq.network.p2p.NodeAddress; - -import bisq.common.app.Version; - -import lombok.EqualsAndHashCode; -import lombok.Value; - -@EqualsAndHashCode(callSuper = true) -@Value -public final class PeerPublishedDelayedPayoutTxMessage extends TradeMailboxMessage { - private final NodeAddress senderNodeAddress; - - public PeerPublishedDelayedPayoutTxMessage(String uid, - String tradeId, - NodeAddress senderNodeAddress) { - this(Version.getP2PMessageVersion(), - uid, - tradeId, - senderNodeAddress); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private PeerPublishedDelayedPayoutTxMessage(String messageVersion, - String uid, - String tradeId, - NodeAddress senderNodeAddress) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - } - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - final protobuf.PeerPublishedDelayedPayoutTxMessage.Builder builder = protobuf.PeerPublishedDelayedPayoutTxMessage.newBuilder(); - builder.setUid(uid) - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()); - return getNetworkEnvelopeBuilder().setPeerPublishedDelayedPayoutTxMessage(builder).build(); - } - - public static PeerPublishedDelayedPayoutTxMessage fromProto(protobuf.PeerPublishedDelayedPayoutTxMessage proto, String messageVersion) { - return new PeerPublishedDelayedPayoutTxMessage(messageVersion, - proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress())); - } - - @Override - public String toString() { - return "PeerPublishedDelayedPayoutTxMessage{" + - "\n senderNodeAddress=" + senderNodeAddress + - "\n} " + super.toString(); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/ArbitratorProtocol.java b/core/src/main/java/bisq/core/trade/protocol/ArbitratorProtocol.java index e8fb99589c..65bd3489ab 100644 --- a/core/src/main/java/bisq/core/trade/protocol/ArbitratorProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/ArbitratorProtocol.java @@ -75,7 +75,7 @@ public class ArbitratorProtocol extends DisputeProtocol { ArbitratorProcessesDepositRequest.class) .using(new TradeTaskRunner(trade, () -> { - if (trade.getState() == Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TX) { + if (trade.getState() == Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS) { stopTimeout(); this.errorMessageHandler = null; } diff --git a/core/src/main/java/bisq/core/trade/protocol/BuyerAsMakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/BuyerAsMakerProtocol.java index 23f2b1f759..30cc5a7ea8 100644 --- a/core/src/main/java/bisq/core/trade/protocol/BuyerAsMakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/BuyerAsMakerProtocol.java @@ -19,26 +19,16 @@ package bisq.core.trade.protocol; import bisq.core.trade.BuyerAsMakerTrade; import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; import bisq.core.trade.messages.DepositResponse; -import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage; import bisq.core.trade.messages.InitMultisigRequest; import bisq.core.trade.messages.InitTradeRequest; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.PaymentReceivedMessage; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; +import bisq.core.trade.protocol.tasks.MakerSendsInitTradeRequestIfUnreserved; import bisq.core.trade.protocol.tasks.ProcessInitTradeRequest; import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.buyer.BuyerFinalizesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.buyer.BuyerSendsDelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.buyer.BuyerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerVerifiesPreparedDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.maker.MaybeRemoveOpenOffer; -import bisq.core.trade.protocol.tasks.maker.MakerSendsInitTradeRequestIfUnreserved; -import bisq.core.trade.protocol.tasks.maker.MakerVerifyTakerFeePayment; - import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; import bisq.common.handlers.ResultHandler; @@ -134,37 +124,4 @@ public class BuyerAsMakerProtocol extends BuyerProtocol implements MakerProtocol protected void handle(PaymentReceivedMessage message, NodeAddress peer) { super.handle(message, peer); } - - @Override - protected Class getVerifyPeersFeePaymentClass() { - return MakerVerifyTakerFeePayment.class; - } - - // TODO (woodser): remove or ignore any unsupported requests - - /////////////////////////////////////////////////////////////////////////////////////////// - // Incoming messages Take offer process - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - protected void handle(DelayedPayoutTxSignatureRequest message, NodeAddress peer) { - expect(phase(Trade.Phase.TAKER_FEE_PUBLISHED) - .with(message) - .from(peer)) - .setup(tasks( - MaybeRemoveOpenOffer.class, - BuyerProcessDelayedPayoutTxSignatureRequest.class, - BuyerVerifiesPreparedDelayedPayoutTx.class, - BuyerSignsDelayedPayoutTx.class, - BuyerFinalizesDelayedPayoutTx.class, - BuyerSendsDelayedPayoutTxSignatureResponse.class) - .withTimeout(60)) - .executeTasks(true); - } - - // We keep the handler here in as well to make it more transparent which messages we expect - @Override - protected void handle(DepositTxAndDelayedPayoutTxMessage message, NodeAddress peer) { - super.handle(message, peer); - } } diff --git a/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java index 1873ef97e5..f9803d3ef6 100644 --- a/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java @@ -22,32 +22,14 @@ import bisq.core.offer.Offer; import bisq.core.trade.BuyerAsTakerTrade; import bisq.core.trade.Trade; import bisq.core.trade.handlers.TradeResultHandler; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; import bisq.core.trade.messages.DepositResponse; -import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage; import bisq.core.trade.messages.InitMultisigRequest; -import bisq.core.trade.messages.InputsForDepositTxResponse; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.PaymentReceivedMessage; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.protocol.tasks.ApplyFilter; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness; -import bisq.core.trade.protocol.tasks.buyer.BuyerFinalizesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.buyer.BuyerSendsDelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.buyer.BuyerSetupDepositTxListener; -import bisq.core.trade.protocol.tasks.buyer.BuyerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerVerifiesPreparedDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer_as_taker.BuyerAsTakerSendsDepositTxMessage; -import bisq.core.trade.protocol.tasks.buyer_as_taker.BuyerAsTakerSignsDepositTx; -import bisq.core.trade.protocol.tasks.taker.TakerProcessesInputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.taker.TakerPublishFeeTx; -import bisq.core.trade.protocol.tasks.taker.TakerReservesTradeFunds; -import bisq.core.trade.protocol.tasks.taker.TakerSendsInitTradeRequestToArbitrator; -import bisq.core.trade.protocol.tasks.taker.TakerVerifyMakerFeePayment; import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; import bisq.common.handlers.ResultHandler; @@ -56,7 +38,6 @@ import lombok.extern.slf4j.Slf4j; import static com.google.common.base.Preconditions.checkNotNull; -// TODO (woodser): remove unused request handling @Slf4j public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol { @@ -159,57 +140,5 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol @Override protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); - - if (message instanceof InputsForDepositTxResponse) { - handle((InputsForDepositTxResponse) message, peer); - } - } - - @Override - protected Class getVerifyPeersFeePaymentClass() { - return TakerVerifyMakerFeePayment.class; - } - - // TODO (woodser): remove unused - - /////////////////////////////////////////////////////////////////////////////////////////// - // Incoming messages Take offer process - /////////////////////////////////////////////////////////////////////////////////////////// - - private void handle(InputsForDepositTxResponse message, NodeAddress peer) { - expect(phase(Trade.Phase.INIT) - .with(message) - .from(peer)) - .setup(tasks(TakerProcessesInputsForDepositTxResponse.class, - ApplyFilter.class, - VerifyPeersAccountAgeWitness.class, - //TakerVerifyAndSignContract.class, - TakerPublishFeeTx.class, - BuyerAsTakerSignsDepositTx.class, - BuyerSetupDepositTxListener.class, - BuyerAsTakerSendsDepositTxMessage.class) - .withTimeout(60)) - .executeTasks(true); - } - - @Override - protected void handle(DelayedPayoutTxSignatureRequest message, NodeAddress peer) { - expect(phase(Trade.Phase.TAKER_FEE_PUBLISHED) - .with(message) - .from(peer)) - .setup(tasks( - BuyerProcessDelayedPayoutTxSignatureRequest.class, - BuyerVerifiesPreparedDelayedPayoutTx.class, - BuyerSignsDelayedPayoutTx.class, - BuyerFinalizesDelayedPayoutTx.class, - BuyerSendsDelayedPayoutTxSignatureResponse.class) - .withTimeout(60)) - .executeTasks(true); - } - - // We keep the handler here in as well to make it more transparent which messages we expect - @Override - protected void handle(DepositTxAndDelayedPayoutTxMessage message, NodeAddress peer) { - super.handle(message, peer); } } diff --git a/core/src/main/java/bisq/core/trade/protocol/BuyerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/BuyerProtocol.java index 2ceb6b2cd0..e49f35bd15 100644 --- a/core/src/main/java/bisq/core/trade/protocol/BuyerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/BuyerProtocol.java @@ -19,17 +19,14 @@ package bisq.core.trade.protocol; import bisq.core.trade.BuyerTrade; import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; -import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage; import bisq.core.trade.messages.PaymentReceivedMessage; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.protocol.tasks.ApplyFilter; +import bisq.core.trade.protocol.tasks.BuyerPreparesPaymentSentMessage; +import bisq.core.trade.protocol.tasks.BuyerProcessesPaymentReceivedMessage; +import bisq.core.trade.protocol.tasks.BuyerSendsPaymentSentMessage; +import bisq.core.trade.protocol.tasks.BuyerSetupPayoutTxListener; import bisq.core.trade.protocol.tasks.SetupDepositTxsListener; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.buyer.BuyerPreparesPaymentSentMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessesPaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerSendsPaymentSentMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerSetupPayoutTxListener; import bisq.core.util.Validator; import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; @@ -77,49 +74,11 @@ public abstract class BuyerProtocol extends DisputeProtocol { @Override public void onMailboxMessage(TradeMessage message, NodeAddress peer) { super.onMailboxMessage(message, peer); - - if (message instanceof DepositTxAndDelayedPayoutTxMessage) { - handle((DepositTxAndDelayedPayoutTxMessage) message, peer); - } else if (message instanceof PaymentReceivedMessage) { + if (message instanceof PaymentReceivedMessage) { handle((PaymentReceivedMessage) message, peer); } } - protected abstract void handle(DelayedPayoutTxSignatureRequest message, NodeAddress peer); - - // The DepositTxAndDelayedPayoutTxMessage is a mailbox message as earlier we use only the deposit tx which can - // be also with from the network once published. - // Now we send the delayed payout tx as well and with that this message is mandatory for continuing the protocol. - // We do not support mailbox message handling during the take offer process as it is expected that both peers - // are online. - // For backward compatibility and extra resilience we still keep DepositTxAndDelayedPayoutTxMessage as a - // mailbox message but the stored in mailbox case is not expected and the seller would try to send the message again - // in the hope to reach the buyer directly. - protected void handle(DepositTxAndDelayedPayoutTxMessage message, NodeAddress peer) { -// expect(anyPhase(Trade.Phase.TAKER_FEE_PUBLISHED, Trade.Phase.DEPOSIT_PUBLISHED) -// .with(message) -// .from(peer) -// .preCondition(trade.getDepositTx() == null || trade.getDelayedPayoutTx() == null, -// () -> { -// log.warn("We with a DepositTxAndDelayedPayoutTxMessage but we have already processed the deposit and " + -// "delayed payout tx so we ignore the message. This can happen if the ACK message to the peer did not " + -// "arrive and the peer repeats sending us the message. We send another ACK msg."); -// stopTimeout(); -// sendAckMessage(message, true, null); -// removeMailboxMessageAfterProcessing(message); -// })) -// .setup(tasks(BuyerProcessDepositTxAndDelayedPayoutTxMessage.class, -// BuyerVerifiesFinalDelayedPayoutTx.class) -// .using(new TradeTaskRunner(trade, -// () -> { -// stopTimeout(); -// handleTaskRunnerSuccess(message); -// }, -// errorMessage -> handleTaskRunnerFault(message, errorMessage)))) -// .run(() -> processModel.witnessDebugLog(trade)) -// .executeTasks(); - } - /////////////////////////////////////////////////////////////////////////////////////////// // User interaction /////////////////////////////////////////////////////////////////////////////////////////// @@ -135,7 +94,6 @@ public abstract class BuyerProtocol extends DisputeProtocol { .with(event) .preCondition(trade.confirmPermitted())) .setup(tasks(ApplyFilter.class, - getVerifyPeersFeePaymentClass(), //UpdateMultisigWithTradingPeer.class, // TODO (woodser): can use this to test protocol with updated multisig from peer. peer should attempt to send updated multisig hex earlier as part of protocol. cannot use with countdown latch because response comes back in a separate thread and blocks on trade BuyerPreparesPaymentSentMessage.class, //BuyerSetupPayoutTxListener.class, @@ -170,7 +128,6 @@ public abstract class BuyerProtocol extends DisputeProtocol { .with(message) .from(peer)) .setup(tasks( - getVerifyPeersFeePaymentClass(), BuyerProcessesPaymentReceivedMessage.class) .using(new TradeTaskRunner(trade, () -> { @@ -192,15 +149,8 @@ public abstract class BuyerProtocol extends DisputeProtocol { @Override protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); - - if (message instanceof DelayedPayoutTxSignatureRequest) { - handle((DelayedPayoutTxSignatureRequest) message, peer); - } else if (message instanceof DepositTxAndDelayedPayoutTxMessage) { - handle((DepositTxAndDelayedPayoutTxMessage) message, peer); - } else if (message instanceof PaymentReceivedMessage) { + if (message instanceof PaymentReceivedMessage) { handle((PaymentReceivedMessage) message, peer); } } - - abstract protected Class getVerifyPeersFeePaymentClass(); } diff --git a/core/src/main/java/bisq/core/trade/protocol/DisputeProtocol.java b/core/src/main/java/bisq/core/trade/protocol/DisputeProtocol.java index eb542428e2..5762919a55 100644 --- a/core/src/main/java/bisq/core/trade/protocol/DisputeProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/DisputeProtocol.java @@ -20,11 +20,8 @@ package bisq.core.trade.protocol; import bisq.core.trade.Trade; import bisq.core.trade.messages.MediatedPayoutTxPublishedMessage; import bisq.core.trade.messages.MediatedPayoutTxSignatureMessage; -import bisq.core.trade.messages.PeerPublishedDelayedPayoutTxMessage; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.protocol.tasks.ApplyFilter; -import bisq.core.trade.protocol.tasks.ProcessPeerPublishedDelayedPayoutTxMessage; -import bisq.core.trade.protocol.tasks.mediation.BroadcastMediatedPayoutTx; import bisq.core.trade.protocol.tasks.mediation.FinalizeMediatedPayoutTx; import bisq.core.trade.protocol.tasks.mediation.ProcessMediatedPayoutSignatureMessage; import bisq.core.trade.protocol.tasks.mediation.ProcessMediatedPayoutTxPublishedMessage; @@ -97,7 +94,6 @@ public abstract class DisputeProtocol extends TradeProtocol { .setup(tasks(ApplyFilter.class, SignMediatedPayoutTx.class, FinalizeMediatedPayoutTx.class, - BroadcastMediatedPayoutTx.class, SendMediatedPayoutTxPublishedMessage.class) .using(new TradeTaskRunner(trade, () -> { @@ -162,21 +158,6 @@ public abstract class DisputeProtocol extends TradeProtocol { // } - /////////////////////////////////////////////////////////////////////////////////////////// - // Peer has published the delayed payout tx - /////////////////////////////////////////////////////////////////////////////////////////// - - private void handle(PeerPublishedDelayedPayoutTxMessage message, NodeAddress peer) { - expect(anyPhase(Trade.Phase.DEPOSIT_UNLOCKED, - Trade.Phase.PAYMENT_SENT, - Trade.Phase.PAYMENT_RECEIVED) - .with(message) - .from(peer)) - .setup(tasks(ProcessPeerPublishedDelayedPayoutTxMessage.class)) - .executeTasks(); - } - - /////////////////////////////////////////////////////////////////////////////////////////// // Dispatcher /////////////////////////////////////////////////////////////////////////////////////////// @@ -187,8 +168,6 @@ public abstract class DisputeProtocol extends TradeProtocol { handle((MediatedPayoutTxSignatureMessage) message, peer); } else if (message instanceof MediatedPayoutTxPublishedMessage) { handle((MediatedPayoutTxPublishedMessage) message, peer); - } else if (message instanceof PeerPublishedDelayedPayoutTxMessage) { - handle((PeerPublishedDelayedPayoutTxMessage) message, peer); } } @@ -199,8 +178,6 @@ public abstract class DisputeProtocol extends TradeProtocol { handle((MediatedPayoutTxSignatureMessage) message, peer); } else if (message instanceof MediatedPayoutTxPublishedMessage) { handle((MediatedPayoutTxPublishedMessage) message, peer); - } else if (message instanceof PeerPublishedDelayedPayoutTxMessage) { - handle((PeerPublishedDelayedPayoutTxMessage) message, peer); } } } diff --git a/core/src/main/java/bisq/core/trade/protocol/SellerAsMakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/SellerAsMakerProtocol.java index 69d415ef85..daf5f44d6e 100644 --- a/core/src/main/java/bisq/core/trade/protocol/SellerAsMakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/SellerAsMakerProtocol.java @@ -24,21 +24,12 @@ import bisq.core.trade.messages.PaymentSentMessage; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; import bisq.core.trade.messages.DepositResponse; -import bisq.core.trade.messages.DepositTxMessage; import bisq.core.trade.messages.InitMultisigRequest; import bisq.core.trade.messages.InitTradeRequest; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.TradeMessage; +import bisq.core.trade.protocol.tasks.MakerSendsInitTradeRequestIfUnreserved; import bisq.core.trade.protocol.tasks.ProcessInitTradeRequest; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.maker.MaybeRemoveOpenOffer; -import bisq.core.trade.protocol.tasks.maker.MakerSendsInitTradeRequestIfUnreserved; -import bisq.core.trade.protocol.tasks.maker.MakerVerifyTakerFeePayment; -import bisq.core.trade.protocol.tasks.seller.SellerCreatesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller.SellerSendDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.seller.SellerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerFinalizesDepositTx; -import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerProcessDepositTxMessage; import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; import bisq.common.handlers.ResultHandler; @@ -132,42 +123,9 @@ public class SellerAsMakerProtocol extends SellerProtocol implements MakerProtoc @Override protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); - - log.info("Received {} from {} with tradeId {} and uid {}", - message.getClass().getSimpleName(), peer, message.getTradeId(), message.getUid()); - - if (message instanceof DepositTxMessage) { - handle((DepositTxMessage) message, peer); - } + log.info("Received {} from {} with tradeId {} and uid {}", message.getClass().getSimpleName(), peer, message.getTradeId(), message.getUid()); } - @Override - protected Class getVerifyPeersFeePaymentClass() { - return MakerVerifyTakerFeePayment.class; - } - - // TODO (woodser): remove unused - - /////////////////////////////////////////////////////////////////////////////////////////// - // Incoming messages Take offer process - /////////////////////////////////////////////////////////////////////////////////////////// - - protected void handle(DepositTxMessage message, NodeAddress peer) { - expect(phase(Trade.Phase.TAKER_FEE_PUBLISHED) - .with(message) - .from(peer)) - .setup(tasks( - MaybeRemoveOpenOffer.class, - SellerAsMakerProcessDepositTxMessage.class, - SellerAsMakerFinalizesDepositTx.class, - SellerCreatesDelayedPayoutTx.class, - SellerSignsDelayedPayoutTx.class, - SellerSendDelayedPayoutTxSignatureRequest.class) - .withTimeout(60)) - .executeTasks(true); - } - - /////////////////////////////////////////////////////////////////////////////////////////// // Incoming message when buyer has clicked payment started button /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java index 2aa35196b1..b5ff7bef92 100644 --- a/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java @@ -27,22 +27,9 @@ import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; import bisq.core.trade.messages.DepositResponse; import bisq.core.trade.messages.InitMultisigRequest; -import bisq.core.trade.messages.InputsForDepositTxResponse; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.protocol.tasks.ApplyFilter; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness; -import bisq.core.trade.protocol.tasks.seller.SellerCreatesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller.SellerSendDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.seller.SellerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller_as_taker.SellerAsTakerSignsDepositTx; -import bisq.core.trade.protocol.tasks.taker.TakerProcessesInputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.taker.TakerPublishFeeTx; -import bisq.core.trade.protocol.tasks.taker.TakerReservesTradeFunds; -import bisq.core.trade.protocol.tasks.taker.TakerSendsInitTradeRequestToArbitrator; -import bisq.core.trade.protocol.tasks.taker.TakerVerifyMakerFeePayment; - import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; import bisq.common.handlers.ResultHandler; @@ -152,41 +139,6 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc @Override protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); - - log.info("Received {} from {} with tradeId {} and uid {}", - message.getClass().getSimpleName(), peer, message.getTradeId(), message.getUid()); - - if (message instanceof InputsForDepositTxResponse) { - handle((InputsForDepositTxResponse) message, peer); - } - } - - @Override - protected Class getVerifyPeersFeePaymentClass() { - return TakerVerifyMakerFeePayment.class; - } - - // TODO (woodser): remove unused calls and classes - - /////////////////////////////////////////////////////////////////////////////////////////// - // Incoming messages Take offer process - /////////////////////////////////////////////////////////////////////////////////////////// - - private void handle(InputsForDepositTxResponse message, NodeAddress peer) { - expect(phase(Trade.Phase.INIT) - .with(message) - .from(peer)) - .setup(tasks( - TakerProcessesInputsForDepositTxResponse.class, - ApplyFilter.class, - VerifyPeersAccountAgeWitness.class, - //TakerVerifyAndSignContract.class, - TakerPublishFeeTx.class, - SellerAsTakerSignsDepositTx.class, - SellerCreatesDelayedPayoutTx.class, - SellerSignsDelayedPayoutTx.class, - SellerSendDelayedPayoutTxSignatureRequest.class) - .withTimeout(60)) - .executeTasks(true); + log.info("Received {} from {} with tradeId {} and uid {}", message.getClass().getSimpleName(), peer, message.getTradeId(), message.getUid()); } } diff --git a/core/src/main/java/bisq/core/trade/protocol/SellerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/SellerProtocol.java index 269bef3922..7dfadc476b 100644 --- a/core/src/main/java/bisq/core/trade/protocol/SellerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/SellerProtocol.java @@ -23,12 +23,10 @@ import bisq.core.trade.messages.PaymentSentMessage; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.protocol.BuyerProtocol.BuyerEvent; import bisq.core.trade.protocol.tasks.ApplyFilter; +import bisq.core.trade.protocol.tasks.SellerPreparesPaymentReceivedMessage; +import bisq.core.trade.protocol.tasks.SellerProcessesPaymentSentMessage; +import bisq.core.trade.protocol.tasks.SellerSendsPaymentReceivedMessage; import bisq.core.trade.protocol.tasks.SetupDepositTxsListener; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.trade.protocol.tasks.seller.SellerProcessesPaymentSentMessage; -import bisq.core.trade.protocol.tasks.seller.SellerSendsPaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.seller.SellerPreparesPaymentReceivedMessage; - import bisq.network.p2p.NodeAddress; import bisq.common.handlers.ErrorMessageHandler; import bisq.common.handlers.ResultHandler; @@ -100,9 +98,8 @@ public abstract class SellerProtocol extends DisputeProtocol { removeMailboxMessageAfterProcessing(message); })) .setup(tasks( - SellerProcessesPaymentSentMessage.class, ApplyFilter.class, - getVerifyPeersFeePaymentClass()) + SellerProcessesPaymentSentMessage.class) .using(new TradeTaskRunner(trade, () -> { stopTimeout(); @@ -134,7 +131,6 @@ public abstract class SellerProtocol extends DisputeProtocol { .preCondition(trade.confirmPermitted())) .setup(tasks( ApplyFilter.class, - getVerifyPeersFeePaymentClass(), SellerPreparesPaymentReceivedMessage.class, SellerSendsPaymentReceivedMessage.class) .using(new TradeTaskRunner(trade, () -> { @@ -159,7 +155,4 @@ public abstract class SellerProtocol extends DisputeProtocol { handle((PaymentSentMessage) message, peer); } } - - abstract protected Class getVerifyPeersFeePaymentClass(); - } diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerReservesTradeFunds.java b/core/src/main/java/bisq/core/trade/protocol/TakerReservesTradeFunds.java similarity index 98% rename from core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerReservesTradeFunds.java rename to core/src/main/java/bisq/core/trade/protocol/TakerReservesTradeFunds.java index 1fb9e5a0c9..175003a8b9 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerReservesTradeFunds.java +++ b/core/src/main/java/bisq/core/trade/protocol/TakerReservesTradeFunds.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.taker; +package bisq.core.trade.protocol; import bisq.common.taskrunner.TaskRunner; import bisq.core.btc.model.XmrAddressEntry; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerSendsInitTradeRequestToArbitrator.java b/core/src/main/java/bisq/core/trade/protocol/TakerSendsInitTradeRequestToArbitrator.java similarity index 99% rename from core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerSendsInitTradeRequestToArbitrator.java rename to core/src/main/java/bisq/core/trade/protocol/TakerSendsInitTradeRequestToArbitrator.java index 346e0cf61d..e3bfc14cb0 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerSendsInitTradeRequestToArbitrator.java +++ b/core/src/main/java/bisq/core/trade/protocol/TakerSendsInitTradeRequestToArbitrator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.taker; +package bisq.core.trade.protocol; import bisq.core.support.dispute.arbitration.arbitrator.Arbitrator; import bisq.core.trade.Trade; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerVerifyMakerFeePayment.java b/core/src/main/java/bisq/core/trade/protocol/TakerVerifyMakerFeePayment.java similarity index 97% rename from core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerVerifyMakerFeePayment.java rename to core/src/main/java/bisq/core/trade/protocol/TakerVerifyMakerFeePayment.java index 43a2e23954..5f3849cf98 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerVerifyMakerFeePayment.java +++ b/core/src/main/java/bisq/core/trade/protocol/TakerVerifyMakerFeePayment.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.taker; +package bisq.core.trade.protocol; import bisq.core.trade.Trade; import bisq.core.trade.protocol.tasks.TradeTask; diff --git a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java index fba55daa80..9a9d21e586 100644 --- a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java @@ -24,13 +24,13 @@ import bisq.core.trade.TradeUtils; import bisq.core.trade.handlers.TradeResultHandler; import bisq.core.trade.messages.PaymentSentMessage; import bisq.core.trade.messages.DepositResponse; -import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage; import bisq.core.trade.messages.InitMultisigRequest; import bisq.core.trade.messages.PaymentAccountPayloadRequest; import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.messages.UpdateMultisigRequest; +import bisq.core.trade.protocol.tasks.MaybeRemoveOpenOffer; import bisq.core.trade.protocol.tasks.MaybeSendSignContractRequest; import bisq.core.trade.protocol.tasks.ProcessDepositResponse; import bisq.core.trade.protocol.tasks.ProcessInitMultisigRequest; @@ -38,7 +38,6 @@ import bisq.core.trade.protocol.tasks.ProcessPaymentAccountPayloadRequest; import bisq.core.trade.protocol.tasks.ProcessSignContractRequest; import bisq.core.trade.protocol.tasks.ProcessSignContractResponse; import bisq.core.trade.protocol.tasks.ProcessUpdateMultisigRequest; -import bisq.core.trade.protocol.tasks.maker.MaybeRemoveOpenOffer; import bisq.core.util.Validator; import bisq.network.p2p.AckMessage; @@ -324,7 +323,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D latchTrade(); Validator.checkTradeId(processModel.getOfferId(), response); processModel.setTradeMessage(response); - expect(state(Trade.State.MAKER_SENT_PUBLISH_DEPOSIT_TX_REQUEST) + expect(state(Trade.State.SENT_PUBLISH_DEPOSIT_TX_REQUEST) .with(response) .from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress() .setup(tasks( @@ -348,11 +347,11 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D System.out.println(getClass().getCanonicalName() + ".handlePaymentAccountPayloadRequest()"); synchronized (trade) { Validator.checkTradeId(processModel.getOfferId(), request); - if (trade.getState() == Trade.State.MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG) { + if (trade.getState() == Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS) { latchTrade(); Validator.checkTradeId(processModel.getOfferId(), request); processModel.setTradeMessage(request); - expect(state(Trade.State.MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG) + expect(state(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS) .with(request) .from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress() .setup(tasks( @@ -374,7 +373,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D awaitTradeLatch(); } else { EasyBind.subscribe(trade.stateProperty(), state -> { - if (state == Trade.State.MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG) new Thread(() -> handlePaymentAccountPayloadRequest(request, sender)).start(); // process notification without trade lock + if (state == Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS) new Thread(() -> handlePaymentAccountPayloadRequest(request, sender)).start(); // process notification without trade lock }); } } @@ -459,8 +458,6 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D // TODO (woodser): add AckMessage for InitTradeRequest and support automatic re-send ? if (ackMessage.getSourceMsgClassName().equals(PaymentSentMessage.class.getSimpleName())) { processModel.setPaymentStartedAckMessage(ackMessage); - } else if (ackMessage.getSourceMsgClassName().equals(DepositTxAndDelayedPayoutTxMessage.class.getSimpleName())) { - processModel.setDepositTxSentAckMessage(ackMessage); } if (ackMessage.isSuccess()) { diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessesDepositRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessesDepositRequest.java index d5a40ac16d..3b8f8687ae 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessesDepositRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessesDepositRequest.java @@ -113,7 +113,7 @@ public class ArbitratorProcessesDepositRequest extends TradeTask { // update trade state log.info("Arbitrator submitted deposit txs for trade " + trade.getId()); - trade.setState(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TX); + trade.setState(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS); // create deposit response DepositResponse response = new DepositResponse( diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/BroadcastPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BroadcastPayoutTx.java deleted file mode 100644 index 52917b9e0f..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/BroadcastPayoutTx.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks; - -import bisq.core.trade.Trade; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - - - -import monero.wallet.model.MoneroTxWallet; - -@Slf4j -public abstract class BroadcastPayoutTx extends TradeTask { - public BroadcastPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - protected abstract void setState(); - - @Override - protected void run() { - try { - runInterceptHook(); - if (true) throw new RuntimeException("BroadcastPayoutTx not implemented for xmr"); - MoneroTxWallet payoutTx = trade.getPayoutTx(); - checkNotNull(payoutTx, "payoutTx must not be null"); - - - if (payoutTx.isRelayed()) { - log.debug("payoutTx was already published"); - setState(); - complete(); - } else { - try { - processModel.getProvider().getXmrWalletService().getWallet().relayTx(payoutTx); - if (!completed) { - log.debug("BroadcastTx succeeded. Transaction:" + payoutTx); - setState(); - complete(); - } else { - log.warn("We got the onSuccess callback called after the timeout has been triggered a complete()."); - } - } catch (Exception e) { - if (!completed) { - log.error("BroadcastTx failed. Error:" + e.getMessage()); - failed(e); - } else { - log.warn("We got the onFailure callback called after the timeout has been triggered a complete()."); - } - } - } - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerPreparesPaymentSentMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerPreparesPaymentSentMessage.java similarity index 98% rename from core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerPreparesPaymentSentMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/BuyerPreparesPaymentSentMessage.java index ade60aca0a..8070fa863c 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerPreparesPaymentSentMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerPreparesPaymentSentMessage.java @@ -15,12 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.buyer; +package bisq.core.trade.protocol.tasks; import bisq.core.btc.wallet.XmrWalletService; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import com.google.common.base.Preconditions; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessesPaymentReceivedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerProcessesPaymentReceivedMessage.java similarity index 97% rename from core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessesPaymentReceivedMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/BuyerProcessesPaymentReceivedMessage.java index b11b1bd73b..04f7ccbba3 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessesPaymentReceivedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerProcessesPaymentReceivedMessage.java @@ -15,13 +15,12 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.buyer; +package bisq.core.trade.protocol.tasks; import bisq.core.account.sign.SignedWitness; import bisq.core.btc.wallet.XmrWalletService; import bisq.core.trade.Trade; import bisq.core.trade.messages.PaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.TradeTask; import bisq.core.util.Validator; import bisq.common.taskrunner.TaskRunner; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsPaymentSentMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSendsPaymentSentMessage.java similarity index 98% rename from core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsPaymentSentMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSendsPaymentSentMessage.java index 4c757c6a27..10d7fca64e 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsPaymentSentMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSendsPaymentSentMessage.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.buyer; +package bisq.core.trade.protocol.tasks; import bisq.core.btc.model.XmrAddressEntry; import bisq.core.btc.wallet.XmrWalletService; @@ -24,8 +24,6 @@ import bisq.core.trade.Trade; import bisq.core.trade.messages.PaymentSentMessage; import bisq.core.trade.messages.TradeMailboxMessage; import bisq.core.trade.messages.TradeMessage; -import bisq.core.trade.protocol.tasks.SendMailboxMessageTask; - import bisq.common.Timer; import bisq.common.UserThread; import bisq.common.taskrunner.TaskRunner; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupDepositTxListener.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupDepositTxListener.java similarity index 98% rename from core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupDepositTxListener.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupDepositTxListener.java index be52815e67..c896581a30 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupDepositTxListener.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupDepositTxListener.java @@ -15,12 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.buyer; +package bisq.core.trade.protocol.tasks; import bisq.core.btc.listeners.AddressConfidenceListener; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import org.fxmisc.easybind.Subscription; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupPayoutTxListener.java b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupPayoutTxListener.java similarity index 92% rename from core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupPayoutTxListener.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupPayoutTxListener.java index 0228e352d4..a122455551 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSetupPayoutTxListener.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/BuyerSetupPayoutTxListener.java @@ -15,11 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.buyer; +package bisq.core.trade.protocol.tasks; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.SetupPayoutTxListener; - import bisq.common.taskrunner.TaskRunner; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInitTradeRequestIfUnreserved.java b/core/src/main/java/bisq/core/trade/protocol/tasks/MakerSendsInitTradeRequestIfUnreserved.java similarity index 98% rename from core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInitTradeRequestIfUnreserved.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/MakerSendsInitTradeRequestIfUnreserved.java index 5852804dbf..b0c654661e 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInitTradeRequestIfUnreserved.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/MakerSendsInitTradeRequestIfUnreserved.java @@ -15,14 +15,12 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.maker; +package bisq.core.trade.protocol.tasks; import bisq.core.btc.model.XmrAddressEntry; import bisq.core.offer.Offer; import bisq.core.trade.Trade; import bisq.core.trade.messages.InitTradeRequest; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.network.p2p.SendDirectMessageListener; import bisq.common.app.Version; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSetsLockTime.java b/core/src/main/java/bisq/core/trade/protocol/tasks/MakerSetsLockTime.java similarity index 95% rename from core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSetsLockTime.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/MakerSetsLockTime.java index 96471970df..70da94a75b 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSetsLockTime.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/MakerSetsLockTime.java @@ -15,12 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.maker; +package bisq.core.trade.protocol.tasks; import bisq.core.btc.wallet.Restrictions; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.config.Config; import bisq.common.taskrunner.TaskRunner; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MaybeRemoveOpenOffer.java b/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeRemoveOpenOffer.java similarity index 93% rename from core/src/main/java/bisq/core/trade/protocol/tasks/maker/MaybeRemoveOpenOffer.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/MaybeRemoveOpenOffer.java index 1352953bb3..4957e29bbb 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MaybeRemoveOpenOffer.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeRemoveOpenOffer.java @@ -15,12 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.maker; +package bisq.core.trade.protocol.tasks; import bisq.core.trade.MakerTrade; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositResponse.java index 586d378de9..d246b108f6 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositResponse.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositResponse.java @@ -41,7 +41,7 @@ public class ProcessDepositResponse extends TradeTask { runInterceptHook(); // arbitrator has broadcast deposit txs - trade.setState(Trade.State.MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG); // TODO (woodser): maker and taker? + trade.setState(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS); // set payment account payload trade.getSelf().setPaymentAccountPayload(processModel.getPaymentAccountPayload(trade)); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPeerPublishedDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPeerPublishedDelayedPayoutTxMessage.java deleted file mode 100644 index c6e019e0cb..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPeerPublishedDelayedPayoutTxMessage.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks; - -import bisq.core.trade.Trade; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class ProcessPeerPublishedDelayedPayoutTxMessage extends TradeTask { - public ProcessPeerPublishedDelayedPayoutTxMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("XMR adaptation does not support delayed payout tx"); - -// PeerPublishedDelayedPayoutTxMessage message = (PeerPublishedDelayedPayoutTxMessage) processModel.getTradeMessage(); -// Validator.checkTradeId(processModel.getOfferId(), message); -// checkNotNull(message); -// -// // update to the latest peer address of our peer if the message is correct -// trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); -// -// // We add the tx to our wallet. -// Transaction delayedPayoutTx = checkNotNull(trade.getDelayedPayoutTx()); -// WalletService.maybeAddSelfTxToWallet(delayedPayoutTx, processModel.getBtcWalletService().getWallet()); -// -// processModel.getTradeManager().requestPersistence(); -// -// complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractResponse.java index 77ef49adb6..a821a29b6c 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractResponse.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractResponse.java @@ -88,7 +88,7 @@ public class ProcessSignContractResponse extends TradeTask { @Override public void onArrived() { log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), request.getUid()); - trade.setState(Trade.State.MAKER_SENT_PUBLISH_DEPOSIT_TX_REQUEST); // TODO: rename to DEPOSIT_REQUESTED + trade.setState(Trade.State.SENT_PUBLISH_DEPOSIT_TX_REQUEST); // TODO: rename to DEPOSIT_REQUESTED processModel.getTradeManager().requestPersistence(); complete(); } diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPreparesPaymentReceivedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPreparesPaymentReceivedMessage.java similarity index 95% rename from core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPreparesPaymentReceivedMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/SellerPreparesPaymentReceivedMessage.java index 5012315d92..4e9ca1d331 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPreparesPaymentReceivedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPreparesPaymentReceivedMessage.java @@ -15,11 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.seller; +package bisq.core.trade.protocol.tasks; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessesPaymentSentMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerProcessesPaymentSentMessage.java similarity index 97% rename from core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessesPaymentSentMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/SellerProcessesPaymentSentMessage.java index 52ddb956b0..99b12ae6df 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessesPaymentSentMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerProcessesPaymentSentMessage.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.seller; +package bisq.core.trade.protocol.tasks; import static com.google.common.base.Preconditions.checkNotNull; @@ -23,7 +23,6 @@ import bisq.common.taskrunner.TaskRunner; import bisq.core.btc.wallet.XmrWalletService; import bisq.core.trade.Trade; import bisq.core.trade.messages.PaymentSentMessage; -import bisq.core.trade.protocol.tasks.TradeTask; import bisq.core.util.Validator; import lombok.extern.slf4j.Slf4j; import monero.wallet.MoneroWallet; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesDepositTx.java similarity index 96% rename from core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesDepositTx.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesDepositTx.java index 596d3e7139..a7593ebc20 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesDepositTx.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesDepositTx.java @@ -15,11 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.seller; +package bisq.core.trade.protocol.tasks; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesTradeStatistics.java b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesTradeStatistics.java similarity index 96% rename from core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesTradeStatistics.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesTradeStatistics.java index 1c768972ac..4a25acec0a 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerPublishesTradeStatistics.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerPublishesTradeStatistics.java @@ -15,11 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.seller; +package bisq.core.trade.protocol.tasks; import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - import bisq.common.taskrunner.TaskRunner; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendsPaymentReceivedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerSendsPaymentReceivedMessage.java similarity index 97% rename from core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendsPaymentReceivedMessage.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/SellerSendsPaymentReceivedMessage.java index 7eed00613a..a1d617bf70 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendsPaymentReceivedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/SellerSendsPaymentReceivedMessage.java @@ -15,15 +15,13 @@ * along with Haveno. If not, see . */ -package bisq.core.trade.protocol.tasks.seller; +package bisq.core.trade.protocol.tasks; import bisq.core.account.sign.SignedWitness; import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.trade.Trade; import bisq.core.trade.messages.PaymentReceivedMessage; import bisq.core.trade.messages.TradeMailboxMessage; -import bisq.core.trade.protocol.tasks.SendMailboxMessageTask; - import bisq.common.taskrunner.TaskRunner; import lombok.EqualsAndHashCode; diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/PublishedDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/PublishedDelayedPayoutTx.java deleted file mode 100644 index 43697d739d..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/PublishedDelayedPayoutTx.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.arbitration; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class PublishedDelayedPayoutTx extends TradeTask { - public PublishedDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - throw new RuntimeException("PublishedDelayedPayoutTx not implemented for XMR"); -// try { -// runInterceptHook(); -// -// Transaction delayedPayoutTx = trade.getDelayedPayoutTx(); -// BtcWalletService btcWalletService = processModel.getBtcWalletService(); -// -// // We have spent the funds from the deposit tx with the delayedPayoutTx -// btcWalletService.resetCoinLockedInMultiSigAddressEntry(trade.getId()); -// // We might receive funds on AddressEntry.Context.TRADE_PAYOUT so we don't swap that -// -// Transaction committedDelayedPayoutTx = WalletService.maybeAddSelfTxToWallet(delayedPayoutTx, btcWalletService.getWallet()); -// -// processModel.getTradeWalletService().broadcastTx(committedDelayedPayoutTx, new TxBroadcaster.Callback() { -// @Override -// public void onSuccess(Transaction transaction) { -// log.info("publishDelayedPayoutTx onSuccess " + transaction); -// complete(); -// } -// -// @Override -// public void onFailure(TxBroadcastException exception) { -// log.error("publishDelayedPayoutTx onFailure", exception); -// failed(exception.toString()); -// } -// }); -// } catch (Throwable t) { -// failed(t); -// } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/SendPeerPublishedDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/SendPeerPublishedDelayedPayoutTxMessage.java deleted file mode 100644 index eda3d3ab74..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/arbitration/SendPeerPublishedDelayedPayoutTxMessage.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.arbitration; - -import bisq.core.trade.Trade; -import bisq.core.trade.messages.PeerPublishedDelayedPayoutTxMessage; -import bisq.core.trade.messages.TradeMailboxMessage; -import bisq.core.trade.protocol.tasks.SendMailboxMessageTask; - -import bisq.common.taskrunner.TaskRunner; - -import java.util.UUID; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SendPeerPublishedDelayedPayoutTxMessage extends SendMailboxMessageTask { - - public SendPeerPublishedDelayedPayoutTxMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected TradeMailboxMessage getTradeMailboxMessage(String id) { - return new PeerPublishedDelayedPayoutTxMessage(UUID.randomUUID().toString(), - trade.getId(), - trade.getTradingPeerNodeAddress()); - } - - @Override - protected void setStateSent() { - } - - @Override - protected void setStateArrived() { - } - - @Override - protected void setStateStoredInMailbox() { - } - - @Override - protected void setStateFault() { - } - - @Override - protected void run() { - try { - runInterceptHook(); - - super.run(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerFinalizesDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerFinalizesDelayedPayoutTx.java deleted file mode 100644 index 7c56c9de14..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerFinalizesDelayedPayoutTx.java +++ /dev/null @@ -1,61 +0,0 @@ -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; -import bisq.common.util.Utilities; - -import org.bitcoinj.core.Transaction; - -import java.util.Arrays; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerFinalizesDelayedPayoutTx extends TradeTask { - public BuyerFinalizesDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - BtcWalletService btcWalletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - Transaction preparedDepositTx = btcWalletService.getTxFromSerializedTx(processModel.getPreparedDepositTx()); - Transaction preparedDelayedPayoutTx = checkNotNull(processModel.getPreparedDelayedPayoutTx()); - - byte[] buyerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - checkArgument(Arrays.equals(buyerMultiSigPubKey, - btcWalletService.getOrCreateAddressEntry(id, AddressEntry.Context.MULTI_SIG).getPubKey()), - "buyerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - byte[] sellerMultiSigPubKey = trade.getTradingPeer().getMultiSigPubKey(); - - byte[] buyerSignature = processModel.getDelayedPayoutTxSignature(); - byte[] sellerSignature = trade.getTradingPeer().getDelayedPayoutTxSignature(); - - Transaction signedDelayedPayoutTx = processModel.getTradeWalletService().finalizeUnconnectedDelayedPayoutTx( - preparedDelayedPayoutTx, - buyerMultiSigPubKey, - sellerMultiSigPubKey, - buyerSignature, - sellerSignature, - preparedDepositTx.getOutput(0).getValue()); - - trade.applyDelayedPayoutTxBytes(signedDelayedPayoutTx.bitcoinSerialize()); - log.info("DelayedPayoutTxBytes = {}", Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDelayedPayoutTxSignatureRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDelayedPayoutTxSignatureRequest.java deleted file mode 100644 index 45de2baf37..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDelayedPayoutTxSignatureRequest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.TradeTask; -import bisq.core.util.Validator; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Transaction; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerProcessDelayedPayoutTxSignatureRequest extends TradeTask { - public BuyerProcessDelayedPayoutTxSignatureRequest(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - DelayedPayoutTxSignatureRequest request = (DelayedPayoutTxSignatureRequest) processModel.getTradeMessage(); - checkNotNull(request); - Validator.checkTradeId(processModel.getOfferId(), request); - byte[] delayedPayoutTxAsBytes = checkNotNull(request.getDelayedPayoutTx()); - Transaction preparedDelayedPayoutTx = processModel.getBtcWalletService().getTxFromSerializedTx(delayedPayoutTxAsBytes); - processModel.setPreparedDelayedPayoutTx(preparedDelayedPayoutTx); - trade.getTradingPeer().setDelayedPayoutTxSignature(checkNotNull(request.getDelayedPayoutTxSellerSignature())); - - // When we receive that message the taker has published the taker fee, so we apply it to the trade. - // The takerFeeTx was sent in the first message. It should be part of DelayedPayoutTxSignatureRequest - // but that cannot be changed due backward compatibility issues. It is a left over from the old trade protocol. - trade.setTakerFeeTxId(processModel.getTakeOfferFeeTxId()); - - trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDepositTxAndDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDepositTxAndDelayedPayoutTxMessage.java deleted file mode 100644 index df15bfebb1..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerProcessDepositTxAndDelayedPayoutTxMessage.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerProcessDepositTxAndDelayedPayoutTxMessage extends TradeTask { - public BuyerProcessDepositTxAndDelayedPayoutTxMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("BuyerProcessDepositTxAndDelayedPayoutTxMessage invalid in xmr base pair"); -// var message = checkNotNull((DepositTxAndDelayedPayoutTxMessage) processModel.getTradeMessage()); -// checkNotNull(message); -// Validator.checkTradeId(processModel.getOfferId(), message); -// -// // To access tx confidence we need to add that tx into our wallet. -// byte[] depositTxBytes = checkNotNull(message.getDepositTx()); -// Transaction depositTx = processModel.getBtcWalletService().getTxFromSerializedTx(depositTxBytes); -// // update with full tx -// Wallet wallet = processModel.getBtcWalletService().getWallet(); -// Transaction committedDepositTx = WalletService.maybeAddSelfTxToWallet(depositTx, wallet); -// trade.applyDepositTx(committedDepositTx); -// BtcWalletService.printTx("depositTx received from peer", committedDepositTx); -// -// // To access tx confidence we need to add that tx into our wallet. -// byte[] delayedPayoutTxBytes = checkNotNull(message.getDelayedPayoutTx()); -// trade.applyDelayedPayoutTxBytes(delayedPayoutTxBytes); -// BtcWalletService.printTx("delayedPayoutTx received from peer", -// checkNotNull(trade.getDelayedPayoutTx())); -// -// trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); -// -// // If we got already the confirmation we don't want to apply an earlier state -// if (trade.getState().ordinal() < Trade.State.BUYER_SAW_DEPOSIT_TX_IN_NETWORK.ordinal()) { -// trade.setState(Trade.State.BUYER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG); -// } -// -// processModel.getBtcWalletService().swapTradeEntryToAvailableEntry(trade.getId(), -// AddressEntry.Context.RESERVED_FOR_TRADE); -// -// complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsDelayedPayoutTxSignatureResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsDelayedPayoutTxSignatureResponse.java deleted file mode 100644 index 9a5ee74f86..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSendsDelayedPayoutTxSignatureResponse.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.network.p2p.NodeAddress; -import bisq.network.p2p.SendDirectMessageListener; - -import bisq.common.taskrunner.TaskRunner; - -import java.util.UUID; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerSendsDelayedPayoutTxSignatureResponse extends TradeTask { - public BuyerSendsDelayedPayoutTxSignatureResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - byte[] delayedPayoutTxSignature = checkNotNull(processModel.getDelayedPayoutTxSignature()); - byte[] depositTxBytes = processModel.getDepositTx() != null - ? processModel.getDepositTx().bitcoinSerialize() // set in BuyerAsTakerSignsDepositTx task - : processModel.getPreparedDepositTx(); // set in BuyerAsMakerCreatesAndSignsDepositTx task - - DelayedPayoutTxSignatureResponse message = new DelayedPayoutTxSignatureResponse(UUID.randomUUID().toString(), - processModel.getOfferId(), - processModel.getMyNodeAddress(), - delayedPayoutTxSignature, - depositTxBytes); - - NodeAddress peersNodeAddress = trade.getTradingPeerNodeAddress(); - log.info("Send {} to peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - processModel.getP2PService().sendEncryptedDirectMessage( - peersNodeAddress, - trade.getTradingPeer().getPubKeyRing(), - message, - new SendDirectMessageListener() { - @Override - public void onArrived() { - log.info("{} arrived at peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - complete(); - } - - @Override - public void onFault(String errorMessage) { - log.error("{} failed: Peer {}. tradeId={}, uid={}, errorMessage={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid(), errorMessage); - appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage); - failed(errorMessage); - } - } - ); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSignsDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSignsDelayedPayoutTx.java deleted file mode 100644 index bda7a0d9d0..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerSignsDelayedPayoutTx.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.Transaction; -import org.bitcoinj.crypto.DeterministicKey; - -import java.util.Arrays; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerSignsDelayedPayoutTx extends TradeTask { - public BuyerSignsDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - Transaction preparedDelayedPayoutTx = checkNotNull(processModel.getPreparedDelayedPayoutTx()); - - BtcWalletService btcWalletService = processModel.getBtcWalletService(); - NetworkParameters params = btcWalletService.getParams(); - Transaction preparedDepositTx = new Transaction(params, processModel.getPreparedDepositTx()); - - String id = processModel.getOffer().getId(); - - byte[] buyerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - DeterministicKey myMultiSigKeyPair = btcWalletService.getMultiSigKeyPair(id, buyerMultiSigPubKey); - - checkArgument(Arrays.equals(buyerMultiSigPubKey, - btcWalletService.getOrCreateAddressEntry(id, AddressEntry.Context.MULTI_SIG).getPubKey()), - "buyerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - byte[] sellerMultiSigPubKey = trade.getTradingPeer().getMultiSigPubKey(); - byte[] delayedPayoutTxSignature = processModel.getTradeWalletService().signDelayedPayoutTx( - preparedDelayedPayoutTx, - preparedDepositTx, - myMultiSigKeyPair, - buyerMultiSigPubKey, - sellerMultiSigPubKey); - processModel.setDelayedPayoutTxSignature(delayedPayoutTxSignature); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesFinalDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesFinalDelayedPayoutTx.java deleted file mode 100644 index ccc610c5d6..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesFinalDelayedPayoutTx.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask { - public BuyerVerifiesFinalDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - throw new RuntimeException("BuyerVerifiesFinalDelayedPayoutTx not applicable for xmr"); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesPreparedDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesPreparedDelayedPayoutTx.java deleted file mode 100644 index 9e45d0485a..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer/BuyerVerifiesPreparedDelayedPayoutTx.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer; - -import bisq.core.trade.Trade; -import bisq.core.trade.TradeDataValidation; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask { - public BuyerVerifiesPreparedDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - var preparedDelayedPayoutTx = processModel.getPreparedDelayedPayoutTx(); - TradeDataValidation.validateDelayedPayoutTx(trade, - preparedDelayedPayoutTx, - processModel.getBtcWalletService()); - - // If the deposit tx is non-malleable, we already know its final ID, so should check that now - // before sending any further data to the seller, to provide extra protection for the buyer. - if (isDepositTxNonMalleable()) { - var preparedDepositTx = processModel.getBtcWalletService().getTxFromSerializedTx( - processModel.getPreparedDepositTx()); - TradeDataValidation.validatePayoutTxInput(preparedDepositTx, checkNotNull(preparedDelayedPayoutTx)); - } else { - log.info("Deposit tx is malleable, so we skip preparedDelayedPayoutTx input validation."); - } - - complete(); - } catch (TradeDataValidation.ValidationException e) { - failed(e.getMessage()); - } catch (Throwable t) { - failed(t); - } - } - - private boolean isDepositTxNonMalleable() { - var buyerInputs = checkNotNull(processModel.getRawTransactionInputs()); - var sellerInputs = checkNotNull(trade.getTradingPeer().getRawTransactionInputs()); - - return buyerInputs.stream().allMatch(processModel.getTradeWalletService()::isP2WH) && - sellerInputs.stream().allMatch(processModel.getTradeWalletService()::isP2WH); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerCreatesAndSignsDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerCreatesAndSignsDepositTx.java deleted file mode 100644 index c3b562bd31..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerCreatesAndSignsDepositTx.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer_as_maker; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.model.PreparedDepositTxAndMakerInputs; -import bisq.core.btc.model.RawTransactionInput; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.offer.Offer; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.TradingPeer; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Address; -import org.bitcoinj.core.Coin; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class BuyerAsMakerCreatesAndSignsDepositTx extends TradeTask { - public BuyerAsMakerCreatesAndSignsDepositTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - Coin tradeAmount = checkNotNull(trade.getAmount(), "trade.getTradeAmount() must not be null"); - - BtcWalletService walletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - TradingPeer tradingPeer = trade.getTradingPeer(); - Offer offer = checkNotNull(trade.getOffer()); - - Coin makerInputAmount = offer.getBuyerSecurityDeposit(); - Optional addressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG); - checkArgument(addressEntryOptional.isPresent(), "addressEntryOptional must be present"); - AddressEntry makerMultiSigAddressEntry = addressEntryOptional.get(); - processModel.getBtcWalletService().setCoinLockedInMultiSigAddressEntry(makerMultiSigAddressEntry, makerInputAmount.value); - walletService.saveAddressEntryList(); - - Coin msOutputAmount = makerInputAmount - .add(trade.getTxFee()) - .add(offer.getSellerSecurityDeposit()) - .add(tradeAmount); - - List takerRawTransactionInputs = checkNotNull(tradingPeer.getRawTransactionInputs()); - checkArgument(takerRawTransactionInputs.stream().allMatch(processModel.getTradeWalletService()::isP2WH), - "all takerRawTransactionInputs must be P2WH"); - long takerChangeOutputValue = tradingPeer.getChangeOutputValue(); - @Nullable String takerChangeAddressString = tradingPeer.getChangeOutputAddress(); - Address makerAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE).getAddress(); - Address makerChangeAddress = walletService.getFreshAddressEntry().getAddress(); - byte[] buyerPubKey = processModel.getMyMultiSigPubKey(); - byte[] sellerPubKey = checkNotNull(tradingPeer.getMultiSigPubKey()); - checkArgument(Arrays.equals(buyerPubKey, - makerMultiSigAddressEntry.getPubKey()), - "buyerPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - - PreparedDepositTxAndMakerInputs result = processModel.getTradeWalletService().buyerAsMakerCreatesAndSignsDepositTx( - trade.getContractHash(), - makerInputAmount, - msOutputAmount, - takerRawTransactionInputs, - takerChangeOutputValue, - takerChangeAddressString, - makerAddress, - makerChangeAddress, - buyerPubKey, - sellerPubKey); - - processModel.setPreparedDepositTx(result.depositTransaction); - processModel.setRawTransactionInputs(result.rawMakerInputs); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerSendsInputsForDepositTxResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerSendsInputsForDepositTxResponse.java deleted file mode 100644 index 93bf5a2eb2..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_maker/BuyerAsMakerSendsInputsForDepositTxResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer_as_maker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.maker.MakerSendsInputsForDepositTxResponse; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Transaction; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerAsMakerSendsInputsForDepositTxResponse extends MakerSendsInputsForDepositTxResponse { - public BuyerAsMakerSendsInputsForDepositTxResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected byte[] getPreparedDepositTx() { - Transaction preparedDepositTx = processModel.getBtcWalletService().getTxFromSerializedTx(processModel.getPreparedDepositTx()); - // Remove witnesses from preparedDepositTx, so that the seller can still compute the final - // tx id, but cannot publish it before providing the buyer with a signed delayed payout tx. - return preparedDepositTx.bitcoinSerialize(false); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerCreatesDepositTxInputs.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerCreatesDepositTxInputs.java deleted file mode 100644 index 292da8bfa6..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerCreatesDepositTxInputs.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer_as_taker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerAsTakerCreatesDepositTxInputs extends TradeTask { - - public BuyerAsTakerCreatesDepositTxInputs(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - throw new RuntimeException("Outputs not communicated in xmr integration"); - -// processModel.getTradeManager().requestPersistence(); - -// Coin txFee = trade.getTxFee(); -// Coin takerInputAmount = checkNotNull(trade.getOffer()).getBuyerSecurityDeposit() -// .add(txFee) -// .add(txFee); // 2 times the fee as we need it for payout tx as well -// InputsAndChangeOutput result = processModel.getTradeWalletService().takerCreatesDepositTxInputs( -// processModel.getTakeOfferFeeTx(), -// takerInputAmount, -// txFee); -// processModel.setRawTransactionInputs(result.rawTransactionInputs); -// processModel.setChangeOutputValue(result.changeOutputValue); -// processModel.setChangeOutputAddress(result.changeOutputAddress); -// -// complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSendsDepositTxMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSendsDepositTxMessage.java deleted file mode 100644 index 28369a3385..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSendsDepositTxMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer_as_taker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerAsTakerSendsDepositTxMessage extends TradeTask { - public BuyerAsTakerSendsDepositTxMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("BuyerAsTakerSendsDepositTxMessage not implemented for xmr"); -// if (processModel.getDepositTx() != null) { -// DepositTxMessage message = new DepositTxMessage(UUID.randomUUID().toString(), -// processModel.getOfferId(), -// processModel.getMyNodeAddress(), -// processModel.getDepositTx().bitcoinSerialize()); -// -// NodeAddress peersNodeAddress = trade.getTradingPeerNodeAddress(); -// log.info("Send {} to peer {}. tradeId={}, uid={}", -// message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); -// processModel.getP2PService().sendEncryptedDirectMessage( -// peersNodeAddress, -// trade.getTradingPeer().getPubKeyRing(), -// message, -// new SendDirectMessageListener() { -// @Override -// public void onArrived() { -// log.info("{} arrived at peer {}. tradeId={}, uid={}", -// message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); -// complete(); -// } -// -// @Override -// public void onFault(String errorMessage) { -// log.error("{} failed: Peer {}. tradeId={}, uid={}, errorMessage={}", -// message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid(), errorMessage); -// -// appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage); -// failed(); -// } -// } -// ); -// } else { -// log.error("processModel.getDepositTx() = " + processModel.getDepositTx()); -// failed("DepositTx is null"); -// } - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java deleted file mode 100644 index d2e52f3873..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.buyer_as_taker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BuyerAsTakerSignsDepositTx extends TradeTask { - - public BuyerAsTakerSignsDepositTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("BuyerAsTakerSignsDepositTx not implemented for xmr"); - - /* log.debug("\n\n------------------------------------------------------------\n" - + "Contract as json\n" - + trade.getContractAsJson() - + "\n------------------------------------------------------------\n");*/ - - -// byte[] contractHash = Hash.getSha256Hash(checkNotNull(trade.getContractAsJson())); -// trade.setContractHash(contractHash); -// List buyerInputs = checkNotNull(processModel.getRawTransactionInputs(), "buyerInputs must not be null"); -// BtcWalletService walletService = processModel.getBtcWalletService(); -// String id = processModel.getOffer().getId(); -// -// Optional addressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG); -// checkArgument(addressEntryOptional.isPresent(), "addressEntryOptional must be present"); -// AddressEntry buyerMultiSigAddressEntry = addressEntryOptional.get(); -// Coin buyerInput = Coin.valueOf(buyerInputs.stream().mapToLong(input -> input.value).sum()); -// -// buyerMultiSigAddressEntry.setCoinLockedInMultiSig(buyerInput.subtract(trade.getTxFee().multiply(2))); -// walletService.saveAddressEntryList(); -// -// TradingPeer tradingPeer = trade.getTradingPeer(); -// byte[] buyerMultiSigPubKey = processModel.getMyMultiSigPubKey(); -// checkArgument(Arrays.equals(buyerMultiSigPubKey, buyerMultiSigAddressEntry.getPubKey()), -// "buyerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); -// -// List sellerInputs = checkNotNull(tradingPeer.getRawTransactionInputs()); -// byte[] sellerMultiSigPubKey = tradingPeer.getMultiSigPubKey(); -// Transaction depositTx = processModel.getTradeWalletService().takerSignsDepositTx( -// false, -// contractHash, -// processModel.getPreparedDepositTx(), -// buyerInputs, -// sellerInputs, -// buyerMultiSigPubKey, -// sellerMultiSigPubKey); -// processModel.setDepositTx(depositTx); -// -// complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInputsForDepositTxResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInputsForDepositTxResponse.java deleted file mode 100644 index ed488ace12..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerSendsInputsForDepositTxResponse.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.maker; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.messages.InputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.network.p2p.NodeAddress; -import bisq.network.p2p.SendDirectMessageListener; - -import bisq.common.crypto.Sig; -import bisq.common.taskrunner.TaskRunner; - -import java.security.PrivateKey; - -import java.util.Arrays; -import java.util.Date; -import java.util.Optional; -import java.util.UUID; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public abstract class MakerSendsInputsForDepositTxResponse extends TradeTask { - public MakerSendsInputsForDepositTxResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - protected abstract byte[] getPreparedDepositTx(); - - @Override - protected void run() { - try { - runInterceptHook(); - BtcWalletService walletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - - Optional optionalMultiSigAddressEntry = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG); - checkArgument(optionalMultiSigAddressEntry.isPresent(), "addressEntry must be set here."); - AddressEntry makerPayoutAddressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT); - byte[] makerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - checkArgument(Arrays.equals(makerMultiSigPubKey, - optionalMultiSigAddressEntry.get().getPubKey()), - "makerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - - byte[] preparedDepositTx = getPreparedDepositTx(); - - // Maker has to use preparedDepositTx as nonce. - // He cannot manipulate the preparedDepositTx - so we avoid to have a challenge protocol for passing the - // nonce we want to get signed. - // This is used for verifying the peers account age witness - PrivateKey privateKey = processModel.getKeyRing().getSignatureKeyPair().getPrivate(); - byte[] signatureOfNonce = Sig.sign(privateKey, preparedDepositTx); - InputsForDepositTxResponse message = new InputsForDepositTxResponse( - processModel.getOfferId(), - checkNotNull(processModel.getPaymentAccountPayload(trade)), - processModel.getAccountId(), - makerMultiSigPubKey, - trade.getContractAsJson(), - trade.getMaker().getContractSignature(), - makerPayoutAddressEntry.getAddressString(), - preparedDepositTx, - processModel.getRawTransactionInputs(), - processModel.getMyNodeAddress(), - UUID.randomUUID().toString(), - signatureOfNonce, - new Date().getTime(), - trade.getLockTime()); - - trade.setState(Trade.State.MAKER_SENT_PUBLISH_DEPOSIT_TX_REQUEST); - processModel.getTradeManager().requestPersistence(); - NodeAddress peersNodeAddress = trade.getTradingPeerNodeAddress(); - log.info("Send {} to peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - processModel.getP2PService().sendEncryptedDirectMessage( - peersNodeAddress, - trade.getTradingPeer().getPubKeyRing(), - message, - new SendDirectMessageListener() { - @Override - public void onArrived() { - log.info("{} arrived at peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - trade.setState(Trade.State.MAKER_SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST); - processModel.getTradeManager().requestPersistence(); - complete(); - } - - @Override - public void onFault(String errorMessage) { - log.error("{} failed: Peer {}. tradeId={}, uid={}, errorMessage={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid(), errorMessage); - trade.setState(Trade.State.MAKER_SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST); - appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage); - processModel.getTradeManager().requestPersistence(); - failed(errorMessage); - } - } - ); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerVerifyTakerFeePayment.java b/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerVerifyTakerFeePayment.java deleted file mode 100644 index 89940d38b0..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/maker/MakerVerifyTakerFeePayment.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.maker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class MakerVerifyTakerFeePayment extends TradeTask { - - public MakerVerifyTakerFeePayment(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - //TODO missing impl. - // int numOfPeersSeenTx = processModel.getWalletService().getNumOfPeersSeenTx(processModel.getTakeOfferFeeTxId()); - /* if (numOfPeersSeenTx > 2) { - resultHandler.handleResult(); - }*/ - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/mediation/BroadcastMediatedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/mediation/BroadcastMediatedPayoutTx.java deleted file mode 100644 index 23a8c55b4e..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/mediation/BroadcastMediatedPayoutTx.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.mediation; - -import bisq.core.support.dispute.mediation.MediationResultState; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.BroadcastPayoutTx; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class BroadcastMediatedPayoutTx extends BroadcastPayoutTx { - public BroadcastMediatedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - super.run(); - } catch (Throwable t) { - failed(t); - } - } - - @Override - protected void setState() { - trade.setMediationResultState(MediationResultState.PAYOUT_TX_PUBLISHED); - processModel.getTradeManager().requestPersistence(); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerBroadcastPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerBroadcastPayoutTx.java deleted file mode 100644 index 1088588b8f..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerBroadcastPayoutTx.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.BroadcastPayoutTx; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SellerBroadcastPayoutTx extends BroadcastPayoutTx { - public SellerBroadcastPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - super.run(); - } catch (Throwable t) { - failed(t); - } - } - - @Override - protected void setState() { - trade.setState(Trade.State.SELLER_PUBLISHED_PAYOUT_TX); - processModel.getTradeManager().requestPersistence(); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerCreatesDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerCreatesDelayedPayoutTx.java deleted file mode 100644 index a50612b327..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerCreatesDelayedPayoutTx.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.btc.wallet.TradeWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.TradeDataValidation; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.Transaction; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerCreatesDelayedPayoutTx extends TradeTask { - - public SellerCreatesDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("SellerCreatesDelayedPayoutTx not implemented for xmr"); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerFinalizesDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerFinalizesDelayedPayoutTx.java deleted file mode 100644 index 76c31db7f7..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerFinalizesDelayedPayoutTx.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; -import bisq.common.util.Utilities; - -import org.bitcoinj.core.Transaction; - -import java.util.Arrays; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerFinalizesDelayedPayoutTx extends TradeTask { - public SellerFinalizesDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - Transaction preparedDelayedPayoutTx = checkNotNull(processModel.getPreparedDelayedPayoutTx()); - BtcWalletService btcWalletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - - byte[] buyerMultiSigPubKey = trade.getTradingPeer().getMultiSigPubKey(); - byte[] sellerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - checkArgument(Arrays.equals(sellerMultiSigPubKey, - btcWalletService.getOrCreateAddressEntry(id, AddressEntry.Context.MULTI_SIG).getPubKey()), - "sellerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - - byte[] buyerSignature = trade.getTradingPeer().getDelayedPayoutTxSignature(); - byte[] sellerSignature = processModel.getDelayedPayoutTxSignature(); - - Transaction signedDelayedPayoutTx = processModel.getTradeWalletService().finalizeDelayedPayoutTx( - preparedDelayedPayoutTx, - buyerMultiSigPubKey, - sellerMultiSigPubKey, - buyerSignature, - sellerSignature); - - trade.applyDelayedPayoutTx(signedDelayedPayoutTx); - log.info("DelayedPayoutTxBytes = {}", Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessDelayedPayoutTxSignatureResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessDelayedPayoutTxSignatureResponse.java deleted file mode 100644 index 8e3f77b8fa..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerProcessDelayedPayoutTxSignatureResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -import static bisq.core.util.Validator.checkTradeId; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerProcessDelayedPayoutTxSignatureResponse extends TradeTask { - public SellerProcessDelayedPayoutTxSignatureResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - DelayedPayoutTxSignatureResponse response = (DelayedPayoutTxSignatureResponse) processModel.getTradeMessage(); - checkNotNull(response); - checkTradeId(processModel.getOfferId(), response); - - trade.getTradingPeer().setDelayedPayoutTxSignature(checkNotNull(response.getDelayedPayoutTxBuyerSignature())); - - processModel.getTradeWalletService().sellerAddsBuyerWitnessesToDepositTx( - processModel.getDepositTx(), - processModel.getBtcWalletService().getTxFromSerializedTx(response.getDepositTx()) - ); - - // update to the latest peer address of our peer if the message is correct - trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendDelayedPayoutTxSignatureRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendDelayedPayoutTxSignatureRequest.java deleted file mode 100644 index f043ba790b..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSendDelayedPayoutTxSignatureRequest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.trade.Trade; -import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.network.p2p.NodeAddress; -import bisq.network.p2p.SendDirectMessageListener; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Transaction; - -import java.util.UUID; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerSendDelayedPayoutTxSignatureRequest extends TradeTask { - public SellerSendDelayedPayoutTxSignatureRequest(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - Transaction preparedDelayedPayoutTx = checkNotNull(processModel.getPreparedDelayedPayoutTx(), - "processModel.getPreparedDelayedPayoutTx() must not be null"); - byte[] delayedPayoutTxSignature = checkNotNull(processModel.getDelayedPayoutTxSignature(), - "processModel.getDelayedPayoutTxSignature() must not be null"); - DelayedPayoutTxSignatureRequest message = new DelayedPayoutTxSignatureRequest(UUID.randomUUID().toString(), - processModel.getOfferId(), - processModel.getMyNodeAddress(), - preparedDelayedPayoutTx.bitcoinSerialize(), - delayedPayoutTxSignature); - - NodeAddress peersNodeAddress = trade.getTradingPeerNodeAddress(); - log.info("Send {} to peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - processModel.getP2PService().sendEncryptedDirectMessage( - peersNodeAddress, - trade.getTradingPeer().getPubKeyRing(), - message, - new SendDirectMessageListener() { - @Override - public void onArrived() { - log.info("{} arrived at peer {}. tradeId={}, uid={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid()); - complete(); - } - - @Override - public void onFault(String errorMessage) { - log.error("{} failed: Peer {}. tradeId={}, uid={}, errorMessage={}", - message.getClass().getSimpleName(), peersNodeAddress, message.getTradeId(), message.getUid(), errorMessage); - appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage); - failed(); - } - } - ); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSignsDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSignsDelayedPayoutTx.java deleted file mode 100644 index 3045091cb2..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller/SellerSignsDelayedPayoutTx.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.Transaction; -import org.bitcoinj.crypto.DeterministicKey; - -import java.util.Arrays; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerSignsDelayedPayoutTx extends TradeTask { - public SellerSignsDelayedPayoutTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - Transaction preparedDelayedPayoutTx = checkNotNull(processModel.getPreparedDelayedPayoutTx()); - BtcWalletService btcWalletService = processModel.getBtcWalletService(); - NetworkParameters params = btcWalletService.getParams(); - Transaction preparedDepositTx = new Transaction(params, processModel.getPreparedDepositTx()); - - String id = processModel.getOffer().getId(); - - byte[] sellerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - DeterministicKey myMultiSigKeyPair = btcWalletService.getMultiSigKeyPair(id, sellerMultiSigPubKey); - - checkArgument(Arrays.equals(sellerMultiSigPubKey, - btcWalletService.getOrCreateAddressEntry(id, AddressEntry.Context.MULTI_SIG).getPubKey()), - "sellerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - byte[] buyerMultiSigPubKey = trade.getTradingPeer().getMultiSigPubKey(); - - byte[] delayedPayoutTxSignature = processModel.getTradeWalletService().signDelayedPayoutTx( - preparedDelayedPayoutTx, - preparedDepositTx, - myMultiSigKeyPair, - buyerMultiSigPubKey, - sellerMultiSigPubKey); - - processModel.setDelayedPayoutTxSignature(delayedPayoutTxSignature); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerCreatesUnsignedDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerCreatesUnsignedDepositTx.java deleted file mode 100644 index 737521a6a1..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerCreatesUnsignedDepositTx.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_maker; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.model.PreparedDepositTxAndMakerInputs; -import bisq.core.btc.model.RawTransactionInput; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.offer.Offer; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.TradingPeer; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.crypto.Hash; -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Address; -import org.bitcoinj.core.Coin; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerAsMakerCreatesUnsignedDepositTx extends TradeTask { - public SellerAsMakerCreatesUnsignedDepositTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - checkNotNull(trade.getAmount(), "trade.getTradeAmount() must not be null"); - - BtcWalletService walletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - TradingPeer tradingPeer = trade.getTradingPeer(); - Offer offer = checkNotNull(trade.getOffer()); - - // params - byte[] contractHash = Hash.getSha256Hash(checkNotNull(trade.getContractAsJson())); - trade.setContractHash(contractHash); - log.debug("\n\n------------------------------------------------------------\n" - + "Contract as json\n" - + trade.getContractAsJson() - + "\n------------------------------------------------------------\n"); - - Coin makerInputAmount = offer.getSellerSecurityDeposit().add(trade.getAmount()); - Optional addressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG); - checkArgument(addressEntryOptional.isPresent(), "addressEntryOptional must be present"); - AddressEntry makerMultiSigAddressEntry = addressEntryOptional.get(); - processModel.getBtcWalletService().setCoinLockedInMultiSigAddressEntry(makerMultiSigAddressEntry, makerInputAmount.value); - - walletService.saveAddressEntryList(); - - Coin msOutputAmount = makerInputAmount - .add(trade.getTxFee()) - .add(offer.getBuyerSecurityDeposit()); - - List takerRawTransactionInputs = checkNotNull(tradingPeer.getRawTransactionInputs()); - checkArgument(takerRawTransactionInputs.stream().allMatch(processModel.getTradeWalletService()::isP2WH), - "all takerRawTransactionInputs must be P2WH"); - long takerChangeOutputValue = tradingPeer.getChangeOutputValue(); - String takerChangeAddressString = tradingPeer.getChangeOutputAddress(); - Address makerAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE).getAddress(); - Address makerChangeAddress = walletService.getFreshAddressEntry().getAddress(); - byte[] buyerPubKey = tradingPeer.getMultiSigPubKey(); - byte[] sellerPubKey = processModel.getMyMultiSigPubKey(); - checkArgument(Arrays.equals(sellerPubKey, - makerMultiSigAddressEntry.getPubKey()), - "sellerPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - - PreparedDepositTxAndMakerInputs result = processModel.getTradeWalletService().sellerAsMakerCreatesDepositTx( - contractHash, - makerInputAmount, - msOutputAmount, - takerRawTransactionInputs, - takerChangeOutputValue, - takerChangeAddressString, - makerAddress, - makerChangeAddress, - buyerPubKey, - sellerPubKey); - - processModel.setPreparedDepositTx(result.depositTransaction); - processModel.setRawTransactionInputs(result.rawMakerInputs); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java deleted file mode 100644 index c8f4c63895..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_maker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Transaction; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerAsMakerFinalizesDepositTx extends TradeTask { - public SellerAsMakerFinalizesDepositTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - if (true) throw new RuntimeException("SellerAsMakerFinalizesDepositTx not implemented for xmr"); - - byte[] takersRawPreparedDepositTx = checkNotNull(trade.getTradingPeer().getPreparedDepositTx()); - byte[] myRawPreparedDepositTx = checkNotNull(processModel.getPreparedDepositTx()); - Transaction takersDepositTx = processModel.getBtcWalletService().getTxFromSerializedTx(takersRawPreparedDepositTx); - Transaction myDepositTx = processModel.getBtcWalletService().getTxFromSerializedTx(myRawPreparedDepositTx); - int numTakersInputs = checkNotNull(trade.getTradingPeer().getRawTransactionInputs()).size(); - processModel.getTradeWalletService().sellerAsMakerFinalizesDepositTx(myDepositTx, takersDepositTx, numTakersInputs); - - processModel.setDepositTx(myDepositTx); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerProcessDepositTxMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerProcessDepositTxMessage.java deleted file mode 100644 index 3ce2e98c62..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerProcessDepositTxMessage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_maker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SellerAsMakerProcessDepositTxMessage extends TradeTask { - public SellerAsMakerProcessDepositTxMessage(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - throw new RuntimeException("SellerAsMakerProcessDepositTxMessage needs updated for XMR"); -// try { -// runInterceptHook(); -// log.debug("current trade state " + trade.getState()); -// DepositTxMessage message = (DepositTxMessage) processModel.getTradeMessage(); -// Validator.checkTradeId(processModel.getOfferId(), message); -// checkNotNull(message); -// -// trade.getTradingPeer().setPreparedDepositTx(checkNotNull(message.getDepositTxWithoutWitnesses())); -// trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); -// -// // When we receive that message the taker has published the taker fee, so we apply it to the trade. -// // The takerFeeTx was sent in the first message. It should be part of DelayedPayoutTxSignatureRequest -// // but that cannot be changed due backward compatibility issues. It is a left over from the old trade protocol. -// trade.setTakerFeeTxId(processModel.getTakeOfferFeeTxId()); -// -// processModel.getTradeManager().requestPersistence(); -// -// complete(); -// } catch (Throwable t) { -// failed(t); -// } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerSendsInputsForDepositTxResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerSendsInputsForDepositTxResponse.java deleted file mode 100644 index 1741b4c4b0..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerSendsInputsForDepositTxResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_maker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.maker.MakerSendsInputsForDepositTxResponse; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Transaction; -import org.bitcoinj.script.Script; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SellerAsMakerSendsInputsForDepositTxResponse extends MakerSendsInputsForDepositTxResponse { - public SellerAsMakerSendsInputsForDepositTxResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected byte[] getPreparedDepositTx() { - Transaction preparedDepositTx = processModel.getBtcWalletService().getTxFromSerializedTx(processModel.getPreparedDepositTx()); - preparedDepositTx.getInputs().forEach(input -> { - // Remove signature before sending to peer as we don't want to risk that buyer could publish deposit tx - // before we have received his signature for the delayed payout tx. - input.setScriptSig(new Script(new byte[]{})); - }); - - processModel.getTradeManager().requestPersistence(); - - // Make sure witnesses are removed as well before sending, to cover the segwit case. - return preparedDepositTx.bitcoinSerialize(false); - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerCreatesDepositTxInputs.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerCreatesDepositTxInputs.java deleted file mode 100644 index ef595b7848..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerCreatesDepositTxInputs.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_taker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SellerAsTakerCreatesDepositTxInputs extends TradeTask { - public SellerAsTakerCreatesDepositTxInputs(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - throw new RuntimeException("XMR integration does not communicate outputs"); - -// Coin tradeAmount = checkNotNull(trade.getTradeAmount()); -// Offer offer = checkNotNull(trade.getOffer()); -// Coin txFee = trade.getTxFee(); -// Coin takerInputAmount = offer.getSellerSecurityDeposit() -// .add(txFee) -// .add(txFee) // We add 2 times the fee as one is for the payout tx -// .add(tradeAmount); -// InputsAndChangeOutput result = processModel.getTradeWalletService().takerCreatesDepositTxInputs( -// processModel.getTakeOfferFeeTx(), -// takerInputAmount, -// txFee); -// -// processModel.setRawTransactionInputs(result.rawTransactionInputs); -// processModel.setChangeOutputValue(result.changeOutputValue); -// processModel.setChangeOutputAddress(result.changeOutputAddress); -// -// processModel.getTradeManager().requestPersistence(); -// -// complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerSignsDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerSignsDepositTx.java deleted file mode 100644 index c29542b468..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_taker/SellerAsTakerSignsDepositTx.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.seller_as_taker; - -import bisq.core.btc.model.AddressEntry; -import bisq.core.btc.model.RawTransactionInput; -import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.offer.Offer; -import bisq.core.trade.Contract; -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.TradingPeer; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.Transaction; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class SellerAsTakerSignsDepositTx extends TradeTask { - public SellerAsTakerSignsDepositTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - if (true) throw new RuntimeException("SellerAsTakerSignsDepositTx not implemented for xmr"); - - List sellerInputs = checkNotNull(processModel.getRawTransactionInputs(), - "sellerInputs must not be null"); - BtcWalletService walletService = processModel.getBtcWalletService(); - String id = processModel.getOffer().getId(); - - Optional optionalMultiSigAddressEntry = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG); - checkArgument(optionalMultiSigAddressEntry.isPresent(), "addressEntryOptional must be present"); - AddressEntry sellerMultiSigAddressEntry = optionalMultiSigAddressEntry.get(); - byte[] sellerMultiSigPubKey = processModel.getMyMultiSigPubKey(); - checkArgument(Arrays.equals(sellerMultiSigPubKey, - sellerMultiSigAddressEntry.getPubKey()), - "sellerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id); - - Coin sellerInput = Coin.valueOf(sellerInputs.stream().mapToLong(input -> input.value).sum()); - - Coin totalFee = trade.getTxFee().multiply(2); // Fee for deposit and payout tx - Coin multiSigValue = sellerInput.subtract(totalFee); - processModel.getBtcWalletService().setCoinLockedInMultiSigAddressEntry(sellerMultiSigAddressEntry, multiSigValue.value); - walletService.saveAddressEntryList(); - - Offer offer = trade.getOffer(); - Coin msOutputAmount = offer.getBuyerSecurityDeposit().add(offer.getSellerSecurityDeposit()).add(trade.getTxFee()) - .add(checkNotNull(trade.getAmount())); - - TradingPeer tradingPeer = trade.getTradingPeer(); - - Transaction depositTx = processModel.getTradeWalletService().takerSignsDepositTx( - true, - trade.getContractHash(), - processModel.getPreparedDepositTx(), - msOutputAmount, - checkNotNull(tradingPeer.getRawTransactionInputs()), - sellerInputs, - tradingPeer.getMultiSigPubKey(), - sellerMultiSigPubKey); - - // We set the deposit tx to trade once we have it published - processModel.setDepositTx(depositTx); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - Contract contract = trade.getContract(); - if (contract != null) - contract.printDiff(trade.getTradingPeer().getContractAsJson()); - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerProcessesInputsForDepositTxResponse.java b/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerProcessesInputsForDepositTxResponse.java deleted file mode 100644 index ba47dbb6da..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerProcessesInputsForDepositTxResponse.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.taker; - -import bisq.core.btc.wallet.Restrictions; -import bisq.core.trade.Trade; -import bisq.core.trade.messages.InputsForDepositTxResponse; -import bisq.core.trade.protocol.TradingPeer; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.config.Config; -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - -import static bisq.core.util.Validator.checkTradeId; -import static bisq.core.util.Validator.nonEmptyStringOf; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class TakerProcessesInputsForDepositTxResponse extends TradeTask { - public TakerProcessesInputsForDepositTxResponse(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - InputsForDepositTxResponse response = (InputsForDepositTxResponse) processModel.getTradeMessage(); - checkTradeId(processModel.getOfferId(), response); - checkNotNull(response); - - TradingPeer tradingPeer = trade.getTradingPeer(); - tradingPeer.setPaymentAccountPayload(checkNotNull(response.getMakerPaymentAccountPayload())); - tradingPeer.setAccountId(nonEmptyStringOf(response.getMakerAccountId())); - tradingPeer.setMultiSigPubKey(checkNotNull(response.getMakerMultiSigPubKey())); - tradingPeer.setContractAsJson(nonEmptyStringOf(response.getMakerContractAsJson())); - tradingPeer.setContractSignature(nonEmptyStringOf(response.getMakerContractSignature())); - tradingPeer.setPayoutAddressString(nonEmptyStringOf(response.getMakerPayoutAddressString())); - tradingPeer.setRawTransactionInputs(checkNotNull(response.getMakerInputs())); - byte[] preparedDepositTx = checkNotNull(response.getPreparedDepositTx()); - processModel.setPreparedDepositTx(preparedDepositTx); - long lockTime = response.getLockTime(); - if (Config.baseCurrencyNetwork().isMainnet()) { - int myLockTime = processModel.getBtcWalletService().getBestChainHeight() + - Restrictions.getLockTime(processModel.getOffer().getPaymentMethod().isBlockchain()); - // We allow a tolerance of 3 blocks as BestChainHeight might be a bit different on maker and taker in case a new - // block was just found - checkArgument(Math.abs(lockTime - myLockTime) <= 3, - "Lock time of maker is more than 3 blocks different to the lockTime I " + - "calculated. Makers lockTime= " + lockTime + ", myLockTime=" + myLockTime); - } - trade.setLockTime(lockTime); - long delay = processModel.getBtcWalletService().getBestChainHeight() - lockTime; - log.info("lockTime={}, delay={}", lockTime, delay); - - // Maker has to sign preparedDepositTx. He cannot manipulate the preparedDepositTx - so we avoid to have a - // challenge protocol for passing the nonce we want to get signed. - tradingPeer.setAccountAgeWitnessNonce(preparedDepositTx); - tradingPeer.setAccountAgeWitnessSignature(checkNotNull(response.getAccountAgeWitnessSignatureOfPreparedDepositTx())); - - tradingPeer.setCurrentDate(response.getCurrentDate()); - - checkArgument(response.getMakerInputs().size() > 0); - - // update to the latest peer address of our peer if the message is correct - trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress()); - - processModel.getTradeManager().requestPersistence(); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java deleted file mode 100644 index f7106e3e45..0000000000 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno 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. - * - * Haveno 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 Haveno. If not, see . - */ - -package bisq.core.trade.protocol.tasks.taker; - -import bisq.core.trade.Trade; -import bisq.core.trade.protocol.tasks.TradeTask; - -import bisq.common.taskrunner.TaskRunner; - -import lombok.extern.slf4j.Slf4j; - - - -import monero.wallet.model.MoneroTxWallet; - -@Slf4j -public class TakerPublishFeeTx extends TradeTask { - public TakerPublishFeeTx(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - // We committed to be sure the tx gets into the wallet even in the broadcast process it would be - // committed as well, but if user would close app before success handler returns the commit would not - // be done. - MoneroTxWallet takeOfferFeeTx = processModel.getTakeOfferFeeTx(); - processModel.getProvider().getXmrWalletService().getWallet().relayTx(takeOfferFeeTx); - System.out.println("TAKER PUBLISHED FEE TX"); - System.out.println(takeOfferFeeTx); - trade.setState(Trade.State.TAKER_PUBLISHED_TAKER_FEE_TX); - complete(); - } catch (Throwable t) { - log.error(t.toString()); - t.printStackTrace(); - trade.setErrorMessage("An error occurred.\n Error message:\n" + t.getMessage()); - failed(t); - } - } -} diff --git a/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java b/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java index befa94773a..68b1964978 100644 --- a/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java +++ b/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java @@ -26,45 +26,20 @@ import bisq.core.offer.availability.tasks.SendOfferAvailabilityRequest; import bisq.core.offer.placeoffer.tasks.AddToOfferBook; import bisq.core.offer.placeoffer.tasks.MakerReservesOfferFunds; import bisq.core.offer.placeoffer.tasks.ValidateOffer; +import bisq.core.trade.protocol.TakerVerifyMakerFeePayment; import bisq.core.trade.protocol.tasks.ApplyFilter; +import bisq.core.trade.protocol.tasks.BuyerPreparesPaymentSentMessage; +import bisq.core.trade.protocol.tasks.BuyerProcessesPaymentReceivedMessage; +import bisq.core.trade.protocol.tasks.BuyerSendsPaymentSentMessage; +import bisq.core.trade.protocol.tasks.BuyerSetupPayoutTxListener; +import bisq.core.trade.protocol.tasks.MakerSetsLockTime; +import bisq.core.trade.protocol.tasks.MaybeRemoveOpenOffer; +import bisq.core.trade.protocol.tasks.SellerPreparesPaymentReceivedMessage; +import bisq.core.trade.protocol.tasks.SellerProcessesPaymentSentMessage; +import bisq.core.trade.protocol.tasks.SellerPublishesDepositTx; +import bisq.core.trade.protocol.tasks.SellerPublishesTradeStatistics; +import bisq.core.trade.protocol.tasks.SellerSendsPaymentReceivedMessage; import bisq.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness; -import bisq.core.trade.protocol.tasks.buyer.BuyerPreparesPaymentSentMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessDepositTxAndDelayedPayoutTxMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerProcessesPaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerSendsPaymentSentMessage; -import bisq.core.trade.protocol.tasks.buyer.BuyerSendsDelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.buyer.BuyerSetupPayoutTxListener; -import bisq.core.trade.protocol.tasks.buyer.BuyerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerVerifiesFinalDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer.BuyerVerifiesPreparedDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.buyer_as_maker.BuyerAsMakerCreatesAndSignsDepositTx; -import bisq.core.trade.protocol.tasks.buyer_as_maker.BuyerAsMakerSendsInputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.buyer_as_taker.BuyerAsTakerCreatesDepositTxInputs; -import bisq.core.trade.protocol.tasks.buyer_as_taker.BuyerAsTakerSendsDepositTxMessage; -import bisq.core.trade.protocol.tasks.buyer_as_taker.BuyerAsTakerSignsDepositTx; -import bisq.core.trade.protocol.tasks.maker.MaybeRemoveOpenOffer; -import bisq.core.trade.protocol.tasks.maker.MakerSetsLockTime; -import bisq.core.trade.protocol.tasks.maker.MakerVerifyTakerFeePayment; -import bisq.core.trade.protocol.tasks.seller.SellerCreatesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller.SellerFinalizesDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller.SellerProcessesPaymentSentMessage; -import bisq.core.trade.protocol.tasks.seller.SellerProcessDelayedPayoutTxSignatureResponse; -import bisq.core.trade.protocol.tasks.seller.SellerPublishesDepositTx; -import bisq.core.trade.protocol.tasks.seller.SellerPublishesTradeStatistics; -import bisq.core.trade.protocol.tasks.seller.SellerSendDelayedPayoutTxSignatureRequest; -import bisq.core.trade.protocol.tasks.seller.SellerSendsPaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.seller.SellerPreparesPaymentReceivedMessage; -import bisq.core.trade.protocol.tasks.seller.SellerSignsDelayedPayoutTx; -import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerCreatesUnsignedDepositTx; -import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerFinalizesDepositTx; -import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerSendsInputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.seller_as_taker.SellerAsTakerCreatesDepositTxInputs; -import bisq.core.trade.protocol.tasks.seller_as_taker.SellerAsTakerSignsDepositTx; -import bisq.core.trade.protocol.tasks.taker.TakerProcessesInputsForDepositTxResponse; -import bisq.core.trade.protocol.tasks.taker.TakerPublishFeeTx; -import bisq.core.trade.protocol.tasks.taker.TakerVerifyMakerFeePayment; - import bisq.common.taskrunner.Task; import bisq.common.util.Tuple2; @@ -118,19 +93,10 @@ public class DebugView extends InitializableView { FXCollections.observableArrayList(Arrays.asList( ApplyFilter.class, TakerVerifyMakerFeePayment.class, - SellerAsTakerCreatesDepositTxInputs.class, - TakerProcessesInputsForDepositTxResponse.class, ApplyFilter.class, VerifyPeersAccountAgeWitness.class, - TakerPublishFeeTx.class, - SellerAsTakerSignsDepositTx.class, - SellerCreatesDelayedPayoutTx.class, - SellerSendDelayedPayoutTxSignatureRequest.class, - SellerProcessDelayedPayoutTxSignatureResponse.class, - SellerSignsDelayedPayoutTx.class, - SellerFinalizesDelayedPayoutTx.class, //SellerSendsDepositTxAndDelayedPayoutTxMessage.class, SellerPublishesDepositTx.class, SellerPublishesTradeStatistics.class, @@ -151,22 +117,11 @@ public class DebugView extends InitializableView { FXCollections.observableArrayList(Arrays.asList( ApplyFilter.class, VerifyPeersAccountAgeWitness.class, - MakerVerifyTakerFeePayment.class, MakerSetsLockTime.class, - BuyerAsMakerCreatesAndSignsDepositTx.class, - BuyerAsMakerSendsInputsForDepositTxResponse.class, - BuyerProcessDelayedPayoutTxSignatureRequest.class, MaybeRemoveOpenOffer.class, - BuyerVerifiesPreparedDelayedPayoutTx.class, - BuyerSignsDelayedPayoutTx.class, - BuyerSendsDelayedPayoutTxSignatureResponse.class, - - BuyerProcessDepositTxAndDelayedPayoutTxMessage.class, - BuyerVerifiesFinalDelayedPayoutTx.class, ApplyFilter.class, - MakerVerifyTakerFeePayment.class, BuyerPreparesPaymentSentMessage.class, BuyerSetupPayoutTxListener.class, BuyerSendsPaymentSentMessage.class, @@ -180,22 +135,9 @@ public class DebugView extends InitializableView { FXCollections.observableArrayList(Arrays.asList( ApplyFilter.class, TakerVerifyMakerFeePayment.class, - BuyerAsTakerCreatesDepositTxInputs.class, - TakerProcessesInputsForDepositTxResponse.class, ApplyFilter.class, VerifyPeersAccountAgeWitness.class, - TakerPublishFeeTx.class, - BuyerAsTakerSignsDepositTx.class, - BuyerAsTakerSendsDepositTxMessage.class, - - BuyerProcessDelayedPayoutTxSignatureRequest.class, - BuyerVerifiesPreparedDelayedPayoutTx.class, - BuyerSignsDelayedPayoutTx.class, - BuyerSendsDelayedPayoutTxSignatureResponse.class, - - BuyerProcessDepositTxAndDelayedPayoutTxMessage.class, - BuyerVerifiesFinalDelayedPayoutTx.class, ApplyFilter.class, TakerVerifyMakerFeePayment.class, @@ -209,30 +151,19 @@ public class DebugView extends InitializableView { FXCollections.observableArrayList(Arrays.asList( ApplyFilter.class, VerifyPeersAccountAgeWitness.class, - MakerVerifyTakerFeePayment.class, MakerSetsLockTime.class, - SellerAsMakerCreatesUnsignedDepositTx.class, - SellerAsMakerSendsInputsForDepositTxResponse.class, //SellerAsMakerProcessDepositTxMessage.class, MaybeRemoveOpenOffer.class, - SellerAsMakerFinalizesDepositTx.class, - SellerCreatesDelayedPayoutTx.class, - SellerSendDelayedPayoutTxSignatureRequest.class, - SellerProcessDelayedPayoutTxSignatureResponse.class, - SellerSignsDelayedPayoutTx.class, - SellerFinalizesDelayedPayoutTx.class, //SellerSendsDepositTxAndDelayedPayoutTxMessage.class, SellerPublishesDepositTx.class, SellerPublishesTradeStatistics.class, SellerProcessesPaymentSentMessage.class, ApplyFilter.class, - MakerVerifyTakerFeePayment.class, ApplyFilter.class, - MakerVerifyTakerFeePayment.class, SellerPreparesPaymentReceivedMessage.class, //SellerBroadcastPayoutTx.class, // TODO (woodser): removed from main pipeline; debug view? SellerSendsPaymentReceivedMessage.class diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index eacab9fbfd..2ed91b74e0 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -400,7 +400,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel