remove sender node address and pub key ring from non-mailbox messages

This commit is contained in:
woodser 2023-01-19 07:24:08 -05:00
parent 932854d7b2
commit f1b9829b09
19 changed files with 45 additions and 148 deletions

View file

@ -738,6 +738,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
trade.getProcessModel().setMakerSignature(model.getMakerSignature()); trade.getProcessModel().setMakerSignature(model.getMakerSignature());
trade.getProcessModel().setUseSavingsWallet(useSavingsWallet); trade.getProcessModel().setUseSavingsWallet(useSavingsWallet);
trade.getProcessModel().setFundsNeededForTradeAsLong(fundsNeededForTrade.value); trade.getProcessModel().setFundsNeededForTradeAsLong(fundsNeededForTrade.value);
trade.getMaker().setPubKeyRing(trade.getOffer().getPubKeyRing());
trade.getTaker().setPubKeyRing(model.getPubKeyRing()); trade.getTaker().setPubKeyRing(model.getPubKeyRing());
trade.getTaker().setPaymentAccountId(paymentAccountId); trade.getTaker().setPaymentAccountId(paymentAccountId);

View file

@ -20,11 +20,9 @@ package bisq.core.trade.messages;
import bisq.core.proto.CoreProtoResolver; import bisq.core.proto.CoreProtoResolver;
import bisq.network.p2p.DirectMessage; import bisq.network.p2p.DirectMessage;
import bisq.network.p2p.NodeAddress;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.ProtoUtil; import bisq.common.proto.ProtoUtil;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Value; import lombok.Value;
@ -32,8 +30,6 @@ import lombok.Value;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Value @Value
public final class DepositRequest extends TradeMessage implements DirectMessage { public final class DepositRequest extends TradeMessage implements DirectMessage {
private final NodeAddress senderNodeAddress;
private final PubKeyRing pubKeyRing;
private final long currentDate; private final long currentDate;
private final String contractSignature; private final String contractSignature;
private final String depositTxHex; private final String depositTxHex;
@ -42,8 +38,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage
private final byte[] paymentAccountKey; private final byte[] paymentAccountKey;
public DepositRequest(String tradeId, public DepositRequest(String tradeId,
NodeAddress senderNodeAddress,
PubKeyRing pubKeyRing,
String uid, String uid,
String messageVersion, String messageVersion,
long currentDate, long currentDate,
@ -52,8 +46,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage
String depositTxKey, String depositTxKey,
@Nullable byte[] paymentAccountKey) { @Nullable byte[] paymentAccountKey) {
super(messageVersion, tradeId, uid); super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.pubKeyRing = pubKeyRing;
this.currentDate = currentDate; this.currentDate = currentDate;
this.contractSignature = contractSignature; this.contractSignature = contractSignature;
this.depositTxHex = depositTxHex; this.depositTxHex = depositTxHex;
@ -70,8 +62,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.DepositRequest.Builder builder = protobuf.DepositRequest.newBuilder() protobuf.DepositRequest.Builder builder = protobuf.DepositRequest.newBuilder()
.setTradeId(tradeId) .setTradeId(tradeId)
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setUid(uid) .setUid(uid)
.setContractSignature(contractSignature) .setContractSignature(contractSignature)
.setDepositTxHex(depositTxHex) .setDepositTxHex(depositTxHex)
@ -86,8 +76,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage
CoreProtoResolver coreProtoResolver, CoreProtoResolver coreProtoResolver,
String messageVersion) { String messageVersion) {
return new DepositRequest(proto.getTradeId(), return new DepositRequest(proto.getTradeId(),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getUid(), proto.getUid(),
messageVersion, messageVersion,
proto.getCurrentDate(), proto.getCurrentDate(),
@ -100,8 +88,6 @@ public final class DepositRequest extends TradeMessage implements DirectMessage
@Override @Override
public String toString() { public String toString() {
return "DepositRequest {" + return "DepositRequest {" +
"\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n currentDate=" + currentDate + ",\n currentDate=" + currentDate +
",\n contractSignature=" + contractSignature + ",\n contractSignature=" + contractSignature +
",\n depositTxHex='" + depositTxHex + ",\n depositTxHex='" + depositTxHex +

View file

@ -32,21 +32,15 @@ import lombok.Value;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Value @Value
public final class DepositResponse extends TradeMessage implements DirectMessage { public final class DepositResponse extends TradeMessage implements DirectMessage {
private final NodeAddress senderNodeAddress;
private final PubKeyRing pubKeyRing;
private final long currentDate; private final long currentDate;
private final String errorMessage; private final String errorMessage;
public DepositResponse(String tradeId, public DepositResponse(String tradeId,
NodeAddress senderNodeAddress,
PubKeyRing pubKeyRing,
String uid, String uid,
String messageVersion, String messageVersion,
long currentDate, long currentDate,
String errorMessage) { String errorMessage) {
super(messageVersion, tradeId, uid); super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.pubKeyRing = pubKeyRing;
this.currentDate = currentDate; this.currentDate = currentDate;
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
@ -60,8 +54,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.DepositResponse.Builder builder = protobuf.DepositResponse.newBuilder() protobuf.DepositResponse.Builder builder = protobuf.DepositResponse.newBuilder()
.setTradeId(tradeId) .setTradeId(tradeId)
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setUid(uid); .setUid(uid);
builder.setCurrentDate(currentDate); builder.setCurrentDate(currentDate);
Optional.ofNullable(errorMessage).ifPresent(e -> builder.setErrorMessage(errorMessage)); Optional.ofNullable(errorMessage).ifPresent(e -> builder.setErrorMessage(errorMessage));
@ -73,8 +65,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage
CoreProtoResolver coreProtoResolver, CoreProtoResolver coreProtoResolver,
String messageVersion) { String messageVersion) {
return new DepositResponse(proto.getTradeId(), return new DepositResponse(proto.getTradeId(),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getUid(), proto.getUid(),
messageVersion, messageVersion,
proto.getCurrentDate(), proto.getCurrentDate(),
@ -84,8 +74,6 @@ public final class DepositResponse extends TradeMessage implements DirectMessage
@Override @Override
public String toString() { public String toString() {
return "DepositResponse {" + return "DepositResponse {" +
"\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n currentDate=" + currentDate + ",\n currentDate=" + currentDate +
",\n errorMessage=" + errorMessage + ",\n errorMessage=" + errorMessage +
"\n} " + super.toString(); "\n} " + super.toString();

View file

@ -35,8 +35,6 @@ import javax.annotation.Nullable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Value @Value
public final class InitMultisigRequest extends TradeMessage implements DirectMessage { public final class InitMultisigRequest extends TradeMessage implements DirectMessage {
private final NodeAddress senderNodeAddress;
private final PubKeyRing pubKeyRing;
private final long currentDate; private final long currentDate;
@Nullable @Nullable
private final String preparedMultisigHex; private final String preparedMultisigHex;
@ -46,8 +44,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes
private final String exchangedMultisigHex; private final String exchangedMultisigHex;
public InitMultisigRequest(String tradeId, public InitMultisigRequest(String tradeId,
NodeAddress senderNodeAddress,
PubKeyRing pubKeyRing,
String uid, String uid,
String messageVersion, String messageVersion,
long currentDate, long currentDate,
@ -55,8 +51,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes
String madeMultisigHex, String madeMultisigHex,
String exchangedMultisigHex) { String exchangedMultisigHex) {
super(messageVersion, tradeId, uid); super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.pubKeyRing = pubKeyRing;
this.currentDate = currentDate; this.currentDate = currentDate;
this.preparedMultisigHex = preparedMultisigHex; this.preparedMultisigHex = preparedMultisigHex;
this.madeMultisigHex = madeMultisigHex; this.madeMultisigHex = madeMultisigHex;
@ -72,8 +66,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.InitMultisigRequest.Builder builder = protobuf.InitMultisigRequest.newBuilder() protobuf.InitMultisigRequest.Builder builder = protobuf.InitMultisigRequest.newBuilder()
.setTradeId(tradeId) .setTradeId(tradeId)
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setUid(uid); .setUid(uid);
Optional.ofNullable(preparedMultisigHex).ifPresent(e -> builder.setPreparedMultisigHex(preparedMultisigHex)); Optional.ofNullable(preparedMultisigHex).ifPresent(e -> builder.setPreparedMultisigHex(preparedMultisigHex));
@ -89,8 +81,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes
CoreProtoResolver coreProtoResolver, CoreProtoResolver coreProtoResolver,
String messageVersion) { String messageVersion) {
return new InitMultisigRequest(proto.getTradeId(), return new InitMultisigRequest(proto.getTradeId(),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getUid(), proto.getUid(),
messageVersion, messageVersion,
proto.getCurrentDate(), proto.getCurrentDate(),
@ -102,8 +92,6 @@ public final class InitMultisigRequest extends TradeMessage implements DirectMes
@Override @Override
public String toString() { public String toString() {
return "InitMultisigRequest {" + return "InitMultisigRequest {" +
"\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n currentDate=" + currentDate + ",\n currentDate=" + currentDate +
",\n preparedMultisigHex='" + preparedMultisigHex + ",\n preparedMultisigHex='" + preparedMultisigHex +
",\n madeMultisigHex='" + madeMultisigHex + ",\n madeMultisigHex='" + madeMultisigHex +

View file

@ -36,8 +36,6 @@ import lombok.Value;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Value @Value
public final class SignContractRequest extends TradeMessage implements DirectMessage { public final class SignContractRequest extends TradeMessage implements DirectMessage {
private final NodeAddress senderNodeAddress;
private final PubKeyRing pubKeyRing;
private final long currentDate; private final long currentDate;
private final String accountId; private final String accountId;
private final byte[] paymentAccountPayloadHash; private final byte[] paymentAccountPayloadHash;
@ -46,8 +44,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes
private final byte[] accountAgeWitnessSignatureOfDepositHash; private final byte[] accountAgeWitnessSignatureOfDepositHash;
public SignContractRequest(String tradeId, public SignContractRequest(String tradeId,
NodeAddress senderNodeAddress,
PubKeyRing pubKeyRing,
String uid, String uid,
String messageVersion, String messageVersion,
long currentDate, long currentDate,
@ -57,8 +53,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes
String depositTxHash, String depositTxHash,
@Nullable byte[] accountAgeWitnessSignatureOfDepositHash) { @Nullable byte[] accountAgeWitnessSignatureOfDepositHash) {
super(messageVersion, tradeId, uid); super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.pubKeyRing = pubKeyRing;
this.currentDate = currentDate; this.currentDate = currentDate;
this.accountId = accountId; this.accountId = accountId;
this.paymentAccountPayloadHash = paymentAccountPayloadHash; this.paymentAccountPayloadHash = paymentAccountPayloadHash;
@ -76,8 +70,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.SignContractRequest.Builder builder = protobuf.SignContractRequest.newBuilder() protobuf.SignContractRequest.Builder builder = protobuf.SignContractRequest.newBuilder()
.setTradeId(tradeId) .setTradeId(tradeId)
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setUid(uid) .setUid(uid)
.setAccountId(accountId) .setAccountId(accountId)
.setPaymentAccountPayloadHash(ByteString.copyFrom(paymentAccountPayloadHash)) .setPaymentAccountPayloadHash(ByteString.copyFrom(paymentAccountPayloadHash))
@ -94,8 +86,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes
CoreProtoResolver coreProtoResolver, CoreProtoResolver coreProtoResolver,
String messageVersion) { String messageVersion) {
return new SignContractRequest(proto.getTradeId(), return new SignContractRequest(proto.getTradeId(),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getUid(), proto.getUid(),
messageVersion, messageVersion,
proto.getCurrentDate(), proto.getCurrentDate(),
@ -109,8 +99,6 @@ public final class SignContractRequest extends TradeMessage implements DirectMes
@Override @Override
public String toString() { public String toString() {
return "SignContractRequest {" + return "SignContractRequest {" +
"\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n currentDate=" + currentDate + ",\n currentDate=" + currentDate +
",\n accountId=" + accountId + ",\n accountId=" + accountId +
",\n paymentAccountPayloadHash='" + Utilities.bytesAsHexString(paymentAccountPayloadHash) + ",\n paymentAccountPayloadHash='" + Utilities.bytesAsHexString(paymentAccountPayloadHash) +

View file

@ -33,16 +33,12 @@ import lombok.Value;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Value @Value
public final class SignContractResponse extends TradeMessage implements DirectMessage { public final class SignContractResponse extends TradeMessage implements DirectMessage {
private final NodeAddress senderNodeAddress;
private final PubKeyRing pubKeyRing;
private final long currentDate; private final long currentDate;
private final String contractAsJson; private final String contractAsJson;
private final String contractSignature; private final String contractSignature;
private final byte[] encryptedPaymentAccountPayload; private final byte[] encryptedPaymentAccountPayload;
public SignContractResponse(String tradeId, public SignContractResponse(String tradeId,
NodeAddress senderNodeAddress,
PubKeyRing pubKeyRing,
String uid, String uid,
String messageVersion, String messageVersion,
long currentDate, long currentDate,
@ -50,8 +46,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe
String contractSignature, String contractSignature,
@Nullable byte[] encryptedPaymentAccountPayload) { @Nullable byte[] encryptedPaymentAccountPayload) {
super(messageVersion, tradeId, uid); super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.pubKeyRing = pubKeyRing;
this.currentDate = currentDate; this.currentDate = currentDate;
this.contractAsJson = contractAsJson; this.contractAsJson = contractAsJson;
this.contractSignature = contractSignature; this.contractSignature = contractSignature;
@ -67,8 +61,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.SignContractResponse.Builder builder = protobuf.SignContractResponse.newBuilder() protobuf.SignContractResponse.Builder builder = protobuf.SignContractResponse.newBuilder()
.setTradeId(tradeId) .setTradeId(tradeId)
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setUid(uid); .setUid(uid);
Optional.ofNullable(contractAsJson).ifPresent(e -> builder.setContractAsJson(contractAsJson)); Optional.ofNullable(contractAsJson).ifPresent(e -> builder.setContractAsJson(contractAsJson));
@ -84,8 +76,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe
CoreProtoResolver coreProtoResolver, CoreProtoResolver coreProtoResolver,
String messageVersion) { String messageVersion) {
return new SignContractResponse(proto.getTradeId(), return new SignContractResponse(proto.getTradeId(),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
proto.getUid(), proto.getUid(),
messageVersion, messageVersion,
proto.getCurrentDate(), proto.getCurrentDate(),
@ -97,8 +87,6 @@ public final class SignContractResponse extends TradeMessage implements DirectMe
@Override @Override
public String toString() { public String toString() {
return "SignContractResponse {" + return "SignContractResponse {" +
"\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n currentDate=" + currentDate + ",\n currentDate=" + currentDate +
",\n contractAsJson='" + contractAsJson + ",\n contractAsJson='" + contractAsJson +
",\n contractSignature='" + contractSignature + ",\n contractSignature='" + contractSignature +

View file

@ -29,8 +29,6 @@ import bisq.common.handlers.ErrorMessageHandler;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j @Slf4j
public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol { public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol {
@ -40,11 +38,6 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
public BuyerAsTakerProtocol(BuyerAsTakerTrade trade) { public BuyerAsTakerProtocol(BuyerAsTakerTrade trade) {
super(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?
} }

View file

@ -18,7 +18,6 @@
package bisq.core.trade.protocol; package bisq.core.trade.protocol;
import bisq.core.offer.Offer;
import bisq.core.trade.SellerAsTakerTrade; import bisq.core.trade.SellerAsTakerTrade;
import bisq.core.trade.Trade; import bisq.core.trade.Trade;
import bisq.core.trade.handlers.TradeResultHandler; import bisq.core.trade.handlers.TradeResultHandler;
@ -29,8 +28,6 @@ import bisq.common.handlers.ErrorMessageHandler;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkNotNull;
// TODO (woodser): remove unused request handling // TODO (woodser): remove unused request handling
@Slf4j @Slf4j
public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol { public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol {
@ -41,9 +38,6 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
public SellerAsTakerProtocol(SellerAsTakerTrade trade) { public SellerAsTakerProtocol(SellerAsTakerTrade trade) {
super(trade); super(trade);
Offer offer = checkNotNull(trade.getOffer());
trade.getTradingPeer().setPubKeyRing(offer.getPubKeyRing());
trade.getMaker().setPubKeyRing(offer.getPubKeyRing());
} }

View file

@ -63,21 +63,20 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
String contractAsJson = trade.getContractAsJson(); String contractAsJson = trade.getContractAsJson();
DepositRequest request = (DepositRequest) processModel.getTradeMessage(); // TODO (woodser): verify response DepositRequest request = (DepositRequest) processModel.getTradeMessage(); // TODO (woodser): verify response
String signature = request.getContractSignature(); String signature = request.getContractSignature();
// get peer info // get trader info
TradingPeer peer = trade.getTradingPeer(request.getSenderNodeAddress()); TradingPeer trader = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress());
if (peer == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator"); if (trader == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator");
PubKeyRing peerPubKeyRing = peer.getPubKeyRing(); PubKeyRing peerPubKeyRing = trader.getPubKeyRing();
// verify signature // verify signature
if (!Sig.verify(peerPubKeyRing.getSignaturePubKey(), contractAsJson, signature)) throw new RuntimeException("Peer's contract signature is invalid"); if (!Sig.verify(peerPubKeyRing.getSignaturePubKey(), contractAsJson, signature)) throw new RuntimeException("Peer's contract signature is invalid");
// set peer's signature // set peer's signature
peer.setContractSignature(signature); trader.setContractSignature(signature);
// collect expected values // collect expected values
Offer offer = trade.getOffer(); Offer offer = trade.getOffer();
TradingPeer trader = trade.getTradingPeer(request.getSenderNodeAddress());
boolean isFromTaker = trader == trade.getTaker(); boolean isFromTaker = trader == trade.getTaker();
boolean isFromBuyer = trader == trade.getBuyer(); boolean isFromBuyer = trader == trade.getBuyer();
BigInteger tradeFee = HavenoUtils.coinToAtomicUnits(isFromTaker ? trade.getTakerFee() : trade.getMakerFee()); BigInteger tradeFee = HavenoUtils.coinToAtomicUnits(isFromTaker ? trade.getTakerFee() : trade.getMakerFee());
@ -97,7 +96,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
request.getDepositTxKey(), request.getDepositTxKey(),
null); null);
} catch (Exception e) { } 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 // set deposit info
@ -124,8 +123,6 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
// create deposit response // create deposit response
DepositResponse response = new DepositResponse( DepositResponse response = new DepositResponse(
trade.getOffer().getId(), trade.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),
@ -154,8 +151,6 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
// create deposit response with error // create deposit response with error
DepositResponse response = new DepositResponse( DepositResponse response = new DepositResponse(
trade.getOffer().getId(), trade.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -132,8 +132,6 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
// create message to initialize multisig // create message to initialize multisig
InitMultisigRequest initMultisigRequest = new InitMultisigRequest( InitMultisigRequest initMultisigRequest = new InitMultisigRequest(
processModel.getOffer().getId(), processModel.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -88,8 +88,6 @@ public class MaybeSendSignContractRequest extends TradeTask {
// create request for peer and arbitrator to sign contract // create request for peer and arbitrator to sign contract
SignContractRequest request = new SignContractRequest( SignContractRequest request = new SignContractRequest(
trade.getOffer().getId(), trade.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -22,8 +22,11 @@ import bisq.common.taskrunner.TaskRunner;
import bisq.core.trade.Trade; import bisq.core.trade.Trade;
import bisq.core.trade.messages.DepositsConfirmedMessage; import bisq.core.trade.messages.DepositsConfirmedMessage;
import bisq.core.trade.protocol.TradingPeer; import bisq.core.trade.protocol.TradingPeer;
import bisq.core.util.Validator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j @Slf4j
public class ProcessDepositsConfirmedMessage extends TradeTask { public class ProcessDepositsConfirmedMessage extends TradeTask {
@ -39,6 +42,8 @@ public class ProcessDepositsConfirmedMessage extends TradeTask {
// get peer // get peer
DepositsConfirmedMessage request = (DepositsConfirmedMessage) processModel.getTradeMessage(); DepositsConfirmedMessage request = (DepositsConfirmedMessage) processModel.getTradeMessage();
checkNotNull(request);
Validator.checkTradeId(processModel.getOfferId(), request);
TradingPeer sender = trade.getTradingPeer(request.getPubKeyRing()); TradingPeer sender = trade.getTradingPeer(request.getPubKeyRing());
if (sender == null) throw new RuntimeException("Pub key ring is not from arbitrator, buyer, or seller"); if (sender == null) throw new RuntimeException("Pub key ring is not from arbitrator, buyer, or seller");

View file

@ -67,16 +67,8 @@ public class ProcessInitMultisigRequest extends TradeTask {
checkTradeId(processModel.getOfferId(), request); checkTradeId(processModel.getOfferId(), request);
XmrWalletService xmrWalletService = processModel.getProvider().getXmrWalletService(); 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 // get peer multisig participant
TradingPeer multisigParticipant; TradingPeer multisigParticipant = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress());
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());
// reconcile peer's established multisig hex with message // reconcile peer's established multisig hex with message
if (multisigParticipant.getPreparedMultisigHex() == null) multisigParticipant.setPreparedMultisigHex(request.getPreparedMultisigHex()); if (multisigParticipant.getPreparedMultisigHex() == null) multisigParticipant.setPreparedMultisigHex(request.getPreparedMultisigHex());
@ -215,8 +207,6 @@ public class ProcessInitMultisigRequest extends TradeTask {
// create multisig message with current multisig hex // create multisig message with current multisig hex
InitMultisigRequest request = new InitMultisigRequest( InitMultisigRequest request = new InitMultisigRequest(
processModel.getOffer().getId(), processModel.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -61,8 +61,7 @@ public class ProcessInitTradeRequest extends TradeTask {
TradingPeer multisigParticipant; TradingPeer multisigParticipant;
if (trade instanceof ArbitratorTrade) { if (trade instanceof ArbitratorTrade) {
trade.getMaker().setPubKeyRing((trade.getOffer().getPubKeyRing())); trade.getMaker().setPubKeyRing((trade.getOffer().getPubKeyRing()));
trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model
processModel.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model
// handle request from taker // handle request from taker
if (request.getSenderNodeAddress().equals(request.getTakerNodeAddress())) { if (request.getSenderNodeAddress().equals(request.getTakerNodeAddress())) {

View file

@ -48,8 +48,8 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
runInterceptHook(); runInterceptHook();
log.debug("current trade state " + trade.getState()); log.debug("current trade state " + trade.getState());
PaymentReceivedMessage message = (PaymentReceivedMessage) processModel.getTradeMessage(); PaymentReceivedMessage message = (PaymentReceivedMessage) processModel.getTradeMessage();
Validator.checkTradeId(processModel.getOfferId(), message);
checkNotNull(message); checkNotNull(message);
Validator.checkTradeId(processModel.getOfferId(), message);
checkArgument(message.getUnsignedPayoutTxHex() != null || message.getSignedPayoutTxHex() != null, "No payout tx hex provided"); checkArgument(message.getUnsignedPayoutTxHex() != null || message.getSignedPayoutTxHex() != null, "No payout tx hex provided");
// verify signature of payment received message // verify signature of payment received message

View file

@ -38,8 +38,8 @@ public class ProcessPaymentSentMessage extends TradeTask {
runInterceptHook(); runInterceptHook();
log.debug("current trade state " + trade.getState()); log.debug("current trade state " + trade.getState());
PaymentSentMessage message = (PaymentSentMessage) processModel.getTradeMessage(); PaymentSentMessage message = (PaymentSentMessage) processModel.getTradeMessage();
Validator.checkTradeId(processModel.getOfferId(), message);
checkNotNull(message); checkNotNull(message);
Validator.checkTradeId(processModel.getOfferId(), message);
// verify signature of payment sent message // verify signature of payment sent message
HavenoUtils.verifyPaymentSentMessage(trade, message); HavenoUtils.verifyPaymentSentMessage(trade, message);

View file

@ -65,7 +65,7 @@ public class ProcessSignContractRequest extends TradeTask {
// extract fields from request // extract fields from request
// TODO (woodser): verify request and from maker or taker // TODO (woodser): verify request and from maker or taker
SignContractRequest request = (SignContractRequest) processModel.getTradeMessage(); SignContractRequest request = (SignContractRequest) processModel.getTradeMessage();
TradingPeer trader = trade.getTradingPeer(request.getSenderNodeAddress()); TradingPeer trader = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress());
trader.setDepositTxHash(request.getDepositTxHash()); trader.setDepositTxHash(request.getDepositTxHash());
trader.setAccountId(request.getAccountId()); trader.setAccountId(request.getAccountId());
trader.setPaymentAccountPayloadHash(request.getPaymentAccountPayloadHash()); trader.setPaymentAccountPayloadHash(request.getPaymentAccountPayloadHash());
@ -112,8 +112,6 @@ public class ProcessSignContractRequest extends TradeTask {
// create response with contract signature // create response with contract signature
SignContractResponse response = new SignContractResponse( SignContractResponse response = new SignContractResponse(
trade.getOffer().getId(), trade.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -54,7 +54,7 @@ public class ProcessSignContractResponse extends TradeTask {
} }
// get peer info // get peer info
TradingPeer peer = trade.getTradingPeer(response.getSenderNodeAddress()); TradingPeer peer = trade.getTradingPeer(processModel.getTempTradingPeerNodeAddress());
PubKeyRing peerPubKeyRing = peer.getPubKeyRing(); PubKeyRing peerPubKeyRing = peer.getPubKeyRing();
// save peer's encrypted payment account payload // 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 // create request for arbitrator to deposit funds to multisig
DepositRequest request = new DepositRequest( DepositRequest request = new DepositRequest(
trade.getOffer().getId(), trade.getOffer().getId(),
processModel.getMyNodeAddress(),
processModel.getPubKeyRing(),
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
Version.getP2PMessageVersion(), Version.getP2PMessageVersion(),
new Date().getTime(), new Date().getTime(),

View file

@ -293,58 +293,48 @@ message InitTradeRequest {
message InitMultisigRequest { message InitMultisigRequest {
string trade_id = 1; string trade_id = 1;
NodeAddress sender_node_address = 2; string uid = 2;
PubKeyRing pub_key_ring = 3; int64 current_date = 3;
string uid = 4; string prepared_multisig_hex = 4;
int64 current_date = 5; string made_multisig_hex = 5;
string prepared_multisig_hex = 6; string exchanged_multisig_hex = 6;
string made_multisig_hex = 7;
string exchanged_multisig_hex = 8;
} }
message SignContractRequest { message SignContractRequest {
string trade_id = 1; string trade_id = 1;
NodeAddress sender_node_address = 2; string uid = 2;
PubKeyRing pub_key_ring = 3; int64 current_date = 3;
string uid = 4; string account_id = 4;
int64 current_date = 5; bytes payment_account_payload_hash = 5;
string account_id = 6; string payout_address = 6;
bytes payment_account_payload_hash = 7; string deposit_tx_hash = 7;
string payout_address = 8;; bytes account_age_witness_signature_of_deposit_hash = 8;
string deposit_tx_hash = 9;
bytes account_age_witness_signature_of_deposit_hash = 10;
} }
message SignContractResponse { message SignContractResponse {
string trade_id = 1; string trade_id = 1;
NodeAddress sender_node_address = 2; string uid = 2;
PubKeyRing pub_key_ring = 3; int64 current_date = 3;
string uid = 4; string contract_as_json = 4;
int64 current_date = 5; string contract_signature = 5;
string contract_as_json = 6; bytes encrypted_payment_account_payload = 6;
string contract_signature = 7;
bytes encrypted_payment_account_payload = 8;
} }
message DepositRequest { message DepositRequest {
string trade_id = 1; string trade_id = 1;
NodeAddress sender_node_address = 2; string uid = 2;
PubKeyRing pub_key_ring = 3; int64 current_date = 3;
string uid = 4; string contract_signature = 4;
int64 current_date = 5; string deposit_tx_hex = 5;
string contract_signature = 6; string deposit_tx_key = 6;
string deposit_tx_hex = 7; bytes payment_account_key = 7;
string deposit_tx_key = 8;
bytes payment_account_key = 9;
} }
message DepositResponse { message DepositResponse {
string trade_id = 1; string trade_id = 1;
NodeAddress sender_node_address = 2; string uid = 2;
PubKeyRing pub_key_ring = 3; int64 current_date = 3;
string uid = 4; string error_message = 4;
int64 current_date = 5;
string error_message = 6;
} }
message DepositsConfirmedMessage { message DepositsConfirmedMessage {