mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
refactor node addresses and pub key rings to TradingPeer (#460)
This commit is contained in:
parent
c153afff67
commit
5fbc41946e
53 changed files with 227 additions and 332 deletions
|
@ -116,7 +116,7 @@ public class CoreDisputesService {
|
|||
byte[] payoutTxSerialized = null;
|
||||
String payoutTxHashAsString = null;
|
||||
|
||||
PubKeyRing arbitratorPubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
PubKeyRing arbitratorPubKeyRing = trade.getArbitrator().getPubKeyRing();
|
||||
checkNotNull(arbitratorPubKeyRing, "arbitratorPubKeyRing must not be null");
|
||||
byte[] depositTxSerialized = null; // depositTx.bitcoinSerialize(); TODO (woodser)
|
||||
String depositTxHashAsString = null; // depositTx.getHashAsString(); TODO (woodser)
|
||||
|
|
|
@ -42,14 +42,14 @@ public class TradeInfo implements Payload {
|
|||
// view and interact with trades.
|
||||
|
||||
private static final Function<Trade, String> toPeerNodeAddress = (trade) ->
|
||||
trade.getTradingPeerNodeAddress() == null
|
||||
trade.getTradingPeer() == null || trade.getTradingPeer().getNodeAddress() == null
|
||||
? ""
|
||||
: trade.getTradingPeerNodeAddress().getFullAddress();
|
||||
: trade.getTradingPeer().getNodeAddress().getFullAddress();
|
||||
|
||||
private static final Function<Trade, String> toArbitratorNodeAddress = (trade) ->
|
||||
trade.getArbitratorNodeAddress() == null
|
||||
trade.getArbitrator() == null || trade.getArbitrator().getNodeAddress() == null
|
||||
? ""
|
||||
: trade.getArbitratorNodeAddress().getFullAddress();
|
||||
: trade.getArbitrator().getNodeAddress().getFullAddress();
|
||||
|
||||
private static final Function<Trade, String> toRoundedVolume = (trade) ->
|
||||
trade.getVolume() == null
|
||||
|
|
|
@ -139,7 +139,7 @@ public class Balances {
|
|||
if (trade.getContract() == null) continue;
|
||||
Long reservedAmt;
|
||||
OfferPayload offerPayload = trade.getContract().getOfferPayload();
|
||||
if (trade.getArbitratorNodeAddress().equals(P2PService.getMyNodeAddress())) { // TODO (woodser): this only works if node address does not change
|
||||
if (trade.getArbitrator().getNodeAddress().equals(P2PService.getMyNodeAddress())) { // TODO (woodser): this only works if node address does not change
|
||||
reservedAmt = offerPayload.getAmount() + offerPayload.getBuyerSecurityDeposit() + offerPayload.getSellerSecurityDeposit(); // arbitrator reserved balance is sum of amounts sent to multisig
|
||||
} else {
|
||||
reservedAmt = trade.getContract().isMyRoleBuyer(tradeManager.getKeyRing().getPubKeyRing()) ? offerPayload.getBuyerSecurityDeposit() : offerPayload.getAmount() + offerPayload.getSellerSecurityDeposit();
|
||||
|
|
|
@ -68,9 +68,9 @@ public class ArbitratorTrade extends Trade {
|
|||
xmrWalletService,
|
||||
processModel,
|
||||
uid,
|
||||
proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null,
|
||||
proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null,
|
||||
proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null),
|
||||
proto.getProcessModel().getMaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getMaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null),
|
||||
proto,
|
||||
coreProtoResolver);
|
||||
}
|
||||
|
|
|
@ -92,17 +92,13 @@ public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade {
|
|||
xmrWalletService,
|
||||
processModel,
|
||||
uid,
|
||||
proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null,
|
||||
proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null,
|
||||
proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null);
|
||||
proto.getProcessModel().getMaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getMaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null);
|
||||
|
||||
trade.setAmountAsLong(proto.getAmountAsLong());
|
||||
trade.setPrice(proto.getPrice());
|
||||
|
||||
trade.setMakerNodeAddress(proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null);
|
||||
trade.setTakerNodeAddress(proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null);
|
||||
trade.setArbitratorNodeAddress(proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null);
|
||||
|
||||
return fromProto(trade,
|
||||
proto,
|
||||
coreProtoResolver);
|
||||
|
|
|
@ -93,9 +93,9 @@ public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade {
|
|||
xmrWalletService,
|
||||
processModel,
|
||||
uid,
|
||||
proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null,
|
||||
proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null,
|
||||
proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null),
|
||||
proto.getProcessModel().getMaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getMaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null),
|
||||
proto,
|
||||
coreProtoResolver);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.monetary.Volume;
|
|||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OpenOffer;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.protocol.TradingPeer;
|
||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
import bisq.core.user.Preferences;
|
||||
|
||||
|
@ -191,9 +192,10 @@ public class ClosedTradableManager implements PersistedDataHost {
|
|||
if (isOpenOffer(tradable)) {
|
||||
return 0;
|
||||
}
|
||||
NodeAddress addressInTrade = castToTradeModel(tradable).getTradingPeerNodeAddress();
|
||||
NodeAddress addressInTrade = castToTradeModel(tradable).getTradingPeer().getNodeAddress();
|
||||
return (int) getTradeModelStream()
|
||||
.map(Trade::getTradingPeerNodeAddress)
|
||||
.map(Trade::getTradingPeer)
|
||||
.map(TradingPeer::getNodeAddress)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(address -> address.equals(addressInTrade))
|
||||
.count();
|
||||
|
|
|
@ -93,9 +93,9 @@ public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade
|
|||
xmrWalletService,
|
||||
processModel,
|
||||
uid,
|
||||
proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null,
|
||||
proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null,
|
||||
proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null);
|
||||
proto.getProcessModel().getMaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getMaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null);
|
||||
|
||||
trade.setAmountAsLong(proto.getAmountAsLong());
|
||||
trade.setPrice(proto.getPrice());
|
||||
|
|
|
@ -93,9 +93,9 @@ public final class SellerAsTakerTrade extends SellerTrade implements TakerTrade
|
|||
xmrWalletService,
|
||||
processModel,
|
||||
uid,
|
||||
proto.hasMakerNodeAddress() ? NodeAddress.fromProto(proto.getMakerNodeAddress()) : null,
|
||||
proto.hasTakerNodeAddress() ? NodeAddress.fromProto(proto.getTakerNodeAddress()) : null,
|
||||
proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null),
|
||||
proto.getProcessModel().getMaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getMaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null,
|
||||
proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null),
|
||||
proto,
|
||||
coreProtoResolver);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package bisq.core.trade;
|
|||
import bisq.core.monetary.Price;
|
||||
import bisq.core.monetary.Volume;
|
||||
import bisq.core.offer.Offer;
|
||||
|
||||
import bisq.core.trade.protocol.TradingPeer;
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
|
||||
import bisq.common.proto.persistable.PersistablePayload;
|
||||
|
@ -76,6 +76,6 @@ public interface Tradable extends PersistablePayload {
|
|||
}
|
||||
|
||||
default Optional<NodeAddress> getOptionalTradingPeerNodeAddress() {
|
||||
return asTradeModel().map(Trade::getTradingPeerNodeAddress);
|
||||
return asTradeModel().map(Trade::getTradingPeer).map(TradingPeer::getNodeAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import bisq.network.p2p.NodeAddress;
|
|||
import bisq.network.p2p.P2PService;
|
||||
import bisq.common.UserThread;
|
||||
import bisq.common.crypto.Encryption;
|
||||
import bisq.common.crypto.PubKeyRing;
|
||||
import bisq.common.proto.ProtoUtil;
|
||||
import bisq.common.taskrunner.Model;
|
||||
import bisq.common.util.Utilities;
|
||||
|
@ -337,18 +336,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
@Setter
|
||||
private byte[] contractHash;
|
||||
@Nullable
|
||||
@Getter
|
||||
@Setter
|
||||
private NodeAddress arbitratorNodeAddress;
|
||||
@Nullable
|
||||
@Getter
|
||||
@Setter
|
||||
private PubKeyRing arbitratorPubKeyRing;
|
||||
@Nullable
|
||||
@Getter
|
||||
@Setter
|
||||
private String takerPaymentAccountId;
|
||||
@Nullable
|
||||
private String errorMessage;
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -402,14 +389,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
@Getter
|
||||
@Setter
|
||||
private byte[] delayedPayoutTxBytes;
|
||||
@Nullable
|
||||
@Getter
|
||||
@Setter
|
||||
private NodeAddress refundAgentNodeAddress;
|
||||
@Nullable
|
||||
@Getter
|
||||
@Setter
|
||||
private PubKeyRing refundAgentPubKeyRing;
|
||||
@Getter
|
||||
@Nullable
|
||||
private RefundResultState refundResultState = RefundResultState.UNDEFINED_REFUND_RESULT;
|
||||
|
@ -436,23 +415,9 @@ public abstract class Trade implements Tradable, Model {
|
|||
|
||||
// Added in XMR integration
|
||||
private transient List<TradeListener> tradeListeners; // notified on fully validated trade messages
|
||||
@Getter
|
||||
@Setter
|
||||
private NodeAddress makerNodeAddress;
|
||||
@Getter
|
||||
@Setter
|
||||
private NodeAddress takerNodeAddress;
|
||||
@Getter
|
||||
@Setter
|
||||
private PubKeyRing makerPubKeyRing;
|
||||
@Getter
|
||||
@Setter
|
||||
private PubKeyRing takerPubKeyRing;
|
||||
transient MoneroWalletListener depositTxListener;
|
||||
transient Boolean makerDepositLocked; // null when unknown, true while locked, false when unlocked
|
||||
transient Boolean takerDepositLocked;
|
||||
transient private MoneroTx makerDepositTx;
|
||||
transient private MoneroTx takerDepositTx;
|
||||
private Long startTime; // cache
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -484,9 +449,9 @@ public abstract class Trade implements Tradable, Model {
|
|||
this.takeOfferDate = new Date().getTime();
|
||||
this.tradeListeners = new ArrayList<TradeListener>();
|
||||
|
||||
this.makerNodeAddress = makerNodeAddress;
|
||||
this.takerNodeAddress = takerNodeAddress;
|
||||
this.arbitratorNodeAddress = arbitratorNodeAddress;
|
||||
getMaker().setNodeAddress(makerNodeAddress);
|
||||
getTaker().setNodeAddress(takerNodeAddress);
|
||||
getArbitrator().setNodeAddress(arbitratorNodeAddress);
|
||||
|
||||
setAmount(tradeAmount);
|
||||
}
|
||||
|
@ -578,22 +543,13 @@ public abstract class Trade implements Tradable, Model {
|
|||
Optional.ofNullable(contract).ifPresent(e -> builder.setContract(contract.toProtoMessage()));
|
||||
Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson);
|
||||
Optional.ofNullable(contractHash).ifPresent(e -> builder.setContractHash(ByteString.copyFrom(contractHash)));
|
||||
Optional.ofNullable(arbitratorNodeAddress).ifPresent(e -> builder.setArbitratorNodeAddress(arbitratorNodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(refundAgentNodeAddress).ifPresent(e -> builder.setRefundAgentNodeAddress(refundAgentNodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(takerPaymentAccountId).ifPresent(builder::setTakerPaymentAccountId);
|
||||
Optional.ofNullable(errorMessage).ifPresent(builder::setErrorMessage);
|
||||
Optional.ofNullable(arbitratorPubKeyRing).ifPresent(e -> builder.setArbitratorPubKeyRing(arbitratorPubKeyRing.toProtoMessage()));
|
||||
Optional.ofNullable(refundAgentPubKeyRing).ifPresent(e -> builder.setRefundAgentPubKeyRing(refundAgentPubKeyRing.toProtoMessage()));
|
||||
Optional.ofNullable(counterCurrencyTxId).ifPresent(e -> builder.setCounterCurrencyTxId(counterCurrencyTxId));
|
||||
Optional.ofNullable(mediationResultState).ifPresent(e -> builder.setMediationResultState(MediationResultState.toProtoMessage(mediationResultState)));
|
||||
Optional.ofNullable(refundResultState).ifPresent(e -> builder.setRefundResultState(RefundResultState.toProtoMessage(refundResultState)));
|
||||
Optional.ofNullable(delayedPayoutTxBytes).ifPresent(e -> builder.setDelayedPayoutTxBytes(ByteString.copyFrom(delayedPayoutTxBytes)));
|
||||
Optional.ofNullable(counterCurrencyExtraData).ifPresent(e -> builder.setCounterCurrencyExtraData(counterCurrencyExtraData));
|
||||
Optional.ofNullable(assetTxProofResult).ifPresent(e -> builder.setAssetTxProofResult(assetTxProofResult.name()));
|
||||
Optional.ofNullable(makerNodeAddress).ifPresent(e -> builder.setMakerNodeAddress(makerNodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(makerPubKeyRing).ifPresent(e -> builder.setMakerPubKeyRing(makerPubKeyRing.toProtoMessage()));
|
||||
Optional.ofNullable(takerNodeAddress).ifPresent(e -> builder.setTakerNodeAddress(takerNodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(takerPubKeyRing).ifPresent(e -> builder.setTakerPubKeyRing(takerPubKeyRing.toProtoMessage()));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -607,12 +563,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
trade.setContract(proto.hasContract() ? Contract.fromProto(proto.getContract(), coreProtoResolver) : null);
|
||||
trade.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson()));
|
||||
trade.setContractHash(ProtoUtil.byteArrayOrNullFromProto(proto.getContractHash()));
|
||||
trade.setArbitratorNodeAddress(proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null);
|
||||
trade.setRefundAgentNodeAddress(proto.hasRefundAgentNodeAddress() ? NodeAddress.fromProto(proto.getRefundAgentNodeAddress()) : null);
|
||||
trade.setTakerPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getTakerPaymentAccountId()));
|
||||
trade.setErrorMessage(ProtoUtil.stringOrNullFromProto(proto.getErrorMessage()));
|
||||
trade.setArbitratorPubKeyRing(proto.hasArbitratorPubKeyRing() ? PubKeyRing.fromProto(proto.getArbitratorPubKeyRing()) : null);
|
||||
trade.setRefundAgentPubKeyRing(proto.hasRefundAgentPubKeyRing() ? PubKeyRing.fromProto(proto.getRefundAgentPubKeyRing()) : null);
|
||||
trade.setCounterCurrencyTxId(proto.getCounterCurrencyTxId().isEmpty() ? null : proto.getCounterCurrencyTxId());
|
||||
trade.setMediationResultState(MediationResultState.fromProto(proto.getMediationResultState()));
|
||||
trade.setRefundResultState(RefundResultState.fromProto(proto.getRefundResultState()));
|
||||
|
@ -626,10 +577,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
persistedAssetTxProofResult = null;
|
||||
}
|
||||
trade.setAssetTxProofResult(persistedAssetTxProofResult);
|
||||
trade.setMakerNodeAddress(NodeAddress.fromProto(proto.getMakerNodeAddress()));
|
||||
trade.setMakerPubKeyRing(proto.hasMakerPubKeyRing() ? PubKeyRing.fromProto(proto.getMakerPubKeyRing()) : null);
|
||||
trade.setTakerNodeAddress(NodeAddress.fromProto(proto.getTakerNodeAddress()));
|
||||
trade.setTakerPubKeyRing(proto.hasTakerPubKeyRing() ? PubKeyRing.fromProto(proto.getTakerPubKeyRing()) : null);
|
||||
|
||||
trade.chatMessages.addAll(proto.getChatMessageList().stream()
|
||||
.map(ChatMessage::fromPayloadProto)
|
||||
|
@ -639,8 +586,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
}
|
||||
|
||||
public void initialize(ProcessModelServiceProvider serviceProvider) {
|
||||
serviceProvider.getArbitratorManager().getDisputeAgentByNodeAddress(arbitratorNodeAddress).ifPresent(arbitrator -> {
|
||||
arbitratorPubKeyRing = arbitrator.getPubKeyRing();
|
||||
serviceProvider.getArbitratorManager().getDisputeAgentByNodeAddress(getArbitrator().getNodeAddress()).ifPresent(arbitrator -> {
|
||||
getArbitrator().setPubKeyRing(arbitrator.getPubKeyRing());
|
||||
});
|
||||
|
||||
isInitialized = true;
|
||||
|
@ -652,36 +599,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setMyNodeAddress() {
|
||||
if (this instanceof MakerTrade) makerNodeAddress = P2PService.getMyNodeAddress();
|
||||
else if (this instanceof TakerTrade) takerNodeAddress = P2PService.getMyNodeAddress();
|
||||
else if (this instanceof ArbitratorTrade) arbitratorNodeAddress = P2PService.getMyNodeAddress();
|
||||
else throw new RuntimeException("Must be maker, taker, or arbitrator to set own address");
|
||||
}
|
||||
|
||||
public void setTradingPeerNodeAddress(NodeAddress peerAddress) {
|
||||
if (this instanceof MakerTrade) takerNodeAddress = peerAddress;
|
||||
else if (this instanceof TakerTrade) makerNodeAddress = peerAddress;
|
||||
else throw new RuntimeException("Must be maker or taker to set peer address");
|
||||
}
|
||||
|
||||
public NodeAddress getTradingPeerNodeAddress() {
|
||||
if (this instanceof MakerTrade) return takerNodeAddress;
|
||||
else if (this instanceof TakerTrade) return makerNodeAddress;
|
||||
else if (this instanceof ArbitratorTrade) return null;
|
||||
else throw new RuntimeException("Unknown trade type: " + this.getClass().getName());
|
||||
}
|
||||
|
||||
public void setTradingPeerPubKeyRing(PubKeyRing peerPubKeyRing) {
|
||||
if (this instanceof MakerTrade) takerPubKeyRing = peerPubKeyRing;
|
||||
else if (this instanceof TakerTrade) makerPubKeyRing = peerPubKeyRing;
|
||||
else throw new RuntimeException("Must be maker or taker to set peer address");
|
||||
}
|
||||
|
||||
public PubKeyRing getTradingPeerPubKeyRing() {
|
||||
if (this instanceof MakerTrade) return takerPubKeyRing;
|
||||
else if (this instanceof TakerTrade) return makerPubKeyRing;
|
||||
else if (this instanceof ArbitratorTrade) return null;
|
||||
else throw new RuntimeException("Unknown trade type: " + this.getClass().getName());
|
||||
getSelf().setNodeAddress(P2PService.getMyNodeAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -696,9 +614,9 @@ public abstract class Trade implements Tradable, Model {
|
|||
getOffer().getOfferPayload(),
|
||||
checkNotNull(getAmount()).value,
|
||||
getPrice().getValue(),
|
||||
isBuyerMakerAndSellerTaker ? getMakerNodeAddress() : getTakerNodeAddress(), // buyer node address // TODO (woodser): use maker and taker node address instead of buyer and seller node address for consistency
|
||||
isBuyerMakerAndSellerTaker ? getTakerNodeAddress() : getMakerNodeAddress(), // seller node address
|
||||
getArbitratorNodeAddress(),
|
||||
(isBuyerMakerAndSellerTaker ? getMaker() : getTaker()).getNodeAddress(), // buyer node address // TODO (woodser): use maker and taker node address instead of buyer and seller node address for consistency
|
||||
(isBuyerMakerAndSellerTaker ? getTaker() : getMaker()).getNodeAddress(), // seller node address
|
||||
getArbitrator().getNodeAddress(),
|
||||
isBuyerMakerAndSellerTaker,
|
||||
this instanceof MakerTrade ? processModel.getAccountId() : getMaker().getAccountId(), // maker account id
|
||||
this instanceof TakerTrade ? processModel.getAccountId() : getTaker().getAccountId(), // taker account id
|
||||
|
@ -706,8 +624,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
checkNotNull(this instanceof TakerTrade ? processModel.getPaymentAccountPayload(this).getPaymentMethodId() : getTaker().getPaymentMethodId()), // taker payment method id
|
||||
this instanceof MakerTrade ? processModel.getPaymentAccountPayload(this).getHash() : getMaker().getPaymentAccountPayloadHash(), // maker payment account payload hash
|
||||
this instanceof TakerTrade ? processModel.getPaymentAccountPayload(this).getHash() : getTaker().getPaymentAccountPayloadHash(), // maker payment account payload hash
|
||||
getMakerPubKeyRing(),
|
||||
getTakerPubKeyRing(),
|
||||
getMaker().getPubKeyRing(),
|
||||
getTaker().getPubKeyRing(),
|
||||
this instanceof MakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getMaker().getPayoutAddressString(), // maker payout address
|
||||
this instanceof TakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getTaker().getPayoutAddressString(), // taker payout address
|
||||
getLockTime(),
|
||||
|
@ -891,8 +809,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
if (txs.size() == 2) {
|
||||
setStatePublished();
|
||||
boolean makerFirst = txs.get(0).getHash().equals(processModel.getMaker().getDepositTxHash());
|
||||
makerDepositTx = makerFirst ? txs.get(0) : txs.get(1);
|
||||
takerDepositTx = makerFirst ? txs.get(1) : txs.get(0);
|
||||
getMaker().setDepositTx(makerFirst ? txs.get(0) : txs.get(1));
|
||||
getTaker().setDepositTx(makerFirst ? txs.get(1) : txs.get(0));
|
||||
|
||||
// check if deposit txs unlocked
|
||||
if (txs.get(0).isConfirmed() && txs.get(1).isConfirmed()) {
|
||||
|
@ -930,8 +848,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
|
||||
// update deposit txs
|
||||
boolean makerFirst = txs.get(0).getHash().equals(processModel.getMaker().getDepositTxHash());
|
||||
makerDepositTx = makerFirst ? txs.get(0) : txs.get(1);
|
||||
takerDepositTx = makerFirst ? txs.get(1) : txs.get(0);
|
||||
getMaker().setDepositTx(makerFirst ? txs.get(0) : txs.get(1));
|
||||
getTaker().setDepositTx(makerFirst ? txs.get(1) : txs.get(0));
|
||||
|
||||
// check if deposit txs confirmed and compute unlock height
|
||||
if (txs.size() == 2 && txs.get(0).isConfirmed() && txs.get(1).isConfirmed() && unlockHeight == null) {
|
||||
|
@ -958,8 +876,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
public MoneroTx getTakerDepositTx() {
|
||||
String depositTxHash = getProcessModel().getTaker().getDepositTxHash();
|
||||
try {
|
||||
if (takerDepositTx == null) takerDepositTx = depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash);
|
||||
return takerDepositTx;
|
||||
if (getTaker().getDepositTx() == null) getTaker().setDepositTx(depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash));
|
||||
return getTaker().getDepositTx();
|
||||
} catch (MoneroError e) {
|
||||
log.error("Wallet is missing taker deposit tx " + depositTxHash);
|
||||
return null;
|
||||
|
@ -970,8 +888,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
public MoneroTx getMakerDepositTx() {
|
||||
String depositTxHash = getProcessModel().getMaker().getDepositTxHash();
|
||||
try {
|
||||
if (makerDepositTx == null) makerDepositTx = depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash);
|
||||
return makerDepositTx;
|
||||
if (getMaker().getDepositTx() == null) getMaker().setDepositTx(depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash));
|
||||
return getMaker().getDepositTx();
|
||||
} catch (MoneroError e) {
|
||||
log.error("Wallet is missing maker deposit tx " + depositTxHash);
|
||||
return null;
|
||||
|
@ -1171,6 +1089,10 @@ public abstract class Trade implements Tradable, Model {
|
|||
throw new RuntimeException("Trade is not maker, taker, or arbitrator");
|
||||
}
|
||||
|
||||
public TradingPeer getArbitrator() {
|
||||
return processModel.getArbitrator();
|
||||
}
|
||||
|
||||
public TradingPeer getMaker() {
|
||||
return processModel.getMaker();
|
||||
}
|
||||
|
@ -1208,10 +1130,10 @@ public abstract class Trade implements Tradable, Model {
|
|||
* @return the trade peer
|
||||
*/
|
||||
public TradingPeer getTradingPeer(NodeAddress address) {
|
||||
if (address.equals(getMakerNodeAddress())) return processModel.getMaker();
|
||||
if (address.equals(getTakerNodeAddress())) return processModel.getTaker();
|
||||
if (address.equals(getArbitratorNodeAddress())) return processModel.getArbitrator();
|
||||
throw new RuntimeException("No protocol participant has node address: " + address);
|
||||
if (address.equals(getMaker().getNodeAddress())) return processModel.getMaker();
|
||||
if (address.equals(getTaker().getNodeAddress())) return processModel.getTaker();
|
||||
if (address.equals(getArbitrator().getNodeAddress())) return processModel.getArbitrator();
|
||||
throw new RuntimeException("No trade participant with the given address. Their address might have changed: " + address);
|
||||
}
|
||||
|
||||
public Date getTakeOfferDate() {
|
||||
|
@ -1505,7 +1427,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
",\n contract=" + contract +
|
||||
",\n contractAsJson='" + contractAsJson + '\'' +
|
||||
",\n contractHash=" + Utilities.bytesAsHexString(contractHash) +
|
||||
",\n takerPaymentAccountId='" + takerPaymentAccountId + '\'' +
|
||||
",\n errorMessage='" + errorMessage + '\'' +
|
||||
",\n counterCurrencyTxId='" + counterCurrencyTxId + '\'' +
|
||||
",\n counterCurrencyExtraData='" + counterCurrencyExtraData + '\'' +
|
||||
|
@ -1519,7 +1440,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
",\n disputeStateProperty=" + disputeStateProperty +
|
||||
",\n tradePeriodStateProperty=" + tradePeriodStateProperty +
|
||||
",\n errorMessageProperty=" + errorMessageProperty +
|
||||
",\n depositTx=" + takerDepositTx +
|
||||
",\n delayedPayoutTx=" + delayedPayoutTx +
|
||||
",\n payoutTx=" + payoutTx +
|
||||
",\n tradeAmount=" + tradeAmount +
|
||||
|
@ -1529,16 +1449,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
",\n mediationResultStateProperty=" + mediationResultStateProperty +
|
||||
",\n lockTime=" + lockTime +
|
||||
",\n delayedPayoutTxBytes=" + Utilities.bytesAsHexString(delayedPayoutTxBytes) +
|
||||
",\n refundAgentNodeAddress=" + refundAgentNodeAddress +
|
||||
",\n refundAgentPubKeyRing=" + refundAgentPubKeyRing +
|
||||
",\n refundResultState=" + refundResultState +
|
||||
",\n refundResultStateProperty=" + refundResultStateProperty +
|
||||
",\n makerNodeAddress=" + makerNodeAddress +
|
||||
",\n makerPubKeyRing=" + makerPubKeyRing +
|
||||
",\n takerNodeAddress=" + takerNodeAddress +
|
||||
",\n takerPubKeyRing=" + takerPubKeyRing +
|
||||
",\n arbitratorNodeAddress=" + arbitratorNodeAddress +
|
||||
",\n arbitratorPubKeyRing=" + arbitratorPubKeyRing +
|
||||
"\n}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -538,11 +538,11 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
request.getTakerNodeAddress(),
|
||||
request.getArbitratorNodeAddress());
|
||||
|
||||
//System.out.println("TradeManager trade.setTradingPeerNodeAddress(): " + sender);
|
||||
//trade.setTradingPeerNodeAddress(sender);
|
||||
//System.out.println("TradeManager trade.getTradingPeer().setNodeAddress(): " + sender);
|
||||
//trade.getTradingPeer().setNodeAddress(sender);
|
||||
// TODO (woodser): what if maker's address changes while offer open, or taker's address changes after multisig deposit available? need to verify and update. see OpenOfferManager.maybeUpdatePersistedOffers()
|
||||
trade.setArbitratorPubKeyRing(arbitrator.getPubKeyRing());
|
||||
trade.setMakerPubKeyRing(trade.getOffer().getPubKeyRing());
|
||||
trade.getArbitrator().setPubKeyRing(arbitrator.getPubKeyRing());
|
||||
trade.getMaker().setPubKeyRing(trade.getOffer().getPubKeyRing());
|
||||
initTradeAndProtocol(trade, getTradeProtocol(trade));
|
||||
trade.getSelf().setReserveTxHash(openOffer.getReserveTxHash()); // TODO (woodser): initialize in initTradeAndProtocol?
|
||||
trade.getSelf().setReserveTxHex(openOffer.getReserveTxHex());
|
||||
|
@ -764,8 +764,8 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
trade.getProcessModel().setMakerSignature(model.getMakerSignature());
|
||||
trade.getProcessModel().setUseSavingsWallet(useSavingsWallet);
|
||||
trade.getProcessModel().setFundsNeededForTradeAsLong(fundsNeededForTrade.value);
|
||||
trade.setTakerPubKeyRing(model.getPubKeyRing());
|
||||
trade.setTakerPaymentAccountId(paymentAccountId);
|
||||
trade.getTaker().setPubKeyRing(model.getPubKeyRing());
|
||||
trade.getTaker().setPaymentAccountId(paymentAccountId);
|
||||
|
||||
TradeProtocol tradeProtocol = TradeProtocolFactory.getNewTradeProtocol(trade);
|
||||
TradeProtocol prev = tradeProtocolByTradeId.put(trade.getUid(), tradeProtocol);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
|||
super(trade);
|
||||
Offer offer = checkNotNull(trade.getOffer());
|
||||
trade.getTradingPeer().setPubKeyRing(offer.getPubKeyRing());
|
||||
trade.setMakerPubKeyRing(offer.getPubKeyRing());
|
||||
trade.getMaker().setPubKeyRing(offer.getPubKeyRing());
|
||||
|
||||
// TODO (woodser): setup deposit and payout listeners on construction for startup like before rebase?
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
|||
this.errorMessageHandler = errorMessageHandler;
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(TakerEvent.TAKE_OFFER)
|
||||
.from(trade.getTradingPeerNodeAddress()))
|
||||
.from(trade.getTradingPeer().getNodeAddress()))
|
||||
.setup(tasks(
|
||||
ApplyFilter.class,
|
||||
TakerReserveTradeFunds.class,
|
||||
|
|
|
@ -285,7 +285,7 @@ public class ProcessModel implements Model, PersistablePayload {
|
|||
if (trade instanceof MakerTrade)
|
||||
paymentAccount = getUser().getPaymentAccount(offer.getMakerPaymentAccountId());
|
||||
else
|
||||
paymentAccount = getUser().getPaymentAccount(trade.getTakerPaymentAccountId());
|
||||
paymentAccount = getUser().getPaymentAccount(trade.getTaker().getPaymentAccountId());
|
||||
return paymentAccount != null ? paymentAccount.getPaymentAccountPayload() : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
super(trade);
|
||||
Offer offer = checkNotNull(trade.getOffer());
|
||||
trade.getTradingPeer().setPubKeyRing(offer.getPubKeyRing());
|
||||
trade.setMakerPubKeyRing(offer.getPubKeyRing());
|
||||
trade.getMaker().setPubKeyRing(offer.getPubKeyRing());
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
this.errorMessageHandler = errorMessageHandler;
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(TakerEvent.TAKE_OFFER)
|
||||
.from(trade.getTradingPeerNodeAddress()))
|
||||
.from(trade.getTradingPeer().getNodeAddress()))
|
||||
.setup(tasks(
|
||||
ApplyFilter.class,
|
||||
TakerReserveTradeFunds.class,
|
||||
|
|
|
@ -453,8 +453,6 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
|
||||
protected void sendAckMessage(NodeAddress peer, TradeMessage message, boolean result, @Nullable String errorMessage) {
|
||||
|
||||
// TODO (woodser): remove trade.getTradingPeerNodeAddress() and processModel.getTempTradingPeerNodeAddress() if everything should be maker, taker, or arbitrator
|
||||
|
||||
// get peer's pub key ring
|
||||
PubKeyRing peersPubKeyRing = getPeersPubKeyRing(peer);
|
||||
if (peersPubKeyRing == null) {
|
||||
|
@ -546,9 +544,9 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
|
||||
private PubKeyRing getPeersPubKeyRing(NodeAddress peer) {
|
||||
trade.setMyNodeAddress(); // TODO: this is a hack to update my node address before verifying the message
|
||||
if (peer.equals(trade.getArbitratorNodeAddress())) return trade.getArbitratorPubKeyRing();
|
||||
else if (peer.equals(trade.getMakerNodeAddress())) return trade.getMakerPubKeyRing();
|
||||
else if (peer.equals(trade.getTakerNodeAddress())) return trade.getTakerPubKeyRing();
|
||||
if (peer.equals(trade.getArbitrator().getNodeAddress())) return trade.getArbitrator().getPubKeyRing();
|
||||
else if (peer.equals(trade.getMaker().getNodeAddress())) return trade.getMaker().getPubKeyRing();
|
||||
else if (peer.equals(trade.getTaker().getNodeAddress())) return trade.getTaker().getPubKeyRing();
|
||||
else {
|
||||
log.warn("Cannot get peer's pub key ring because peer is not maker, taker, or arbitrator. Their address might have changed: " + peer);
|
||||
return null;
|
||||
|
@ -565,7 +563,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
if (this instanceof ArbitratorProtocol) {
|
||||
|
||||
// valid if traders unknown
|
||||
if (trade.getMaker().getPubKeyRing() == null || trade.getTakerPubKeyRing() == null) return true;
|
||||
if (trade.getMaker().getPubKeyRing() == null || trade.getTaker().getPubKeyRing() == null) return true;
|
||||
|
||||
// valid if maker pub key
|
||||
if (message.getSignaturePubKey().equals(trade.getMaker().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
|
@ -575,10 +573,10 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
} else {
|
||||
|
||||
// valid if arbitrator or peer unknown
|
||||
if (trade.getArbitratorPubKeyRing() == null || (trade.getTradingPeer() == null || trade.getTradingPeer().getPubKeyRing() == null)) return true;
|
||||
if (trade.getArbitrator().getPubKeyRing() == null || (trade.getTradingPeer() == null || trade.getTradingPeer().getPubKeyRing() == null)) return true;
|
||||
|
||||
// valid if arbitrator's pub key ring
|
||||
if (message.getSignaturePubKey().equals(trade.getArbitratorPubKeyRing().getSignaturePubKey())) return true;
|
||||
if (message.getSignaturePubKey().equals(trade.getArbitrator().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
|
||||
// valid if peer's pub key ring
|
||||
if (message.getSignaturePubKey().equals(trade.getTradingPeer().getPubKeyRing().getSignaturePubKey())) return true;
|
||||
|
|
|
@ -20,7 +20,7 @@ package bisq.core.trade.protocol;
|
|||
import bisq.core.btc.model.RawTransactionInput;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.proto.CoreProtoResolver;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
import bisq.common.crypto.PubKeyRing;
|
||||
import bisq.common.proto.ProtoUtil;
|
||||
import bisq.common.proto.persistable.PersistablePayload;
|
||||
|
@ -35,6 +35,7 @@ import java.util.stream.Collectors;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.daemon.model.MoneroTx;
|
||||
import monero.wallet.model.MoneroTxWallet;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -53,9 +54,14 @@ public final class TradingPeer implements PersistablePayload {
|
|||
@Setter
|
||||
@Nullable
|
||||
transient private byte[] preparedDepositTx;
|
||||
transient private MoneroTx depositTx;
|
||||
|
||||
// Persistable mutable
|
||||
@Nullable
|
||||
private NodeAddress nodeAddress;
|
||||
@Nullable
|
||||
private PubKeyRing pubKeyRing;
|
||||
@Nullable
|
||||
private String accountId;
|
||||
@Nullable
|
||||
private String paymentAccountId;
|
||||
|
@ -78,8 +84,6 @@ public final class TradingPeer implements PersistablePayload {
|
|||
@Nullable
|
||||
private byte[] signature;
|
||||
@Nullable
|
||||
private PubKeyRing pubKeyRing;
|
||||
@Nullable
|
||||
private byte[] multiSigPubKey;
|
||||
@Nullable
|
||||
private List<RawTransactionInput> rawTransactionInputs;
|
||||
|
@ -134,6 +138,8 @@ public final class TradingPeer implements PersistablePayload {
|
|||
final protobuf.TradingPeer.Builder builder = protobuf.TradingPeer.newBuilder()
|
||||
.setChangeOutputValue(changeOutputValue)
|
||||
.addAllReserveTxKeyImages(reserveTxKeyImages);
|
||||
Optional.ofNullable(nodeAddress).ifPresent(e -> builder.setNodeAddress(nodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(pubKeyRing.toProtoMessage()));
|
||||
Optional.ofNullable(accountId).ifPresent(builder::setAccountId);
|
||||
Optional.ofNullable(paymentAccountId).ifPresent(builder::setPaymentAccountId);
|
||||
Optional.ofNullable(paymentMethodId).ifPresent(builder::setPaymentMethodId);
|
||||
|
@ -173,6 +179,8 @@ public final class TradingPeer implements PersistablePayload {
|
|||
return null;
|
||||
} else {
|
||||
TradingPeer tradingPeer = new TradingPeer();
|
||||
tradingPeer.setNodeAddress(proto.hasNodeAddress() ? NodeAddress.fromProto(proto.getNodeAddress()) : null);
|
||||
tradingPeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null);
|
||||
tradingPeer.setChangeOutputValue(proto.getChangeOutputValue());
|
||||
tradingPeer.setAccountId(ProtoUtil.stringOrNullFromProto(proto.getAccountId()));
|
||||
tradingPeer.setPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getPaymentAccountId()));
|
||||
|
|
|
@ -56,14 +56,9 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
String signature = request.getContractSignature();
|
||||
|
||||
// get peer info
|
||||
// TODO (woodser): make these utilities / refactor model
|
||||
// TODO (woodser): verify request
|
||||
PubKeyRing peerPubKeyRing;
|
||||
TradingPeer peer = trade.getTradingPeer(request.getSenderNodeAddress());
|
||||
if (peer == processModel.getArbitrator()) peerPubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
else if (peer == processModel.getMaker()) peerPubKeyRing = trade.getMakerPubKeyRing();
|
||||
else if (peer == processModel.getTaker()) peerPubKeyRing = trade.getTakerPubKeyRing();
|
||||
else throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator");
|
||||
if (peer == null) throw new RuntimeException(request.getClass().getSimpleName() + " is not from maker, taker, or arbitrator");
|
||||
PubKeyRing peerPubKeyRing = peer.getPubKeyRing();
|
||||
|
||||
// verify signature
|
||||
if (!Sig.verify(peerPubKeyRing.getSignaturePubKey(), contractAsJson, signature)) throw new RuntimeException("Peer's contract signature is invalid");
|
||||
|
@ -73,7 +68,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
|
||||
// collect expected values of deposit tx
|
||||
Offer offer = trade.getOffer();
|
||||
boolean isFromTaker = request.getSenderNodeAddress().equals(trade.getTakerNodeAddress());
|
||||
boolean isFromTaker = request.getSenderNodeAddress().equals(trade.getTaker().getNodeAddress());
|
||||
boolean isFromBuyer = isFromTaker ? offer.getDirection() == OfferDirection.SELL : offer.getDirection() == OfferDirection.BUY;
|
||||
BigInteger depositAmount = ParsingUtils.coinToAtomicUnits(isFromBuyer ? offer.getBuyerSecurityDeposit() : offer.getAmount().add(offer.getSellerSecurityDeposit()));
|
||||
String depositAddress = processModel.getMultisigAddress();
|
||||
|
@ -121,8 +116,8 @@ public class ArbitratorProcessDepositRequest extends TradeTask {
|
|||
new Date().getTime());
|
||||
|
||||
// send deposit response to maker and taker
|
||||
sendDepositResponse(trade.getMakerNodeAddress(), trade.getMakerPubKeyRing(), response);
|
||||
sendDepositResponse(trade.getTakerNodeAddress(), trade.getTakerPubKeyRing(), response);
|
||||
sendDepositResponse(trade.getMaker().getNodeAddress(), trade.getMaker().getPubKeyRing(), response);
|
||||
sendDepositResponse(trade.getTaker().getNodeAddress(), trade.getTaker().getPubKeyRing(), response);
|
||||
} else {
|
||||
if (processModel.getMaker().getDepositTxHex() == null) log.info("Arbitrator waiting for deposit request from maker for trade " + trade.getId());
|
||||
if (processModel.getTaker().getDepositTxHex() == null) log.info("Arbitrator waiting for deposit request from taker for trade " + trade.getId());
|
||||
|
|
|
@ -59,11 +59,9 @@ public class ArbitratorProcessPaymentAccountKeyRequest extends TradeTask {
|
|||
);
|
||||
|
||||
// send response to buyer
|
||||
boolean isMakerBuyer = trade.getOffer().isBuyOffer();
|
||||
NodeAddress buyerAddress = isMakerBuyer ? trade.getMakerNodeAddress() : trade.getTakerNodeAddress(); // TODO: trade.getBuyer().getNodeAddress()
|
||||
PubKeyRing buyerPubKeyRing = isMakerBuyer ? trade.getMakerPubKeyRing() : trade.getTakerPubKeyRing();
|
||||
NodeAddress buyerAddress = trade.getBuyer().getNodeAddress();
|
||||
log.info("Arbitrator sending PaymentAccountKeyResponse to buyer={}; offerId={}", buyerAddress, trade.getId());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(buyerAddress, buyerPubKeyRing, response, new SendDirectMessageListener() {
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(buyerAddress, trade.getBuyer().getPubKeyRing(), response, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived: trading peer={}; offerId={}; uid={}", response.getClass().getSimpleName(), buyerAddress, trade.getId());
|
||||
|
|
|
@ -41,8 +41,8 @@ public class ArbitratorProcessPayoutTxPublishedMessage extends TradeTask {
|
|||
trade.verifyPayoutTx(request.getSignedPayoutTxHex(), false, true);
|
||||
|
||||
// update latest peer address
|
||||
if (request.isMaker()) trade.setMakerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
else trade.setTakerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
if (request.isMaker()) trade.getMaker().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
else trade.getTaker().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
|
||||
// TODO: publish signed witness data?
|
||||
//request.getSignedWitness()
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ArbitratorProcessReserveTx extends TradeTask {
|
|||
runInterceptHook();
|
||||
Offer offer = trade.getOffer();
|
||||
InitTradeRequest request = (InitTradeRequest) processModel.getTradeMessage();
|
||||
boolean isFromTaker = request.getSenderNodeAddress().equals(trade.getTakerNodeAddress());
|
||||
boolean isFromTaker = request.getSenderNodeAddress().equals(trade.getTaker().getNodeAddress());
|
||||
boolean isFromBuyer = isFromTaker ? offer.getDirection() == OfferDirection.SELL : offer.getDirection() == OfferDirection.BUY;
|
||||
|
||||
// TODO (woodser): if signer online, should never be called by maker
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
byte[] sig = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), processModel.getOfferId().getBytes(Charsets.UTF_8));
|
||||
|
||||
// handle request from taker
|
||||
if (request.getSenderNodeAddress().equals(trade.getTakerNodeAddress())) {
|
||||
if (request.getSenderNodeAddress().equals(trade.getTaker().getNodeAddress())) {
|
||||
|
||||
// create request to initialize trade with maker
|
||||
InitTradeRequest makerRequest = new InitTradeRequest(
|
||||
|
@ -75,9 +75,9 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
Version.getP2PMessageVersion(),
|
||||
sig,
|
||||
new Date().getTime(),
|
||||
trade.getMakerNodeAddress(),
|
||||
trade.getTakerNodeAddress(),
|
||||
trade.getArbitratorNodeAddress(),
|
||||
trade.getMaker().getNodeAddress(),
|
||||
trade.getTaker().getNodeAddress(),
|
||||
trade.getArbitrator().getNodeAddress(),
|
||||
null,
|
||||
null, // do not include taker's reserve tx
|
||||
null,
|
||||
|
@ -85,10 +85,10 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
null);
|
||||
|
||||
// send request to maker
|
||||
log.info("Send {} with offerId {} and uid {} to maker {} with pub key ring", makerRequest.getClass().getSimpleName(), makerRequest.getTradeId(), makerRequest.getUid(), trade.getMakerNodeAddress(), trade.getMakerPubKeyRing());
|
||||
log.info("Send {} with offerId {} and uid {} to maker {} with pub key ring", makerRequest.getClass().getSimpleName(), makerRequest.getTradeId(), makerRequest.getUid(), trade.getMaker().getNodeAddress(), trade.getMaker().getPubKeyRing());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
trade.getMakerNodeAddress(), // TODO (woodser): maker's address might be different from original owner address if they disconnect and reconnect, need to validate and update address when requests received
|
||||
trade.getMakerPubKeyRing(),
|
||||
trade.getMaker().getNodeAddress(), // TODO (woodser): maker's address might be different from original owner address if they disconnect and reconnect, need to validate and update address when requests received
|
||||
trade.getMaker().getPubKeyRing(),
|
||||
makerRequest,
|
||||
new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
@ -98,7 +98,7 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", makerRequest.getClass().getSimpleName(), makerRequest.getUid(), trade.getArbitratorNodeAddress(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", makerRequest.getClass().getSimpleName(), makerRequest.getUid(), trade.getArbitrator().getNodeAddress(), errorMessage);
|
||||
appendToErrorMessage("Sending message failed: message=" + makerRequest + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
}
|
||||
|
||||
// handle request from maker
|
||||
else if (request.getSenderNodeAddress().equals(trade.getMakerNodeAddress())) {
|
||||
else if (request.getSenderNodeAddress().equals(trade.getMaker().getNodeAddress())) {
|
||||
sendInitMultisigRequests();
|
||||
complete(); // TODO: wait for InitMultisigRequest arrivals?
|
||||
} else {
|
||||
|
@ -145,10 +145,10 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
null);
|
||||
|
||||
// send request to maker
|
||||
log.info("Send {} with offerId {} and uid {} to maker {}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getTradeId(), initMultisigRequest.getUid(), trade.getMakerNodeAddress());
|
||||
log.info("Send {} with offerId {} and uid {} to maker {}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getTradeId(), initMultisigRequest.getUid(), trade.getMaker().getNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
trade.getMakerNodeAddress(),
|
||||
trade.getMakerPubKeyRing(),
|
||||
trade.getMaker().getNodeAddress(),
|
||||
trade.getMaker().getPubKeyRing(),
|
||||
initMultisigRequest,
|
||||
new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
@ -157,16 +157,16 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getUid(), trade.getMakerNodeAddress(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getUid(), trade.getMaker().getNodeAddress(), errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// send request to taker
|
||||
log.info("Send {} with offerId {} and uid {} to taker {}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getTradeId(), initMultisigRequest.getUid(), trade.getTakerNodeAddress());
|
||||
log.info("Send {} with offerId {} and uid {} to taker {}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getTradeId(), initMultisigRequest.getUid(), trade.getTaker().getNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
trade.getTakerNodeAddress(),
|
||||
trade.getTakerPubKeyRing(),
|
||||
trade.getTaker().getNodeAddress(),
|
||||
trade.getTaker().getPubKeyRing(),
|
||||
initMultisigRequest,
|
||||
new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
@ -175,7 +175,7 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask {
|
|||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getUid(), trade.getTakerNodeAddress(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", initMultisigRequest.getClass().getSimpleName(), initMultisigRequest.getUid(), trade.getTaker().getNodeAddress(), errorMessage);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -37,8 +37,8 @@ public class BuyerProcessPaymentAccountKeyResponse extends TradeTask {
|
|||
runInterceptHook();
|
||||
|
||||
// update peer node address if not from arbitrator
|
||||
if (!processModel.getTempTradingPeerNodeAddress().equals(trade.getArbitratorNodeAddress())) {
|
||||
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
if (!processModel.getTempTradingPeerNodeAddress().equals(trade.getArbitrator().getNodeAddress())) {
|
||||
trade.getTradingPeer().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
}
|
||||
|
||||
// decrypt peer's payment account payload
|
||||
|
|
|
@ -53,7 +53,7 @@ public class BuyerProcessPaymentReceivedMessage extends TradeTask {
|
|||
checkArgument(message.getPayoutTxHex() != null);
|
||||
|
||||
// update to the latest peer address of our peer if the message is correct
|
||||
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
trade.getTradingPeer().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
|
||||
// handle if payout tx is not seen on network
|
||||
if (trade.getPhase().ordinal() < Trade.Phase.PAYOUT_PUBLISHED.ordinal()) {
|
||||
|
|
|
@ -49,10 +49,10 @@ public class BuyerSendPaymentAccountKeyRequestToArbitrator extends TradeTask {
|
|||
);
|
||||
|
||||
// send request to arbitrator
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", request.getClass().getSimpleName(), request.getTradeId(), request.getUid(), trade.getArbitratorNodeAddress(), trade.getArbitratorPubKeyRing());
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", request.getClass().getSimpleName(), request.getTradeId(), request.getUid(), trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
trade.getArbitratorNodeAddress(),
|
||||
trade.getArbitratorPubKeyRing(),
|
||||
trade.getArbitrator().getNodeAddress(),
|
||||
trade.getArbitrator().getPubKeyRing(),
|
||||
request,
|
||||
new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
|
|
@ -40,12 +40,12 @@ public class BuyerSendPayoutTxPublishedMessage extends SendMailboxMessageTask {
|
|||
|
||||
@Override
|
||||
protected NodeAddress getReceiverNodeAddress() {
|
||||
return trade.getArbitratorNodeAddress();
|
||||
return trade.getArbitrator().getNodeAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PubKeyRing getReceiverPubKeyRing() {
|
||||
return trade.getArbitratorPubKeyRing();
|
||||
return trade.getArbitrator().getPubKeyRing();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -72,9 +72,9 @@ public class MakerSendInitTradeRequest extends TradeTask {
|
|||
Version.getP2PMessageVersion(),
|
||||
sig,
|
||||
makerRequest.getCurrentDate(),
|
||||
trade.getMakerNodeAddress(),
|
||||
trade.getTakerNodeAddress(),
|
||||
trade.getArbitratorNodeAddress(),
|
||||
trade.getMaker().getNodeAddress(),
|
||||
trade.getTaker().getNodeAddress(),
|
||||
trade.getArbitrator().getNodeAddress(),
|
||||
trade.getSelf().getReserveTxHash(),
|
||||
trade.getSelf().getReserveTxHex(),
|
||||
trade.getSelf().getReserveTxKey(),
|
||||
|
@ -82,10 +82,10 @@ public class MakerSendInitTradeRequest extends TradeTask {
|
|||
null);
|
||||
|
||||
// send request to arbitrator
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", arbitratorRequest.getClass().getSimpleName(), arbitratorRequest.getTradeId(), arbitratorRequest.getUid(), trade.getArbitratorNodeAddress(), trade.getArbitratorPubKeyRing());
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", arbitratorRequest.getClass().getSimpleName(), arbitratorRequest.getTradeId(), arbitratorRequest.getUid(), trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
trade.getArbitratorNodeAddress(),
|
||||
trade.getArbitratorPubKeyRing(),
|
||||
trade.getArbitrator().getNodeAddress(),
|
||||
trade.getArbitrator().getPubKeyRing(),
|
||||
arbitratorRequest,
|
||||
new SendDirectMessageListener() {
|
||||
@Override
|
||||
|
|
|
@ -97,32 +97,32 @@ public class MaybeSendSignContractRequest extends TradeTask {
|
|||
depositTx.getHash());
|
||||
|
||||
// send request to trading peer
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeerNodeAddress(), trade.getTradingPeerPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeer().getNodeAddress(), trade.getTradingPeer().getPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived: trading peer={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getTradingPeerNodeAddress(), trade.getId());
|
||||
log.info("{} arrived: trading peer={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getTradingPeer().getNodeAddress(), trade.getId());
|
||||
ack1 = true;
|
||||
if (ack1 && ack2) completeAux();
|
||||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getTradingPeerNodeAddress(), trade.getId(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getTradingPeer().getNodeAddress(), trade.getId(), errorMessage);
|
||||
appendToErrorMessage("Sending message failed: message=" + request + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
});
|
||||
|
||||
// send request to arbitrator
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getArbitratorNodeAddress(), trade.getArbitratorPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived: trading peer={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId());
|
||||
log.info("{} arrived: trading peer={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId());
|
||||
ack2 = true;
|
||||
if (ack1 && ack2) completeAux();
|
||||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), errorMessage);
|
||||
appendToErrorMessage("Sending message failed: message=" + request + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ public class ProcessInitMultisigRequest extends TradeTask {
|
|||
|
||||
// get peer multisig participant
|
||||
TradingPeer multisigParticipant;
|
||||
if (request.getSenderNodeAddress().equals(trade.getMakerNodeAddress())) multisigParticipant = processModel.getMaker();
|
||||
else if (request.getSenderNodeAddress().equals(trade.getTakerNodeAddress())) multisigParticipant = processModel.getTaker();
|
||||
else if (request.getSenderNodeAddress().equals(trade.getArbitratorNodeAddress())) multisigParticipant = processModel.getArbitrator();
|
||||
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
|
||||
|
@ -135,20 +135,20 @@ public class ProcessInitMultisigRequest extends TradeTask {
|
|||
NodeAddress peer2Address;
|
||||
PubKeyRing peer2PubKeyRing;
|
||||
if (trade instanceof ArbitratorTrade) {
|
||||
peer1Address = trade.getTakerNodeAddress();
|
||||
peer1PubKeyRing = trade.getTakerPubKeyRing();
|
||||
peer2Address = trade.getMakerNodeAddress();
|
||||
peer2PubKeyRing = trade.getMakerPubKeyRing();
|
||||
peer1Address = trade.getTaker().getNodeAddress();
|
||||
peer1PubKeyRing = trade.getTaker().getPubKeyRing();
|
||||
peer2Address = trade.getMaker().getNodeAddress();
|
||||
peer2PubKeyRing = trade.getMaker().getPubKeyRing();
|
||||
} else if (trade instanceof MakerTrade) {
|
||||
peer1Address = trade.getTakerNodeAddress();
|
||||
peer1PubKeyRing = trade.getTakerPubKeyRing();
|
||||
peer2Address = trade.getArbitratorNodeAddress();
|
||||
peer2PubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
peer1Address = trade.getTaker().getNodeAddress();
|
||||
peer1PubKeyRing = trade.getTaker().getPubKeyRing();
|
||||
peer2Address = trade.getArbitrator().getNodeAddress();
|
||||
peer2PubKeyRing = trade.getArbitrator().getPubKeyRing();
|
||||
} else {
|
||||
peer1Address = trade.getMakerNodeAddress();
|
||||
peer1PubKeyRing = trade.getMakerPubKeyRing();
|
||||
peer2Address = trade.getArbitratorNodeAddress();
|
||||
peer2PubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
peer1Address = trade.getMaker().getNodeAddress();
|
||||
peer1PubKeyRing = trade.getMaker().getPubKeyRing();
|
||||
peer2Address = trade.getArbitrator().getNodeAddress();
|
||||
peer2PubKeyRing = trade.getArbitrator().getPubKeyRing();
|
||||
}
|
||||
|
||||
if (peer1Address == null) throw new RuntimeException("Peer1 address is null");
|
||||
|
|
|
@ -61,16 +61,16 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
// handle request as arbitrator
|
||||
TradingPeer multisigParticipant;
|
||||
if (trade instanceof ArbitratorTrade) {
|
||||
trade.setMakerPubKeyRing((trade.getOffer().getPubKeyRing()));
|
||||
trade.setArbitratorPubKeyRing(processModel.getPubKeyRing());
|
||||
trade.getMaker().setPubKeyRing((trade.getOffer().getPubKeyRing()));
|
||||
trade.getArbitrator().setPubKeyRing(processModel.getPubKeyRing());
|
||||
processModel.getArbitrator().setPubKeyRing(processModel.getPubKeyRing()); // TODO (woodser): why duplicating field in process model
|
||||
|
||||
// handle request from taker
|
||||
if (request.getSenderNodeAddress().equals(request.getTakerNodeAddress())) {
|
||||
multisigParticipant = processModel.getTaker();
|
||||
if (!trade.getTakerNodeAddress().equals(request.getTakerNodeAddress())) throw new RuntimeException("Init trade requests from maker and taker do not agree");
|
||||
if (trade.getTakerPubKeyRing() != null) throw new RuntimeException("Pub key ring should not be initialized before processing InitTradeRequest");
|
||||
trade.setTakerPubKeyRing(request.getPubKeyRing());
|
||||
if (!trade.getTaker().getNodeAddress().equals(request.getTakerNodeAddress())) throw new RuntimeException("Init trade requests from maker and taker do not agree");
|
||||
if (trade.getTaker().getPubKeyRing() != null) throw new RuntimeException("Pub key ring should not be initialized before processing InitTradeRequest");
|
||||
trade.getTaker().setPubKeyRing(request.getPubKeyRing());
|
||||
if (!TradeUtils.isMakerSignatureValid(request, request.getMakerSignature(), offer.getPubKeyRing())) throw new RuntimeException("Maker signature is invalid for the trade request"); // verify maker signature
|
||||
|
||||
// check trade price
|
||||
|
@ -88,10 +88,10 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
// handle request from maker
|
||||
else if (request.getSenderNodeAddress().equals(request.getMakerNodeAddress())) {
|
||||
multisigParticipant = processModel.getMaker();
|
||||
if (!trade.getMakerNodeAddress().equals(request.getMakerNodeAddress())) throw new RuntimeException("Init trade requests from maker and taker do not agree"); // TODO (woodser): test when maker and taker do not agree, use proper handling, uninitialize trade for other takers
|
||||
if (trade.getMakerPubKeyRing() == null) trade.setMakerPubKeyRing(request.getPubKeyRing());
|
||||
else if (!trade.getMakerPubKeyRing().equals(request.getPubKeyRing())) throw new RuntimeException("Init trade requests from maker and taker do not agree"); // TODO (woodser): proper handling
|
||||
trade.setMakerPubKeyRing(request.getPubKeyRing());
|
||||
if (!trade.getMaker().getNodeAddress().equals(request.getMakerNodeAddress())) throw new RuntimeException("Init trade requests from maker and taker do not agree"); // TODO (woodser): test when maker and taker do not agree, use proper handling, uninitialize trade for other takers
|
||||
if (trade.getMaker().getPubKeyRing() == null) trade.getMaker().setPubKeyRing(request.getPubKeyRing());
|
||||
else if (!trade.getMaker().getPubKeyRing().equals(request.getPubKeyRing())) throw new RuntimeException("Init trade requests from maker and taker do not agree"); // TODO (woodser): proper handling
|
||||
trade.getMaker().setPubKeyRing(request.getPubKeyRing());
|
||||
if (trade.getPrice().getValue() != request.getTradePrice()) throw new RuntimeException("Maker and taker price do not agree");
|
||||
} else {
|
||||
throw new RuntimeException("Sender is not trade's maker or taker");
|
||||
|
@ -101,8 +101,8 @@ public class ProcessInitTradeRequest extends TradeTask {
|
|||
// handle maker trade
|
||||
else if (trade instanceof MakerTrade) {
|
||||
multisigParticipant = processModel.getTaker();
|
||||
trade.setTakerNodeAddress(request.getSenderNodeAddress()); // arbitrator sends maker InitTradeRequest with taker's node address and pub key ring
|
||||
trade.setTakerPubKeyRing(request.getPubKeyRing());
|
||||
trade.getTaker().setNodeAddress(request.getSenderNodeAddress()); // arbitrator sends maker InitTradeRequest with taker's node address and pub key ring
|
||||
trade.getTaker().setPubKeyRing(request.getPubKeyRing());
|
||||
|
||||
// check trade price
|
||||
try {
|
||||
|
|
|
@ -112,10 +112,10 @@ public class ProcessSignContractRequest extends TradeTask {
|
|||
encryptedPaymentAccountPayload);
|
||||
|
||||
// get response recipients. only arbitrator sends response to both peers
|
||||
NodeAddress recipient1 = trade instanceof ArbitratorTrade ? trade.getMakerNodeAddress() : trade.getTradingPeerNodeAddress();
|
||||
PubKeyRing recipient1PubKey = trade instanceof ArbitratorTrade ? trade.getMakerPubKeyRing() : trade.getTradingPeerPubKeyRing();
|
||||
NodeAddress recipient2 = trade instanceof ArbitratorTrade ? trade.getTakerNodeAddress() : null;
|
||||
PubKeyRing recipient2PubKey = trade instanceof ArbitratorTrade ? trade.getTakerPubKeyRing() : null;
|
||||
NodeAddress recipient1 = trade instanceof ArbitratorTrade ? trade.getMaker().getNodeAddress() : trade.getTradingPeer().getNodeAddress();
|
||||
PubKeyRing recipient1PubKey = trade instanceof ArbitratorTrade ? trade.getMaker().getPubKeyRing() : trade.getTradingPeer().getPubKeyRing();
|
||||
NodeAddress recipient2 = trade instanceof ArbitratorTrade ? trade.getTaker().getNodeAddress() : null;
|
||||
PubKeyRing recipient2PubKey = trade instanceof ArbitratorTrade ? trade.getTaker().getPubKeyRing() : null;
|
||||
|
||||
// send response to recipient 1
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(recipient1, recipient1PubKey, response, new SendDirectMessageListener() {
|
||||
|
|
|
@ -54,13 +54,8 @@ public class ProcessSignContractResponse extends TradeTask {
|
|||
}
|
||||
|
||||
// get peer info
|
||||
// TODO (woodser): make these utilities / refactor model
|
||||
PubKeyRing peerPubKeyRing;
|
||||
TradingPeer peer = trade.getTradingPeer(response.getSenderNodeAddress());
|
||||
if (peer == processModel.getArbitrator()) peerPubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
else if (peer == processModel.getMaker()) peerPubKeyRing = trade.getMakerPubKeyRing();
|
||||
else if (peer == processModel.getTaker()) peerPubKeyRing = trade.getTakerPubKeyRing();
|
||||
else throw new RuntimeException(response.getClass().getSimpleName() + " is not from maker, taker, or arbitrator");
|
||||
PubKeyRing peerPubKeyRing = peer.getPubKeyRing();
|
||||
|
||||
// save peer's encrypted payment account payload
|
||||
peer.setEncryptedPaymentAccountPayload(response.getEncryptedPaymentAccountPayload());
|
||||
|
@ -94,18 +89,18 @@ public class ProcessSignContractResponse extends TradeTask {
|
|||
trade.getSelf().getPaymentAccountKey());
|
||||
|
||||
// send request to arbitrator
|
||||
log.info("Sending {} to arbitrator {}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), request.getUid());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getArbitratorNodeAddress(), trade.getArbitratorPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
log.info("Sending {} to arbitrator {}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), request.getUid());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), request.getUid());
|
||||
log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), request.getUid());
|
||||
trade.setStateIfValidTransitionTo(Trade.State.SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
complete();
|
||||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), errorMessage);
|
||||
appendToErrorMessage("Sending message failed: message=" + request + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ public class ProcessUpdateMultisigRequest extends TradeTask {
|
|||
new Date().getTime(),
|
||||
updatedMultisigHex);
|
||||
|
||||
log.info("Send {} with offerId {} and uid {} to peer {}", response.getClass().getSimpleName(), response.getTradeId(), response.getUid(), trade.getTradingPeerNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeerNodeAddress(), trade.getTradingPeerPubKeyRing(), response, new SendDirectMessageListener() {
|
||||
log.info("Send {} with offerId {} and uid {} to peer {}", response.getClass().getSimpleName(), response.getTradeId(), response.getUid(), trade.getTradingPeer().getNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeer().getNodeAddress(), trade.getTradingPeer().getPubKeyRing(), response, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived at trading peer: offerId={}; uid={}", response.getClass().getSimpleName(), response.getTradeId(), response.getUid());
|
||||
|
@ -97,7 +97,7 @@ public class ProcessUpdateMultisigRequest extends TradeTask {
|
|||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", response.getClass().getSimpleName(), response.getUid(), trade.getArbitratorNodeAddress(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", response.getClass().getSimpleName(), response.getUid(), trade.getArbitrator().getNodeAddress(), errorMessage);
|
||||
appendToErrorMessage("Sending response failed: response=" + response + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PublishTradeStatistics extends TradeTask {
|
|||
extraDataMap.put(OfferPayload.REFERRAL_ID, processModel.getReferralIdService().getOptionalReferralId().get());
|
||||
}
|
||||
|
||||
NodeAddress mediatorNodeAddress = checkNotNull(trade.getArbitratorNodeAddress());
|
||||
NodeAddress mediatorNodeAddress = checkNotNull(trade.getArbitrator().getNodeAddress());
|
||||
// The first 4 chars are sufficient to identify a mediator.
|
||||
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
||||
// same values for multiple mediators.
|
||||
|
|
|
@ -55,12 +55,12 @@ public class SellerMaybeSendPayoutTxPublishedMessage extends SendMailboxMessageT
|
|||
|
||||
@Override
|
||||
protected NodeAddress getReceiverNodeAddress() {
|
||||
return trade.getArbitratorNodeAddress();
|
||||
return trade.getArbitrator().getNodeAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PubKeyRing getReceiverPubKeyRing() {
|
||||
return trade.getArbitratorPubKeyRing();
|
||||
return trade.getArbitrator().getPubKeyRing();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SellerProcessPaymentSentMessage extends TradeTask {
|
|||
}
|
||||
|
||||
// update latest peer address
|
||||
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
trade.getTradingPeer().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
|
||||
String counterCurrencyTxId = message.getCounterCurrencyTxId();
|
||||
if (counterCurrencyTxId != null && counterCurrencyTxId.length() < 100) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SellerPublishTradeStatistics extends TradeTask {
|
|||
//
|
||||
// checkNotNull(trade.getDepositTx());
|
||||
//
|
||||
// processModel.getP2PService().findPeersCapabilities(trade.getTradingPeerNodeAddress())
|
||||
// processModel.getP2PService().findPeersCapabilities(trade.getTradingPeer().getNodeAddress())
|
||||
// .filter(capabilities -> capabilities.containsAll(Capability.TRADE_STATISTICS_3))
|
||||
// .ifPresentOrElse(capabilities -> {
|
||||
// // Our peer has updated, so as we are the seller we will publish the trade statistics.
|
||||
|
|
|
@ -71,7 +71,7 @@ public class SellerSendPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||
protected void setStateSent() {
|
||||
trade.setState(trade.getState().ordinal() >= Trade.State.SELLER_PUBLISHED_PAYOUT_TX.ordinal() ? Trade.State.SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG);
|
||||
log.info("Sent SellerReceivedPaymentMessage: tradeId={} at peer {} SignedWitness {}",
|
||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||
trade.getId(), trade.getTradingPeer().getNodeAddress(), signedWitness);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class SellerSendPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||
protected void setStateArrived() {
|
||||
trade.setState(trade.getState().ordinal() >= Trade.State.SELLER_PUBLISHED_PAYOUT_TX.ordinal() ? Trade.State.SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SAW_ARRIVED_PAYMENT_RECEIVED_MSG);
|
||||
log.info("Seller's PaymentReceivedMessage arrived: tradeId={} at peer {} SignedWitness {}",
|
||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||
trade.getId(), trade.getTradingPeer().getNodeAddress(), signedWitness);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class SellerSendPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||
protected void setStateStoredInMailbox() {
|
||||
trade.setState(trade.getState().ordinal() >= Trade.State.SELLER_PUBLISHED_PAYOUT_TX.ordinal() ? Trade.State.SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG);
|
||||
log.info("Seller's PaymentReceivedMessage stored in mailbox: tradeId={} at peer {} SignedWitness {}",
|
||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||
trade.getId(), trade.getTradingPeer().getNodeAddress(), signedWitness);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class SellerSendPaymentReceivedMessage extends SendMailboxMessageTask {
|
|||
protected void setStateFault() {
|
||||
trade.setState(trade.getState().ordinal() >= Trade.State.SELLER_PUBLISHED_PAYOUT_TX.ordinal() ? Trade.State.SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG : Trade.State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG);
|
||||
log.error("SellerReceivedPaymentMessage failed: tradeId={} at peer {} SignedWitness {}",
|
||||
trade.getId(), trade.getTradingPeerNodeAddress(), signedWitness);
|
||||
trade.getId(), trade.getTradingPeer().getNodeAddress(), signedWitness);
|
||||
processModel.getTradeManager().requestPersistence();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class SendMailboxMessageTask extends TradeTask {
|
|||
}
|
||||
|
||||
protected NodeAddress getReceiverNodeAddress() {
|
||||
return trade.getTradingPeerNodeAddress();
|
||||
return trade.getTradingPeer().getNodeAddress();
|
||||
}
|
||||
|
||||
protected PubKeyRing getReceiverPubKeyRing() {
|
||||
|
|
|
@ -93,8 +93,8 @@ public class TakerSendInitTradeRequestToArbitrator extends TradeTask {
|
|||
|
||||
// set pub keys
|
||||
processModel.getArbitrator().setPubKeyRing(arbitrator.getPubKeyRing());
|
||||
trade.setArbitratorNodeAddress(arbitratorNodeAddress);
|
||||
trade.setArbitratorPubKeyRing(processModel.getArbitrator().getPubKeyRing());
|
||||
trade.getArbitrator().setNodeAddress(arbitratorNodeAddress);
|
||||
trade.getArbitrator().setPubKeyRing(processModel.getArbitrator().getPubKeyRing());
|
||||
|
||||
// create request to arbitrator
|
||||
InitTradeRequest makerRequest = (InitTradeRequest) processModel.getTradeMessage(); // taker's InitTradeRequest to maker
|
||||
|
@ -114,7 +114,7 @@ public class TakerSendInitTradeRequestToArbitrator extends TradeTask {
|
|||
makerRequest.getCurrentDate(),
|
||||
makerRequest.getMakerNodeAddress(),
|
||||
makerRequest.getTakerNodeAddress(),
|
||||
trade.getArbitratorNodeAddress(),
|
||||
trade.getArbitrator().getNodeAddress(),
|
||||
processModel.getReserveTx().getHash(),
|
||||
processModel.getReserveTx().getFullHex(),
|
||||
processModel.getReserveTx().getKey(),
|
||||
|
@ -122,7 +122,7 @@ public class TakerSendInitTradeRequestToArbitrator extends TradeTask {
|
|||
processModel.getMakerSignature());
|
||||
|
||||
// send request to arbitrator
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", arbitratorRequest.getClass().getSimpleName(), arbitratorRequest.getTradeId(), arbitratorRequest.getUid(), trade.getArbitratorNodeAddress(), trade.getArbitratorPubKeyRing());
|
||||
log.info("Sending {} with offerId {} and uid {} to arbitrator {} with pub key ring {}", arbitratorRequest.getClass().getSimpleName(), arbitratorRequest.getTradeId(), arbitratorRequest.getUid(), trade.getArbitrator().getNodeAddress(), trade.getArbitrator().getPubKeyRing());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(
|
||||
arbitratorNodeAddress,
|
||||
arbitrator.getPubKeyRing(),
|
||||
|
|
|
@ -95,16 +95,16 @@ public class UpdateMultisigWithTradingPeer extends TradeTask {
|
|||
|
||||
System.out.println("Sending message: " + message);
|
||||
|
||||
// TODO (woodser): trade.getTradingPeerNodeAddress() and/or trade.getTradingPeerPubKeyRing() are null on restart of application, so cannot send payment to complete trade
|
||||
log.info("Send {} with offerId {} and uid {} to peer {}", message.getClass().getSimpleName(), message.getTradeId(), message.getUid(), trade.getTradingPeerNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeerNodeAddress(), trade.getTradingPeerPubKeyRing(), message, new SendDirectMessageListener() {
|
||||
// TODO (woodser): trade.getTradingPeer().getNodeAddress() and/or trade.getTradingPeer().getPubKeyRing() are null on restart of application, so cannot send payment to complete trade
|
||||
log.info("Send {} with offerId {} and uid {} to peer {}", message.getClass().getSimpleName(), message.getTradeId(), message.getUid(), trade.getTradingPeer().getNodeAddress());
|
||||
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeer().getNodeAddress(), trade.getTradingPeer().getPubKeyRing(), message, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
log.info("{} arrived at trading peer: offerId={}; uid={}", message.getClass().getSimpleName(), message.getTradeId(), message.getUid());
|
||||
}
|
||||
@Override
|
||||
public void onFault(String errorMessage) {
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", message.getClass().getSimpleName(), message.getUid(), trade.getArbitratorNodeAddress(), errorMessage);
|
||||
log.error("Sending {} failed: uid={}; peer={}; error={}", message.getClass().getSimpleName(), message.getUid(), trade.getArbitrator().getNodeAddress(), errorMessage);
|
||||
appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage);
|
||||
failed();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ProcessMediatedPayoutSignatureMessage extends TradeTask {
|
|||
trade.getTradingPeer().setMediatedPayoutTxSignature(checkNotNull(message.getTxSignature()));
|
||||
|
||||
// update to the latest peer address of our peer if the message is correct
|
||||
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
trade.getTradingPeer().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
|
||||
trade.setMediationResultState(MediationResultState.RECEIVED_SIG_MSG);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ProcessMediatedPayoutTxPublishedMessage extends TradeTask {
|
|||
// checkArgument(message.getPayoutTx() != null);
|
||||
//
|
||||
// // update to the latest peer address of our peer if the message is correct
|
||||
// trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
// trade.getTradingPeer().setNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||
//
|
||||
// if (trade.getPayoutTx() == null) {
|
||||
// Transaction committedMediatedPayoutTx = WalletService.maybeAddNetworkTxToWallet(message.getPayoutTx(), processModel.getBtcWalletService().getWallet());
|
||||
|
|
|
@ -81,7 +81,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
|
|||
extraDataMap.put(OfferPayload.REFERRAL_ID, referralId);
|
||||
}
|
||||
|
||||
NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress();
|
||||
NodeAddress arbitratorNodeAddress = trade.getArbitrator().getNodeAddress();
|
||||
if (arbitratorNodeAddress != null) {
|
||||
// The first 4 chars are sufficient to identify a arbitrator.
|
||||
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
||||
|
|
|
@ -86,7 +86,7 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||
extraDataMap.put(OfferPayload.REFERRAL_ID, referralId);
|
||||
}
|
||||
|
||||
NodeAddress arbitratorNodeAddress = checkNotNull(trade.getArbitratorNodeAddress());
|
||||
NodeAddress arbitratorNodeAddress = checkNotNull(trade.getArbitrator().getNodeAddress());
|
||||
|
||||
// The first 4 chars are sufficient to identify an arbitrator.
|
||||
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
||||
|
|
|
@ -142,7 +142,7 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
|
|||
.isPresent();
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getObservableList().stream()
|
||||
.filter(t -> t.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()) ||
|
||||
paymentAccount.getId().equals(t.getTakerPaymentAccountId()))
|
||||
paymentAccount.getId().equals(t.getTaker().getPaymentAccountId()))
|
||||
.findAny()
|
||||
.isPresent();
|
||||
if (!isPaymentAccountUsed)
|
||||
|
|
|
@ -147,7 +147,7 @@ class FiatAccountsDataModel extends ActivatableDataModel {
|
|||
.anyMatch(o -> o.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()));
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getObservableList().stream()
|
||||
.anyMatch(t -> t.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()) ||
|
||||
paymentAccount.getId().equals(t.getTakerPaymentAccountId()));
|
||||
paymentAccount.getId().equals(t.getTaker().getPaymentAccountId()));
|
||||
if (!isPaymentAccountUsed)
|
||||
user.removePaymentAccount(paymentAccount);
|
||||
return isPaymentAccountUsed;
|
||||
|
|
|
@ -208,7 +208,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
rows++;
|
||||
if (trade.hasFailed())
|
||||
rows += 2;
|
||||
if (trade.getTradingPeerNodeAddress() != null)
|
||||
if (trade.getTradingPeer().getNodeAddress() != null)
|
||||
rows++;
|
||||
if (showXmrProofResult)
|
||||
rows++;
|
||||
|
@ -232,16 +232,16 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
Res.get("shared.takerTxFee", formatter.formatCoinWithCode(trade.getTxFee().multiply(3)));
|
||||
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
|
||||
|
||||
NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress();
|
||||
NodeAddress arbitratorNodeAddress = trade.getArbitrator().getNodeAddress();
|
||||
if (arbitratorNodeAddress != null) {
|
||||
addConfirmationLabelTextField(gridPane, ++rowIndex,
|
||||
Res.get("tradeDetailsWindow.agentAddresses"),
|
||||
arbitratorNodeAddress.getFullAddress());
|
||||
}
|
||||
|
||||
if (trade.getTradingPeerNodeAddress() != null)
|
||||
if (trade.getTradingPeer().getNodeAddress() != null)
|
||||
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
|
||||
trade.getTradingPeerNodeAddress().getFullAddress());
|
||||
trade.getTradingPeer().getNodeAddress().getFullAddress());
|
||||
|
||||
if (showXmrProofResult) {
|
||||
// As the window is already overloaded we replace the tradingPeersPubKeyHash field with the auto-conf state
|
||||
|
|
|
@ -501,7 +501,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
|
|||
if (!empty && item != null && item.getTradable() instanceof Trade) {
|
||||
Trade tradeModel = (Trade) item.getTradable();
|
||||
int numPastTrades = item.getNumPastTrades();
|
||||
NodeAddress tradingPeerNodeAddress = tradeModel.getTradingPeerNodeAddress();
|
||||
NodeAddress tradingPeerNodeAddress = tradeModel.getTradingPeer().getNodeAddress();
|
||||
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
||||
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress,
|
||||
role,
|
||||
|
|
|
@ -522,7 +522,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
// If no dispute state set we start with mediation
|
||||
resultHandler = () -> navigation.navigateTo(MainView.class, SupportView.class, MediationClientView.class);
|
||||
disputeManager = mediationManager;
|
||||
PubKeyRing arbitratorPubKeyRing = trade.getArbitratorPubKeyRing();
|
||||
PubKeyRing arbitratorPubKeyRing = trade.getArbitrator().getPubKeyRing();
|
||||
checkNotNull(arbitratorPubKeyRing, "arbitratorPubKeyRing must not be null");
|
||||
byte[] depositTxSerialized = null; // depositTx.bitcoinSerialize(); // TODO (woodser): no serialized txs in xmr
|
||||
Dispute dispute = new Dispute(new Date().getTime(),
|
||||
|
|
|
@ -849,7 +849,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
super.updateItem(newItem, empty);
|
||||
if (!empty && newItem != null) {
|
||||
final Trade trade = newItem.getTrade();
|
||||
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeerNodeAddress();
|
||||
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeer().getNodeAddress();
|
||||
int numPastTrades = model.getNumPastTrades(trade);
|
||||
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
||||
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress,
|
||||
|
|
|
@ -372,9 +372,9 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
.filter(e -> {
|
||||
if (e instanceof Trade) {
|
||||
Trade t = (Trade) e;
|
||||
return t.getTradingPeerNodeAddress() != null &&
|
||||
trade.getTradingPeerNodeAddress() != null &&
|
||||
t.getTradingPeerNodeAddress().getFullAddress().equals(trade.getTradingPeerNodeAddress().getFullAddress());
|
||||
return t.getTradingPeer().getNodeAddress() != null &&
|
||||
trade.getTradingPeer().getNodeAddress() != null &&
|
||||
t.getTradingPeer().getNodeAddress().getFullAddress().equals(trade.getTradingPeer().getNodeAddress().getFullAddress());
|
||||
} else
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1725,28 +1725,18 @@ message Trade {
|
|||
bytes contract_hash = 16;
|
||||
NodeAddress arbitrator_node_address = 17;
|
||||
NodeAddress mediator_node_address = 18;
|
||||
bytes arbitrator_btc_pub_key = 19;
|
||||
string taker_payment_account_id = 20;
|
||||
string error_message = 21;
|
||||
PubKeyRing arbitrator_pub_key_ring = 22;
|
||||
PubKeyRing mediator_pub_key_ring = 23;
|
||||
string counter_currency_tx_id = 24;
|
||||
repeated ChatMessage chat_message = 25;
|
||||
MediationResultState mediation_result_state = 26;
|
||||
int64 lock_time = 27;
|
||||
bytes delayed_payout_tx_bytes = 28;
|
||||
NodeAddress refund_agent_node_address = 29;
|
||||
PubKeyRing refund_agent_pub_key_ring = 30;
|
||||
RefundResultState refund_result_state = 31;
|
||||
int64 last_refresh_request_date = 32 [deprecated = true];
|
||||
string counter_currency_extra_data = 33;
|
||||
string asset_tx_proof_result = 34; // name of AssetTxProofResult enum
|
||||
string uid = 35;
|
||||
|
||||
NodeAddress maker_node_address = 100; // TODO (woodser): move these into TradingPeer
|
||||
NodeAddress taker_node_address = 101;
|
||||
PubKeyRing taker_pub_key_ring = 102;
|
||||
PubKeyRing maker_pub_key_ring = 103;
|
||||
RefundResultState refund_result_state = 30;
|
||||
int64 last_refresh_request_date = 31 [deprecated = true];
|
||||
string counter_currency_extra_data = 32;
|
||||
string asset_tx_proof_result = 33; // name of AssetTxProofResult enum
|
||||
string uid = 34;
|
||||
}
|
||||
|
||||
message BuyerAsMakerTrade {
|
||||
|
@ -1800,26 +1790,27 @@ message ProcessModel {
|
|||
}
|
||||
|
||||
message TradingPeer {
|
||||
string account_id = 1;
|
||||
string payment_account_id = 2;
|
||||
string payment_method_id = 3;
|
||||
bytes payment_account_payload_hash = 4;
|
||||
bytes encrypted_payment_account_payload = 5;
|
||||
bytes payment_account_key = 6;
|
||||
PaymentAccountPayload payment_account_payload = 7;
|
||||
string payout_address_string = 8;
|
||||
string contract_as_json = 9;
|
||||
string contract_signature = 10;
|
||||
bytes signature = 11; // TODO (woodser): remove unused fields? this was buyer-signed payout tx as bytes
|
||||
PubKeyRing pub_key_ring = 12;
|
||||
bytes multi_sig_pub_key = 13;
|
||||
repeated RawTransactionInput raw_transaction_inputs = 14;
|
||||
int64 change_output_value = 15;
|
||||
string change_output_address = 16;
|
||||
bytes account_age_witness_nonce = 17;
|
||||
bytes account_age_witness_signature = 18;
|
||||
int64 current_date = 19;
|
||||
bytes mediated_payout_tx_signature = 20;
|
||||
NodeAddress node_address = 1;
|
||||
PubKeyRing pub_key_ring = 2;
|
||||
string account_id = 3;
|
||||
string payment_account_id = 4;
|
||||
string payment_method_id = 5;
|
||||
bytes payment_account_payload_hash = 6;
|
||||
bytes encrypted_payment_account_payload = 7;
|
||||
bytes payment_account_key = 8;
|
||||
PaymentAccountPayload payment_account_payload = 9;
|
||||
string payout_address_string = 10;
|
||||
string contract_as_json = 11;
|
||||
string contract_signature = 12;
|
||||
bytes signature = 13; // TODO (woodser): remove unused fields? this was buyer-signed payout tx as bytes
|
||||
bytes multi_sig_pub_key = 14;
|
||||
repeated RawTransactionInput raw_transaction_inputs = 15;
|
||||
int64 change_output_value = 16;
|
||||
string change_output_address = 17;
|
||||
bytes account_age_witness_nonce = 18;
|
||||
bytes account_age_witness_signature = 19;
|
||||
int64 current_date = 20;
|
||||
bytes mediated_payout_tx_signature = 21;
|
||||
|
||||
string reserve_tx_hash = 1001;
|
||||
string reserve_tx_hex = 1002;
|
||||
|
|
Loading…
Reference in a new issue