diff --git a/core/src/main/java/bisq/core/trade/TradeManager.java b/core/src/main/java/bisq/core/trade/TradeManager.java index 4e11b2cc..6b4f5782 100644 --- a/core/src/main/java/bisq/core/trade/TradeManager.java +++ b/core/src/main/java/bisq/core/trade/TradeManager.java @@ -738,6 +738,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi trade.getProcessModel().setMakerSignature(model.getMakerSignature()); trade.getProcessModel().setUseSavingsWallet(useSavingsWallet); trade.getProcessModel().setFundsNeededForTradeAsLong(fundsNeededForTrade.value); + trade.getMaker().setPubKeyRing(trade.getOffer().getPubKeyRing()); trade.getTaker().setPubKeyRing(model.getPubKeyRing()); trade.getTaker().setPaymentAccountId(paymentAccountId); diff --git a/core/src/main/java/bisq/core/trade/messages/DepositRequest.java b/core/src/main/java/bisq/core/trade/messages/DepositRequest.java index 0a994bef..9c06ea2b 100644 --- a/core/src/main/java/bisq/core/trade/messages/DepositRequest.java +++ b/core/src/main/java/bisq/core/trade/messages/DepositRequest.java @@ -20,11 +20,9 @@ package bisq.core.trade.messages; import bisq.core.proto.CoreProtoResolver; import bisq.network.p2p.DirectMessage; -import bisq.network.p2p.NodeAddress; import com.google.protobuf.ByteString; import java.util.Optional; import javax.annotation.Nullable; -import bisq.common.crypto.PubKeyRing; import bisq.common.proto.ProtoUtil; import lombok.EqualsAndHashCode; import lombok.Value; @@ -32,8 +30,6 @@ import lombok.Value; @EqualsAndHashCode(callSuper = true) @Value public final class DepositRequest extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final PubKeyRing pubKeyRing; private final long currentDate; private final String contractSignature; private final String depositTxHex; @@ -42,8 +38,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage private final byte[] paymentAccountKey; public DepositRequest(String tradeId, - NodeAddress senderNodeAddress, - PubKeyRing pubKeyRing, String uid, String messageVersion, long currentDate, @@ -52,8 +46,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage String depositTxKey, @Nullable byte[] paymentAccountKey) { super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.pubKeyRing = pubKeyRing; this.currentDate = currentDate; this.contractSignature = contractSignature; this.depositTxHex = depositTxHex; @@ -70,8 +62,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { protobuf.DepositRequest.Builder builder = protobuf.DepositRequest.newBuilder() .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setPubKeyRing(pubKeyRing.toProtoMessage()) .setUid(uid) .setContractSignature(contractSignature) .setDepositTxHex(depositTxHex) @@ -86,8 +76,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage CoreProtoResolver coreProtoResolver, String messageVersion) { return new DepositRequest(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - PubKeyRing.fromProto(proto.getPubKeyRing()), proto.getUid(), messageVersion, proto.getCurrentDate(), @@ -100,8 +88,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage @Override public String toString() { return "DepositRequest {" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n currentDate=" + currentDate + ",\n contractSignature=" + contractSignature + ",\n depositTxHex='" + depositTxHex + diff --git a/core/src/main/java/bisq/core/trade/messages/DepositResponse.java b/core/src/main/java/bisq/core/trade/messages/DepositResponse.java index 129d6de5..c7d8a693 100644 --- a/core/src/main/java/bisq/core/trade/messages/DepositResponse.java +++ b/core/src/main/java/bisq/core/trade/messages/DepositResponse.java @@ -32,21 +32,15 @@ import lombok.Value; @EqualsAndHashCode(callSuper = true) @Value public final class DepositResponse extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final PubKeyRing pubKeyRing; private final long currentDate; private final String errorMessage; public DepositResponse(String tradeId, - NodeAddress senderNodeAddress, - PubKeyRing pubKeyRing, String uid, String messageVersion, long currentDate, String errorMessage) { super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.pubKeyRing = pubKeyRing; this.currentDate = currentDate; this.errorMessage = errorMessage; } @@ -60,8 +54,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { protobuf.DepositResponse.Builder builder = protobuf.DepositResponse.newBuilder() .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setPubKeyRing(pubKeyRing.toProtoMessage()) .setUid(uid); builder.setCurrentDate(currentDate); Optional.ofNullable(errorMessage).ifPresent(e -> builder.setErrorMessage(errorMessage)); @@ -73,8 +65,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage CoreProtoResolver coreProtoResolver, String messageVersion) { return new DepositResponse(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - PubKeyRing.fromProto(proto.getPubKeyRing()), proto.getUid(), messageVersion, proto.getCurrentDate(), @@ -84,8 +74,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage @Override public String toString() { return "DepositResponse {" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n currentDate=" + currentDate + ",\n errorMessage=" + errorMessage + "\n} " + super.toString(); diff --git a/core/src/main/java/bisq/core/trade/messages/InitMultisigRequest.java b/core/src/main/java/bisq/core/trade/messages/InitMultisigRequest.java index 1f560913..bb6352ea 100644 --- a/core/src/main/java/bisq/core/trade/messages/InitMultisigRequest.java +++ b/core/src/main/java/bisq/core/trade/messages/InitMultisigRequest.java @@ -35,8 +35,6 @@ import javax.annotation.Nullable; @EqualsAndHashCode(callSuper = true) @Value public final class InitMultisigRequest extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final PubKeyRing pubKeyRing; private final long currentDate; @Nullable private final String preparedMultisigHex; @@ -46,8 +44,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes private final String exchangedMultisigHex; public InitMultisigRequest(String tradeId, - NodeAddress senderNodeAddress, - PubKeyRing pubKeyRing, String uid, String messageVersion, long currentDate, @@ -55,8 +51,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes String madeMultisigHex, String exchangedMultisigHex) { super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.pubKeyRing = pubKeyRing; this.currentDate = currentDate; this.preparedMultisigHex = preparedMultisigHex; this.madeMultisigHex = madeMultisigHex; @@ -72,8 +66,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { protobuf.InitMultisigRequest.Builder builder = protobuf.InitMultisigRequest.newBuilder() .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setPubKeyRing(pubKeyRing.toProtoMessage()) .setUid(uid); Optional.ofNullable(preparedMultisigHex).ifPresent(e -> builder.setPreparedMultisigHex(preparedMultisigHex)); @@ -89,8 +81,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes CoreProtoResolver coreProtoResolver, String messageVersion) { return new InitMultisigRequest(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - PubKeyRing.fromProto(proto.getPubKeyRing()), proto.getUid(), messageVersion, proto.getCurrentDate(), @@ -102,8 +92,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes @Override public String toString() { return "InitMultisigRequest {" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n currentDate=" + currentDate + ",\n preparedMultisigHex='" + preparedMultisigHex + ",\n madeMultisigHex='" + madeMultisigHex + diff --git a/core/src/main/java/bisq/core/trade/messages/SignContractRequest.java b/core/src/main/java/bisq/core/trade/messages/SignContractRequest.java index fc767583..e35e1800 100644 --- a/core/src/main/java/bisq/core/trade/messages/SignContractRequest.java +++ b/core/src/main/java/bisq/core/trade/messages/SignContractRequest.java @@ -36,8 +36,6 @@ import lombok.Value; @EqualsAndHashCode(callSuper = true) @Value public final class SignContractRequest extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final PubKeyRing pubKeyRing; private final long currentDate; private final String accountId; private final byte[] paymentAccountPayloadHash; @@ -46,8 +44,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes private final byte[] accountAgeWitnessSignatureOfDepositHash; public SignContractRequest(String tradeId, - NodeAddress senderNodeAddress, - PubKeyRing pubKeyRing, String uid, String messageVersion, long currentDate, @@ -57,8 +53,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes String depositTxHash, @Nullable byte[] accountAgeWitnessSignatureOfDepositHash) { super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.pubKeyRing = pubKeyRing; this.currentDate = currentDate; this.accountId = accountId; this.paymentAccountPayloadHash = paymentAccountPayloadHash; @@ -76,8 +70,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { protobuf.SignContractRequest.Builder builder = protobuf.SignContractRequest.newBuilder() .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setPubKeyRing(pubKeyRing.toProtoMessage()) .setUid(uid) .setAccountId(accountId) .setPaymentAccountPayloadHash(ByteString.copyFrom(paymentAccountPayloadHash)) @@ -94,8 +86,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes CoreProtoResolver coreProtoResolver, String messageVersion) { return new SignContractRequest(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - PubKeyRing.fromProto(proto.getPubKeyRing()), proto.getUid(), messageVersion, proto.getCurrentDate(), @@ -109,8 +99,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes @Override public String toString() { return "SignContractRequest {" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n currentDate=" + currentDate + ",\n accountId=" + accountId + ",\n paymentAccountPayloadHash='" + Utilities.bytesAsHexString(paymentAccountPayloadHash) + diff --git a/core/src/main/java/bisq/core/trade/messages/SignContractResponse.java b/core/src/main/java/bisq/core/trade/messages/SignContractResponse.java index cd9ff89f..be740dda 100644 --- a/core/src/main/java/bisq/core/trade/messages/SignContractResponse.java +++ b/core/src/main/java/bisq/core/trade/messages/SignContractResponse.java @@ -33,16 +33,12 @@ import lombok.Value; @EqualsAndHashCode(callSuper = true) @Value public final class SignContractResponse extends TradeMessage implements DirectMessage { - private final NodeAddress senderNodeAddress; - private final PubKeyRing pubKeyRing; private final long currentDate; private final String contractAsJson; private final String contractSignature; private final byte[] encryptedPaymentAccountPayload; public SignContractResponse(String tradeId, - NodeAddress senderNodeAddress, - PubKeyRing pubKeyRing, String uid, String messageVersion, long currentDate, @@ -50,8 +46,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe String contractSignature, @Nullable byte[] encryptedPaymentAccountPayload) { super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - this.pubKeyRing = pubKeyRing; this.currentDate = currentDate; this.contractAsJson = contractAsJson; this.contractSignature = contractSignature; @@ -67,8 +61,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { protobuf.SignContractResponse.Builder builder = protobuf.SignContractResponse.newBuilder() .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()) - .setPubKeyRing(pubKeyRing.toProtoMessage()) .setUid(uid); Optional.ofNullable(contractAsJson).ifPresent(e -> builder.setContractAsJson(contractAsJson)); @@ -84,8 +76,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe CoreProtoResolver coreProtoResolver, String messageVersion) { return new SignContractResponse(proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress()), - PubKeyRing.fromProto(proto.getPubKeyRing()), proto.getUid(), messageVersion, proto.getCurrentDate(), @@ -97,8 +87,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe @Override public String toString() { return "SignContractResponse {" + - "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n currentDate=" + currentDate + ",\n contractAsJson='" + contractAsJson + ",\n contractSignature='" + contractSignature + 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 b2aa44fd..86ec2625 100644 --- a/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java @@ -29,8 +29,6 @@ import bisq.common.handlers.ErrorMessageHandler; import lombok.extern.slf4j.Slf4j; -import static com.google.common.base.Preconditions.checkNotNull; - @Slf4j public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol { @@ -40,11 +38,6 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol public BuyerAsTakerProtocol(BuyerAsTakerTrade trade) { super(trade); - Offer offer = checkNotNull(trade.getOffer()); - trade.getTradingPeer().setPubKeyRing(offer.getPubKeyRing()); - trade.getMaker().setPubKeyRing(offer.getPubKeyRing()); - - // TODO (woodser): setup deposit and payout listeners on construction for startup like before rebase? } 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 de1b4b90..b1430c6c 100644 --- a/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java @@ -18,7 +18,6 @@ package bisq.core.trade.protocol; -import bisq.core.offer.Offer; import bisq.core.trade.SellerAsTakerTrade; import bisq.core.trade.Trade; import bisq.core.trade.handlers.TradeResultHandler; @@ -29,8 +28,6 @@ import bisq.common.handlers.ErrorMessageHandler; import lombok.extern.slf4j.Slf4j; -import static com.google.common.base.Preconditions.checkNotNull; - // TODO (woodser): remove unused request handling @Slf4j public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol { @@ -41,9 +38,6 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc public SellerAsTakerProtocol(SellerAsTakerTrade trade) { super(trade); - Offer offer = checkNotNull(trade.getOffer()); - trade.getTradingPeer().setPubKeyRing(offer.getPubKeyRing()); - trade.getMaker().setPubKeyRing(offer.getPubKeyRing()); } diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java index 02639095..d984d789 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java @@ -63,21 +63,20 @@ public class ArbitratorProcessDepositRequest extends TradeTask { String contractAsJson = trade.getContractAsJson(); DepositRequest request = (DepositRequest) processModel.getTradeMessage(); // TODO (woodser): verify response String signature = request.getContractSignature(); - - // get peer info - TradingPeer peer = trade.getTradingPeer(request.getSenderNodeAddress()); - if (peer == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator"); - PubKeyRing peerPubKeyRing = peer.getPubKeyRing(); + + // get trader info + TradingPeer trader = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress()); + if (trader == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator"); + PubKeyRing peerPubKeyRing = trader.getPubKeyRing(); // verify signature if (!Sig.verify(peerPubKeyRing.getSignaturePubKey(), contractAsJson, signature)) throw new RuntimeException("Peer's contract signature is invalid"); // set peer's signature - peer.setContractSignature(signature); + trader.setContractSignature(signature); // collect expected values Offer offer = trade.getOffer(); - TradingPeer trader = trade.getTradingPeer(request.getSenderNodeAddress()); boolean isFromTaker = trader == trade.getTaker(); boolean isFromBuyer = trader == trade.getBuyer(); BigInteger tradeFee = HavenoUtils.coinToAtomicUnits(isFromTaker ? trade.getTakerFee() : trade.getMakerFee()); @@ -97,7 +96,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask { request.getDepositTxKey(), null); } catch (Exception e) { - throw new RuntimeException("Error processing deposit tx from " + (isFromTaker ? "taker " : "maker ") + request.getSenderNodeAddress() + ", offerId=" + offer.getId() + ": " + e.getMessage()); + throw new RuntimeException("Error processing deposit tx from " + (isFromTaker ? "taker " : "maker ") + trader.getNodeAddress() + ", offerId=" + offer.getId() + ": " + e.getMessage()); } // set deposit info @@ -124,8 +123,6 @@ public class ArbitratorProcessDepositRequest extends TradeTask { // create deposit response DepositResponse response = new DepositResponse( trade.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), @@ -154,8 +151,6 @@ public class ArbitratorProcessDepositRequest extends TradeTask { // create deposit response with error DepositResponse response = new DepositResponse( trade.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java index cdca88c8..d22e0c32 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java @@ -132,8 +132,6 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask { // create message to initialize multisig InitMultisigRequest initMultisigRequest = new InitMultisigRequest( processModel.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeSendSignContractRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeSendSignContractRequest.java index 77a7df73..7cacee13 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeSendSignContractRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/MaybeSendSignContractRequest.java @@ -88,8 +88,6 @@ public class MaybeSendSignContractRequest extends TradeTask { // create request for peer and arbitrator to sign contract SignContractRequest request = new SignContractRequest( trade.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositsConfirmedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositsConfirmedMessage.java index 771d4884..9f370233 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositsConfirmedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessDepositsConfirmedMessage.java @@ -22,8 +22,11 @@ import bisq.common.taskrunner.TaskRunner; import bisq.core.trade.Trade; import bisq.core.trade.messages.DepositsConfirmedMessage; import bisq.core.trade.protocol.TradingPeer; +import bisq.core.util.Validator; import lombok.extern.slf4j.Slf4j; +import static com.google.common.base.Preconditions.checkNotNull; + @Slf4j public class ProcessDepositsConfirmedMessage extends TradeTask { @@ -39,6 +42,8 @@ public class ProcessDepositsConfirmedMessage extends TradeTask { // get peer DepositsConfirmedMessage request = (DepositsConfirmedMessage) processModel.getTradeMessage(); + checkNotNull(request); + Validator.checkTradeId(processModel.getOfferId(), request); TradingPeer sender = trade.getTradingPeer(request.getPubKeyRing()); if (sender == null) throw new RuntimeException("Pub key ring is not from arbitrator, buyer, or seller"); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitMultisigRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitMultisigRequest.java index 236e0062..484bdf56 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitMultisigRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitMultisigRequest.java @@ -67,16 +67,8 @@ public class ProcessInitMultisigRequest extends TradeTask { checkTradeId(processModel.getOfferId(), request); XmrWalletService xmrWalletService = processModel.getProvider().getXmrWalletService(); - // TODO (woodser): verify request including sender's signature in previous pipeline task - // TODO (woodser): run in separate thread to not block UI thread? - // TODO (woodser): validate message has expected sender in previous step - // get peer multisig participant - TradingPeer multisigParticipant; - if (request.getSenderNodeAddress().equals(trade.getMaker().getNodeAddress())) multisigParticipant = processModel.getMaker(); - else if (request.getSenderNodeAddress().equals(trade.getTaker().getNodeAddress())) multisigParticipant = processModel.getTaker(); - else if (request.getSenderNodeAddress().equals(trade.getArbitrator().getNodeAddress())) multisigParticipant = processModel.getArbitrator(); - else throw new RuntimeException("Invalid sender to process init trade message: " + trade.getClass().getName()); + TradingPeer multisigParticipant = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress()); // reconcile peer's established multisig hex with message if (multisigParticipant.getPreparedMultisigHex() == null) multisigParticipant.setPreparedMultisigHex(request.getPreparedMultisigHex()); @@ -215,8 +207,6 @@ public class ProcessInitMultisigRequest extends TradeTask { // create multisig message with current multisig hex InitMultisigRequest request = new InitMultisigRequest( processModel.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitTradeRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitTradeRequest.java index 65cffcd7..78f8385b 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitTradeRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessInitTradeRequest.java @@ -61,8 +61,7 @@ public class ProcessInitTradeRequest extends TradeTask { TradingPeer multisigParticipant; if (trade instanceof ArbitratorTrade) { trade.getMaker().setPubKeyRing((trade.getOffer().getPubKeyRing())); - trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); - processModel.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model + trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model // handle request from taker if (request.getSenderNodeAddress().equals(request.getTakerNodeAddress())) { diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java index 202bd6e6..5a501376 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java @@ -48,8 +48,8 @@ public class ProcessPaymentReceivedMessage extends TradeTask { runInterceptHook(); log.debug("current trade state " + trade.getState()); PaymentReceivedMessage message = (PaymentReceivedMessage) processModel.getTradeMessage(); - Validator.checkTradeId(processModel.getOfferId(), message); checkNotNull(message); + Validator.checkTradeId(processModel.getOfferId(), message); checkArgument(message.getUnsignedPayoutTxHex() != null || message.getSignedPayoutTxHex() != null, "No payout tx hex provided"); // verify signature of payment received message diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentSentMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentSentMessage.java index 3ec860d2..af31d25b 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentSentMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentSentMessage.java @@ -38,8 +38,8 @@ public class ProcessPaymentSentMessage extends TradeTask { runInterceptHook(); log.debug("current trade state " + trade.getState()); PaymentSentMessage message = (PaymentSentMessage) processModel.getTradeMessage(); - Validator.checkTradeId(processModel.getOfferId(), message); checkNotNull(message); + Validator.checkTradeId(processModel.getOfferId(), message); // verify signature of payment sent message HavenoUtils.verifyPaymentSentMessage(trade, message); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractRequest.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractRequest.java index 97ba94e7..31b8426a 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractRequest.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessSignContractRequest.java @@ -65,7 +65,7 @@ public class ProcessSignContractRequest extends TradeTask { // extract fields from request // TODO (woodser): verify request and from maker or taker SignContractRequest request = (SignContractRequest) processModel.getTradeMessage(); - TradingPeer trader = trade.getTradingPeer(request.getSenderNodeAddress()); + TradingPeer trader = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress()); trader.setDepositTxHash(request.getDepositTxHash()); trader.setAccountId(request.getAccountId()); trader.setPaymentAccountPayloadHash(request.getPaymentAccountPayloadHash()); @@ -112,8 +112,6 @@ public class ProcessSignContractRequest extends TradeTask { // create response with contract signature SignContractResponse response = new SignContractResponse( trade.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), 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 fdad9d61..0a8785c2 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 @@ -54,7 +54,7 @@ public class ProcessSignContractResponse extends TradeTask { } // get peer info - TradingPeer peer = trade.getTradingPeer(response.getSenderNodeAddress()); + TradingPeer peer = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress()); PubKeyRing peerPubKeyRing = peer.getPubKeyRing(); // save peer's encrypted payment account payload @@ -75,8 +75,6 @@ public class ProcessSignContractResponse extends TradeTask { // create request for arbitrator to deposit funds to multisig DepositRequest request = new DepositRequest( trade.getOffer().getId(), - processModel.getMyNodeAddress(), - processModel.getPubKeyRing(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), new Date().getTime(), diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 7132e8c4..725766ba 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -293,58 +293,48 @@ message InitTradeRequest { message InitMultisigRequest { string trade_id = 1; - NodeAddress sender_node_address = 2; - PubKeyRing pub_key_ring = 3; - string uid = 4; - int64 current_date = 5; - string prepared_multisig_hex = 6; - string made_multisig_hex = 7; - string exchanged_multisig_hex = 8; + string uid = 2; + int64 current_date = 3; + string prepared_multisig_hex = 4; + string made_multisig_hex = 5; + string exchanged_multisig_hex = 6; } message SignContractRequest { string trade_id = 1; - NodeAddress sender_node_address = 2; - PubKeyRing pub_key_ring = 3; - string uid = 4; - int64 current_date = 5; - string account_id = 6; - bytes payment_account_payload_hash = 7; - string payout_address = 8;; - string deposit_tx_hash = 9; - bytes account_age_witness_signature_of_deposit_hash = 10; + string uid = 2; + int64 current_date = 3; + string account_id = 4; + bytes payment_account_payload_hash = 5; + string payout_address = 6; + string deposit_tx_hash = 7; + bytes account_age_witness_signature_of_deposit_hash = 8; } message SignContractResponse { string trade_id = 1; - NodeAddress sender_node_address = 2; - PubKeyRing pub_key_ring = 3; - string uid = 4; - int64 current_date = 5; - string contract_as_json = 6; - string contract_signature = 7; - bytes encrypted_payment_account_payload = 8; + string uid = 2; + int64 current_date = 3; + string contract_as_json = 4; + string contract_signature = 5; + bytes encrypted_payment_account_payload = 6; } message DepositRequest { string trade_id = 1; - NodeAddress sender_node_address = 2; - PubKeyRing pub_key_ring = 3; - string uid = 4; - int64 current_date = 5; - string contract_signature = 6; - string deposit_tx_hex = 7; - string deposit_tx_key = 8; - bytes payment_account_key = 9; + string uid = 2; + int64 current_date = 3; + string contract_signature = 4; + string deposit_tx_hex = 5; + string deposit_tx_key = 6; + bytes payment_account_key = 7; } message DepositResponse { string trade_id = 1; - NodeAddress sender_node_address = 2; - PubKeyRing pub_key_ring = 3; - string uid = 4; - int64 current_date = 5; - string error_message = 6; + string uid = 2; + int64 current_date = 3; + string error_message = 4; } message DepositsConfirmedMessage {