mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00:00
remove sender node address and pub key ring from non-mailbox messages
This commit is contained in:
parent
932854d7b2
commit
f1b9829b09
19 changed files with 45 additions and 148 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 +
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 +
|
||||
|
|
|
@ -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) +
|
||||
|
|
|
@ -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 +
|
||||
|
|
|
@ -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?
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue