remove unused fields from TradePeer and Contract

fix concurrent modification exception applying prices to trade stats
standardize offer fee tx ids (unused)
This commit is contained in:
woodser 2023-03-09 13:00:49 -05:00
parent a16b03bb5c
commit 47f3d98597
28 changed files with 60 additions and 108 deletions

View file

@ -41,7 +41,6 @@ public class ContractInfo implements Payload {
private final PaymentAccountPayload takerPaymentAccountPayload; private final PaymentAccountPayload takerPaymentAccountPayload;
private final String makerPayoutAddressString; private final String makerPayoutAddressString;
private final String takerPayoutAddressString; private final String takerPayoutAddressString;
private final long lockTime;
public ContractInfo(String buyerNodeAddress, public ContractInfo(String buyerNodeAddress,
String sellerNodeAddress, String sellerNodeAddress,
@ -52,8 +51,7 @@ public class ContractInfo implements Payload {
PaymentAccountPayload makerPaymentAccountPayload, PaymentAccountPayload makerPaymentAccountPayload,
PaymentAccountPayload takerPaymentAccountPayload, PaymentAccountPayload takerPaymentAccountPayload,
String makerPayoutAddressString, String makerPayoutAddressString,
String takerPayoutAddressString, String takerPayoutAddressString) {
long lockTime) {
this.buyerNodeAddress = buyerNodeAddress; this.buyerNodeAddress = buyerNodeAddress;
this.sellerNodeAddress = sellerNodeAddress; this.sellerNodeAddress = sellerNodeAddress;
this.arbitratorNodeAddress = arbitratorNodeAddress; this.arbitratorNodeAddress = arbitratorNodeAddress;
@ -64,7 +62,6 @@ public class ContractInfo implements Payload {
this.takerPaymentAccountPayload = takerPaymentAccountPayload; this.takerPaymentAccountPayload = takerPaymentAccountPayload;
this.makerPayoutAddressString = makerPayoutAddressString; this.makerPayoutAddressString = makerPayoutAddressString;
this.takerPayoutAddressString = takerPayoutAddressString; this.takerPayoutAddressString = takerPayoutAddressString;
this.lockTime = lockTime;
} }
@ -79,8 +76,7 @@ public class ContractInfo implements Payload {
null, null,
null, null,
"", "",
"", "");
0);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER // PROTO BUFFER
@ -97,8 +93,7 @@ public class ContractInfo implements Payload {
proto.getMakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getMakerPaymentAccountPayload(), coreProtoResolver), proto.getMakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getMakerPaymentAccountPayload(), coreProtoResolver),
proto.getTakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getTakerPaymentAccountPayload(), coreProtoResolver), proto.getTakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getTakerPaymentAccountPayload(), coreProtoResolver),
proto.getMakerPayoutAddressString(), proto.getMakerPayoutAddressString(),
proto.getTakerPayoutAddressString(), proto.getTakerPayoutAddressString());
proto.getLockTime());
} }
@Override @Override
@ -111,8 +106,7 @@ public class ContractInfo implements Payload {
.setMakerAccountId(makerAccountId) .setMakerAccountId(makerAccountId)
.setTakerAccountId(takerAccountId) .setTakerAccountId(takerAccountId)
.setMakerPayoutAddressString(makerPayoutAddressString) .setMakerPayoutAddressString(makerPayoutAddressString)
.setTakerPayoutAddressString(takerPayoutAddressString) .setTakerPayoutAddressString(takerPayoutAddressString);
.setLockTime(lockTime);
if (makerPaymentAccountPayload != null) builder.setMakerPaymentAccountPayload((protobuf.PaymentAccountPayload) makerPaymentAccountPayload.toProtoMessage()); if (makerPaymentAccountPayload != null) builder.setMakerPaymentAccountPayload((protobuf.PaymentAccountPayload) makerPaymentAccountPayload.toProtoMessage());
if (takerPaymentAccountPayload != null) builder.setTakerPaymentAccountPayload((protobuf.PaymentAccountPayload) takerPaymentAccountPayload.toProtoMessage()); if (takerPaymentAccountPayload != null) builder.setTakerPaymentAccountPayload((protobuf.PaymentAccountPayload) takerPaymentAccountPayload.toProtoMessage());
return builder.build(); return builder.build();

View file

@ -54,7 +54,7 @@ public class OfferInfo implements Payload {
private final String minVolume; private final String minVolume;
private final long makerFee; private final long makerFee;
@Nullable @Nullable
private final String offerFeePaymentTxId; private final String offerFeeTxId;
private final long buyerSecurityDeposit; private final long buyerSecurityDeposit;
private final long sellerSecurityDeposit; private final long sellerSecurityDeposit;
private final String triggerPrice; private final String triggerPrice;
@ -87,7 +87,7 @@ public class OfferInfo implements Payload {
this.volume = builder.getVolume(); this.volume = builder.getVolume();
this.minVolume = builder.getMinVolume(); this.minVolume = builder.getMinVolume();
this.makerFee = builder.getMakerFee(); this.makerFee = builder.getMakerFee();
this.offerFeePaymentTxId = builder.getOfferFeePaymentTxId(); this.offerFeeTxId = builder.getOfferFeeTxId();
this.buyerSecurityDeposit = builder.getBuyerSecurityDeposit(); this.buyerSecurityDeposit = builder.getBuyerSecurityDeposit();
this.sellerSecurityDeposit = builder.getSellerSecurityDeposit(); this.sellerSecurityDeposit = builder.getSellerSecurityDeposit();
this.triggerPrice = builder.getTriggerPrice(); this.triggerPrice = builder.getTriggerPrice();
@ -153,7 +153,7 @@ public class OfferInfo implements Payload {
.withVolume(roundedVolume) .withVolume(roundedVolume)
.withMinVolume(roundedMinVolume) .withMinVolume(roundedMinVolume)
.withMakerFee(offer.getMakerFee().longValueExact()) .withMakerFee(offer.getMakerFee().longValueExact())
.withOfferFeePaymentTxId(offer.getOfferFeePaymentTxId()) .withOfferFeeTxId(offer.getOfferFeeTxId())
.withBuyerSecurityDeposit(offer.getBuyerSecurityDeposit().longValueExact()) .withBuyerSecurityDeposit(offer.getBuyerSecurityDeposit().longValueExact())
.withSellerSecurityDeposit(offer.getSellerSecurityDeposit().longValueExact()) .withSellerSecurityDeposit(offer.getSellerSecurityDeposit().longValueExact())
.withPaymentAccountId(offer.getMakerPaymentAccountId()) .withPaymentAccountId(offer.getMakerPaymentAccountId())
@ -204,7 +204,7 @@ public class OfferInfo implements Payload {
.setVersionNr(versionNumber) .setVersionNr(versionNumber)
.setProtocolVersion(protocolVersion); .setProtocolVersion(protocolVersion);
Optional.ofNullable(arbitratorSigner).ifPresent(builder::setArbitratorSigner); Optional.ofNullable(arbitratorSigner).ifPresent(builder::setArbitratorSigner);
Optional.ofNullable(offerFeePaymentTxId).ifPresent(builder::setOfferFeePaymentTxId); Optional.ofNullable(offerFeeTxId).ifPresent(builder::setOfferFeeTxId);
return builder.build(); return builder.build();
} }
@ -221,7 +221,7 @@ public class OfferInfo implements Payload {
.withVolume(proto.getVolume()) .withVolume(proto.getVolume())
.withMinVolume(proto.getMinVolume()) .withMinVolume(proto.getMinVolume())
.withMakerFee(proto.getMakerFee()) .withMakerFee(proto.getMakerFee())
.withOfferFeePaymentTxId(ProtoUtil.stringOrNullFromProto(proto.getOfferFeePaymentTxId())) .withOfferFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getOfferFeeTxId()))
.withBuyerSecurityDeposit(proto.getBuyerSecurityDeposit()) .withBuyerSecurityDeposit(proto.getBuyerSecurityDeposit())
.withSellerSecurityDeposit(proto.getSellerSecurityDeposit()) .withSellerSecurityDeposit(proto.getSellerSecurityDeposit())
.withTriggerPrice(proto.getTriggerPrice()) .withTriggerPrice(proto.getTriggerPrice())

View file

@ -143,8 +143,7 @@ public class TradeInfo implements Payload {
trade.getMaker().getPaymentAccountPayload(), trade.getMaker().getPaymentAccountPayload(),
trade.getTaker().getPaymentAccountPayload(), trade.getTaker().getPaymentAccountPayload(),
contract.getMakerPayoutAddressString(), contract.getMakerPayoutAddressString(),
contract.getTakerPayoutAddressString(), contract.getTakerPayoutAddressString());
contract.getLockTime());
} else { } else {
contractInfo = ContractInfo.emptyContract.get(); contractInfo = ContractInfo.emptyContract.get();
} }

View file

@ -39,7 +39,7 @@ public final class OfferInfoBuilder {
private String volume; private String volume;
private String minVolume; private String minVolume;
private long makerFee; private long makerFee;
private String offerFeePaymentTxId; private String offerFeeTxId;
private long buyerSecurityDeposit; private long buyerSecurityDeposit;
private long sellerSecurityDeposit; private long sellerSecurityDeposit;
private String triggerPrice; private String triggerPrice;
@ -111,8 +111,8 @@ public final class OfferInfoBuilder {
return this; return this;
} }
public OfferInfoBuilder withOfferFeePaymentTxId(String offerFeePaymentTxId) { public OfferInfoBuilder withOfferFeeTxId(String offerFeeTxId) {
this.offerFeePaymentTxId = offerFeePaymentTxId; this.offerFeeTxId = offerFeeTxId;
return this; return this;
} }

View file

@ -521,10 +521,10 @@ public class HavenoSetup {
// resync. // resync.
// TODO (woodser): check for invalid maker fee txs with xmr? // TODO (woodser): check for invalid maker fee txs with xmr?
// openOfferManager.getObservableList().forEach(e -> { // openOfferManager.getObservableList().forEach(e -> {
// String offerFeePaymentTxId = e.getOffer().getOfferFeePaymentTxId(); // String offerFeeTxId = e.getOffer().getOfferFeeTxId();
// if (btcWalletService.getConfidenceForTxId(offerFeePaymentTxId) == null) { // TODO (woodser): verify xmr maker fee tx // if (btcWalletService.getConfidenceForTxId(offerFeeTxId) == null) { // TODO (woodser): verify xmr maker fee tx
// String message = Res.get("popup.warning.openOfferWithInvalidMakerFeeTx", // String message = Res.get("popup.warning.openOfferWithInvalidMakerFeeTx",
// e.getOffer().getShortId(), offerFeePaymentTxId); // e.getOffer().getShortId(), offerFeeTxId);
// log.warn(message); // log.warn(message);
// if (lockedUpFundsHandler != null) { // if (lockedUpFundsHandler != null) {
// lockedUpFundsHandler.accept(message); // lockedUpFundsHandler.accept(message);

View file

@ -212,7 +212,7 @@ public class WalletAppSetup {
UserThread.runAfter(() -> { UserThread.runAfter(() -> {
String txId = newValue.getTxId(); String txId = newValue.getTxId();
openOfferManager.getObservableList().stream() openOfferManager.getObservableList().stream()
.filter(openOffer -> txId.equals(openOffer.getOffer().getOfferFeePaymentTxId())) .filter(openOffer -> txId.equals(openOffer.getOffer().getOfferFeeTxId()))
.forEach(openOffer -> { .forEach(openOffer -> {
// We delay to avoid concurrent modification exceptions // We delay to avoid concurrent modification exceptions
UserThread.runAfter(() -> { UserThread.runAfter(() -> {
@ -237,7 +237,7 @@ public class WalletAppSetup {
if (txId.equals(trade.getTaker().getDepositTxHash())) { if (txId.equals(trade.getTaker().getDepositTxHash())) {
details = Res.get("popup.warning.trade.txRejected.deposit"); details = Res.get("popup.warning.trade.txRejected.deposit");
} }
if (txId.equals(trade.getOffer().getOfferFeePaymentTxId())) { if (txId.equals(trade.getOffer().getOfferFeeTxId())) {
details = Res.get("popup.warning.trade.txRejected.tradeFee"); details = Res.get("popup.warning.trade.txRejected.tradeFee");
} }

View file

@ -275,8 +275,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
return stateProperty; return stateProperty;
} }
public void setOfferFeePaymentTxId(String offerFeePaymentTxID) { public void setOfferFeeTxId(String offerFeeTxId) {
offerPayload.setOfferFeePaymentTxId(offerFeePaymentTxID); offerPayload.setOfferFeeTxId(offerFeeTxId);
} }
public void setErrorMessage(String errorMessage) { public void setErrorMessage(String errorMessage) {
@ -483,8 +483,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
return offerPayload.getMakerPaymentAccountId(); return offerPayload.getMakerPaymentAccountId();
} }
public String getOfferFeePaymentTxId() { public String getOfferFeeTxId() {
return offerPayload.getOfferFeePaymentTxId(); return offerPayload.getOfferFeeTxId();
} }
public String getVersionNr() { public String getVersionNr() {

View file

@ -120,7 +120,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
// Mutable property. Has to be set before offer is saved in P2P network as it changes the payload hash! // Mutable property. Has to be set before offer is saved in P2P network as it changes the payload hash!
@Setter @Setter
@Nullable @Nullable
private String offerFeePaymentTxId; private String offerFeeTxId;
@Nullable @Nullable
private final String countryCode; private final String countryCode;
@Nullable @Nullable
@ -170,7 +170,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
String counterCurrencyCode, String counterCurrencyCode,
String paymentMethodId, String paymentMethodId,
String makerPaymentAccountId, String makerPaymentAccountId,
@Nullable String offerFeePaymentTxId, @Nullable String offerFeeTxId,
@Nullable String countryCode, @Nullable String countryCode,
@Nullable List<String> acceptedCountryCodes, @Nullable List<String> acceptedCountryCodes,
@Nullable String bankId, @Nullable String bankId,
@ -213,7 +213,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
this.reserveTxKeyImages = reserveTxKeyImages; this.reserveTxKeyImages = reserveTxKeyImages;
this.marketPriceMarginPct = marketPriceMarginPct; this.marketPriceMarginPct = marketPriceMarginPct;
this.useMarketBasedPrice = useMarketBasedPrice; this.useMarketBasedPrice = useMarketBasedPrice;
this.offerFeePaymentTxId = offerFeePaymentTxId; this.offerFeeTxId = offerFeeTxId;
this.countryCode = countryCode; this.countryCode = countryCode;
this.acceptedCountryCodes = acceptedCountryCodes; this.acceptedCountryCodes = acceptedCountryCodes;
this.bankId = bankId; this.bankId = bankId;
@ -233,8 +233,8 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
} }
public byte[] getHash() { public byte[] getHash() {
if (this.hash == null && this.offerFeePaymentTxId != null) { if (this.hash == null && this.offerFeeTxId != null) {
// A proto message can be created only after the offerFeePaymentTxId is // A proto message can be created only after the offerFeeTxId is
// set to a non-null value; now is the time to cache the payload hash. // set to a non-null value; now is the time to cache the payload hash.
this.hash = Hash.getSha256Hash(this.toProtoMessage().toByteArray()); this.hash = Hash.getSha256Hash(this.toProtoMessage().toByteArray());
} }
@ -295,7 +295,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
.setIsPrivateOffer(isPrivateOffer) .setIsPrivateOffer(isPrivateOffer)
.setProtocolVersion(protocolVersion); .setProtocolVersion(protocolVersion);
Optional.ofNullable(arbitratorSigner).ifPresent(e -> builder.setArbitratorSigner(arbitratorSigner.toProtoMessage())); Optional.ofNullable(arbitratorSigner).ifPresent(e -> builder.setArbitratorSigner(arbitratorSigner.toProtoMessage()));
Optional.ofNullable(offerFeePaymentTxId).ifPresent(builder::setOfferFeePaymentTxId); Optional.ofNullable(offerFeeTxId).ifPresent(builder::setOfferFeeTxId);
Optional.ofNullable(countryCode).ifPresent(builder::setCountryCode); Optional.ofNullable(countryCode).ifPresent(builder::setCountryCode);
Optional.ofNullable(bankId).ifPresent(builder::setBankId); Optional.ofNullable(bankId).ifPresent(builder::setBankId);
Optional.ofNullable(acceptedBankIds).ifPresent(builder::addAllAcceptedBankIds); Optional.ofNullable(acceptedBankIds).ifPresent(builder::addAllAcceptedBankIds);
@ -331,7 +331,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
proto.getCounterCurrencyCode(), proto.getCounterCurrencyCode(),
proto.getPaymentMethodId(), proto.getPaymentMethodId(),
proto.getMakerPaymentAccountId(), proto.getMakerPaymentAccountId(),
proto.getOfferFeePaymentTxId(), ProtoUtil.stringOrNullFromProto(proto.getOfferFeeTxId()),
ProtoUtil.stringOrNullFromProto(proto.getCountryCode()), ProtoUtil.stringOrNullFromProto(proto.getCountryCode()),
acceptedCountryCodes, acceptedCountryCodes,
ProtoUtil.stringOrNullFromProto(proto.getBankId()), ProtoUtil.stringOrNullFromProto(proto.getBankId()),
@ -380,7 +380,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
",\r\n reserveTxKeyImages=" + reserveTxKeyImages + ",\r\n reserveTxKeyImages=" + reserveTxKeyImages +
",\r\n marketPriceMargin=" + marketPriceMarginPct + ",\r\n marketPriceMargin=" + marketPriceMarginPct +
",\r\n useMarketBasedPrice=" + useMarketBasedPrice + ",\r\n useMarketBasedPrice=" + useMarketBasedPrice +
",\r\n offerFeePaymentTxId='" + offerFeePaymentTxId + '\'' + ",\r\n offerFeeTxId='" + offerFeeTxId + '\'' +
",\r\n countryCode='" + countryCode + '\'' + ",\r\n countryCode='" + countryCode + '\'' +
",\r\n acceptedCountryCodes=" + acceptedCountryCodes + ",\r\n acceptedCountryCodes=" + acceptedCountryCodes +
",\r\n bankId='" + bankId + '\'' + ",\r\n bankId='" + bankId + '\'' +
@ -422,7 +422,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
object.add("counterCurrencyCode", context.serialize(offerPayload.getCounterCurrencyCode())); object.add("counterCurrencyCode", context.serialize(offerPayload.getCounterCurrencyCode()));
object.add("paymentMethodId", context.serialize(offerPayload.getPaymentMethodId())); object.add("paymentMethodId", context.serialize(offerPayload.getPaymentMethodId()));
object.add("makerPaymentAccountId", context.serialize(offerPayload.getMakerPaymentAccountId())); object.add("makerPaymentAccountId", context.serialize(offerPayload.getMakerPaymentAccountId()));
object.add("offerFeePaymentTxId", context.serialize(offerPayload.getOfferFeePaymentTxId())); object.add("offerFeeTxId", context.serialize(offerPayload.getOfferFeeTxId()));
object.add("versionNr", context.serialize(offerPayload.getVersionNr())); object.add("versionNr", context.serialize(offerPayload.getVersionNr()));
object.add("blockHeightAtOfferCreation", context.serialize(offerPayload.getBlockHeightAtOfferCreation())); object.add("blockHeightAtOfferCreation", context.serialize(offerPayload.getBlockHeightAtOfferCreation()));
object.add("makerFee", context.serialize(offerPayload.getMakerFee())); object.add("makerFee", context.serialize(offerPayload.getMakerFee()));

View file

@ -248,12 +248,12 @@ public class OfferUtil {
} }
public static Optional<String> getInvalidMakerFeeTxErrorMessage(Offer offer, BtcWalletService btcWalletService) { public static Optional<String> getInvalidMakerFeeTxErrorMessage(Offer offer, BtcWalletService btcWalletService) {
String offerFeePaymentTxId = offer.getOfferFeePaymentTxId(); String offerFeeTxId = offer.getOfferFeeTxId();
if (offerFeePaymentTxId == null) { if (offerFeeTxId == null) {
return Optional.empty(); return Optional.empty();
} }
Transaction makerFeeTx = btcWalletService.getTransaction(offerFeePaymentTxId); Transaction makerFeeTx = btcWalletService.getTransaction(offerFeeTxId);
if (makerFeeTx == null) { if (makerFeeTx == null) {
return Optional.empty(); return Optional.empty();
} }

View file

@ -1322,7 +1322,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
originalOfferPayload.getCounterCurrencyCode(), originalOfferPayload.getCounterCurrencyCode(),
originalOfferPayload.getPaymentMethodId(), originalOfferPayload.getPaymentMethodId(),
originalOfferPayload.getMakerPaymentAccountId(), originalOfferPayload.getMakerPaymentAccountId(),
originalOfferPayload.getOfferFeePaymentTxId(), originalOfferPayload.getOfferFeeTxId(),
originalOfferPayload.getCountryCode(), originalOfferPayload.getCountryCode(),
originalOfferPayload.getAcceptedCountryCodes(), originalOfferPayload.getAcceptedCountryCodes(),
originalOfferPayload.getBankId(), originalOfferPayload.getBankId(),

View file

@ -65,7 +65,6 @@ public class MakerReserveOfferFunds extends Task<PlaceOfferModel> {
// save offer state // save offer state
model.setReserveTx(reserveTx); model.setReserveTx(reserveTx);
offer.getOfferPayload().setReserveTxKeyImages(reservedKeyImages); offer.getOfferPayload().setReserveTxKeyImages(reservedKeyImages);
offer.setOfferFeePaymentTxId(reserveTx.getHash()); // TODO (woodser): don't use this field
complete(); complete();
} catch (Throwable t) { } catch (Throwable t) {
offer.setErrorMessage("An error occurred.\n" + offer.setErrorMessage("An error occurred.\n" +

View file

@ -80,7 +80,7 @@ public class MempoolService {
} }
public void validateOfferMakerTx(OfferPayload offerPayload, Consumer<TxValidator> resultHandler) { public void validateOfferMakerTx(OfferPayload offerPayload, Consumer<TxValidator> resultHandler) {
validateOfferMakerTx(new TxValidator( offerPayload.getOfferFeePaymentTxId(), Coin.valueOf(offerPayload.getAmount())), resultHandler); validateOfferMakerTx(new TxValidator( offerPayload.getOfferFeeTxId(), Coin.valueOf(offerPayload.getAmount())), resultHandler);
} }
public void validateOfferMakerTx(TxValidator txValidator, Consumer<TxValidator> resultHandler) { public void validateOfferMakerTx(TxValidator txValidator, Consumer<TxValidator> resultHandler) {

View file

@ -67,9 +67,6 @@ public final class Contract implements NetworkPayload {
private final String makerDepositTxHash; private final String makerDepositTxHash;
private final String takerDepositTxHash; private final String takerDepositTxHash;
// Added in v1.2.0
private long lockTime;
public Contract(OfferPayload offerPayload, public Contract(OfferPayload offerPayload,
long tradeAmount, long tradeAmount,
long tradePrice, long tradePrice,
@ -87,7 +84,6 @@ public final class Contract implements NetworkPayload {
PubKeyRing takerPubKeyRing, PubKeyRing takerPubKeyRing,
String makerPayoutAddressString, String makerPayoutAddressString,
String takerPayoutAddressString, String takerPayoutAddressString,
long lockTime,
String makerDepositTxHash, String makerDepositTxHash,
String takerDepositTxHash) { String takerDepositTxHash) {
this.offerPayload = offerPayload; this.offerPayload = offerPayload;
@ -107,7 +103,6 @@ public final class Contract implements NetworkPayload {
this.takerPubKeyRing = takerPubKeyRing; this.takerPubKeyRing = takerPubKeyRing;
this.makerPayoutAddressString = makerPayoutAddressString; this.makerPayoutAddressString = makerPayoutAddressString;
this.takerPayoutAddressString = takerPayoutAddressString; this.takerPayoutAddressString = takerPayoutAddressString;
this.lockTime = lockTime;
this.makerDepositTxHash = makerDepositTxHash; this.makerDepositTxHash = makerDepositTxHash;
this.takerDepositTxHash = takerDepositTxHash; this.takerDepositTxHash = takerDepositTxHash;
@ -143,7 +138,6 @@ public final class Contract implements NetworkPayload {
PubKeyRing.fromProto(proto.getTakerPubKeyRing()), PubKeyRing.fromProto(proto.getTakerPubKeyRing()),
proto.getMakerPayoutAddressString(), proto.getMakerPayoutAddressString(),
proto.getTakerPayoutAddressString(), proto.getTakerPayoutAddressString(),
proto.getLockTime(),
proto.getMakerDepositTxHash(), proto.getMakerDepositTxHash(),
proto.getTakerDepositTxHash()); proto.getTakerDepositTxHash());
} }
@ -168,7 +162,6 @@ public final class Contract implements NetworkPayload {
.setTakerPubKeyRing(takerPubKeyRing.toProtoMessage()) .setTakerPubKeyRing(takerPubKeyRing.toProtoMessage())
.setMakerPayoutAddressString(makerPayoutAddressString) .setMakerPayoutAddressString(makerPayoutAddressString)
.setTakerPayoutAddressString(takerPayoutAddressString) .setTakerPayoutAddressString(takerPayoutAddressString)
.setLockTime(lockTime)
.setMakerDepositTxHash(makerDepositTxHash) .setMakerDepositTxHash(makerDepositTxHash)
.setTakerDepositTxHash(takerDepositTxHash) .setTakerDepositTxHash(takerDepositTxHash)
.build(); .build();
@ -303,7 +296,6 @@ public final class Contract implements NetworkPayload {
",\n takerPubKeyRing=" + takerPubKeyRing + ",\n takerPubKeyRing=" + takerPubKeyRing +
",\n makerPayoutAddressString='" + makerPayoutAddressString + '\'' + ",\n makerPayoutAddressString='" + makerPayoutAddressString + '\'' +
",\n takerPayoutAddressString='" + takerPayoutAddressString + '\'' + ",\n takerPayoutAddressString='" + takerPayoutAddressString + '\'' +
",\n lockTime=" + lockTime +
",\n makerDepositTxHash='" + makerDepositTxHash + '\'' + ",\n makerDepositTxHash='" + makerDepositTxHash + '\'' +
",\n takerDepositTxHash='" + takerDepositTxHash + '\'' + ",\n takerDepositTxHash='" + takerDepositTxHash + '\'' +
"\n}"; "\n}";

View file

@ -866,7 +866,6 @@ public abstract class Trade implements Tradable, Model {
getTaker().getPubKeyRing(), getTaker().getPubKeyRing(),
this instanceof MakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getMaker().getPayoutAddressString(), // maker payout address 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 this instanceof TakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getTaker().getPayoutAddressString(), // taker payout address
getLockTime(),
getMaker().getDepositTxHash(), getMaker().getDepositTxHash(),
getTaker().getDepositTxHash() getTaker().getDepositTxHash()
); );
@ -1594,9 +1593,7 @@ public abstract class Trade implements Tradable, Model {
} }
public boolean isTxChainInvalid() { public boolean isTxChainInvalid() {
return offer.getOfferFeePaymentTxId() == null || return processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null;
processModel.getMaker().getDepositTxHash() == null ||
processModel.getTaker().getDepositTxHash() == null;
} }
/** /**

View file

@ -25,14 +25,12 @@ import haveno.common.proto.persistable.PersistablePayload;
import haveno.core.account.witness.AccountAgeWitness; import haveno.core.account.witness.AccountAgeWitness;
import haveno.core.payment.payload.PaymentAccountPayload; import haveno.core.payment.payload.PaymentAccountPayload;
import haveno.core.proto.CoreProtoResolver; import haveno.core.proto.CoreProtoResolver;
import haveno.core.xmr.model.RawTransactionInput;
import haveno.network.p2p.NodeAddress; import haveno.network.p2p.NodeAddress;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -82,15 +80,6 @@ public final class TradePeer implements PersistablePayload {
private String contractAsJson; private String contractAsJson;
@Nullable @Nullable
private String contractSignature; private String contractSignature;
@Nullable
private byte[] signature;
@Nullable
private byte[] multiSigPubKey;
@Nullable
private List<RawTransactionInput> rawTransactionInputs;
private long changeOutputValue;
@Nullable
private String changeOutputAddress;
// added in v 0.6 // added in v 0.6
@Nullable @Nullable
@ -145,8 +134,7 @@ public final class TradePeer implements PersistablePayload {
@Override @Override
public Message toProtoMessage() { public Message toProtoMessage() {
final protobuf.TradePeer.Builder builder = protobuf.TradePeer.newBuilder() final protobuf.TradePeer.Builder builder = protobuf.TradePeer.newBuilder();
.setChangeOutputValue(changeOutputValue);
Optional.ofNullable(nodeAddress).ifPresent(e -> builder.setNodeAddress(nodeAddress.toProtoMessage())); Optional.ofNullable(nodeAddress).ifPresent(e -> builder.setNodeAddress(nodeAddress.toProtoMessage()));
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(pubKeyRing.toProtoMessage())); Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(pubKeyRing.toProtoMessage()));
Optional.ofNullable(accountId).ifPresent(builder::setAccountId); Optional.ofNullable(accountId).ifPresent(builder::setAccountId);
@ -159,11 +147,7 @@ public final class TradePeer implements PersistablePayload {
Optional.ofNullable(payoutAddressString).ifPresent(builder::setPayoutAddressString); Optional.ofNullable(payoutAddressString).ifPresent(builder::setPayoutAddressString);
Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson); Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson);
Optional.ofNullable(contractSignature).ifPresent(builder::setContractSignature); Optional.ofNullable(contractSignature).ifPresent(builder::setContractSignature);
Optional.ofNullable(signature).ifPresent(e -> builder.setSignature(ByteString.copyFrom(e)));
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(e.toProtoMessage())); Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(e.toProtoMessage()));
Optional.ofNullable(multiSigPubKey).ifPresent(e -> builder.setMultiSigPubKey(ByteString.copyFrom(e)));
Optional.ofNullable(rawTransactionInputs).ifPresent(e -> builder.addAllRawTransactionInputs(ProtoUtil.collectionToProto(e, protobuf.RawTransactionInput.class)));
Optional.ofNullable(changeOutputAddress).ifPresent(builder::setChangeOutputAddress);
Optional.ofNullable(accountAgeWitnessNonce).ifPresent(e -> builder.setAccountAgeWitnessNonce(ByteString.copyFrom(e))); Optional.ofNullable(accountAgeWitnessNonce).ifPresent(e -> builder.setAccountAgeWitnessNonce(ByteString.copyFrom(e)));
Optional.ofNullable(accountAgeWitnessSignature).ifPresent(e -> builder.setAccountAgeWitnessSignature(ByteString.copyFrom(e))); Optional.ofNullable(accountAgeWitnessSignature).ifPresent(e -> builder.setAccountAgeWitnessSignature(ByteString.copyFrom(e)));
Optional.ofNullable(accountAgeWitness).ifPresent(e -> builder.setAccountAgeWitness(accountAgeWitness.toProtoAccountAgeWitness())); Optional.ofNullable(accountAgeWitness).ifPresent(e -> builder.setAccountAgeWitness(accountAgeWitness.toProtoAccountAgeWitness()));
@ -192,7 +176,6 @@ public final class TradePeer implements PersistablePayload {
TradePeer tradePeer = new TradePeer(); TradePeer tradePeer = new TradePeer();
tradePeer.setNodeAddress(proto.hasNodeAddress() ? NodeAddress.fromProto(proto.getNodeAddress()) : null); tradePeer.setNodeAddress(proto.hasNodeAddress() ? NodeAddress.fromProto(proto.getNodeAddress()) : null);
tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null); tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null);
tradePeer.setChangeOutputValue(proto.getChangeOutputValue());
tradePeer.setAccountId(ProtoUtil.stringOrNullFromProto(proto.getAccountId())); tradePeer.setAccountId(ProtoUtil.stringOrNullFromProto(proto.getAccountId()));
tradePeer.setPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getPaymentAccountId())); tradePeer.setPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getPaymentAccountId()));
tradePeer.setPaymentMethodId(ProtoUtil.stringOrNullFromProto(proto.getPaymentMethodId())); tradePeer.setPaymentMethodId(ProtoUtil.stringOrNullFromProto(proto.getPaymentMethodId()));
@ -203,16 +186,7 @@ public final class TradePeer implements PersistablePayload {
tradePeer.setPayoutAddressString(ProtoUtil.stringOrNullFromProto(proto.getPayoutAddressString())); tradePeer.setPayoutAddressString(ProtoUtil.stringOrNullFromProto(proto.getPayoutAddressString()));
tradePeer.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson())); tradePeer.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson()));
tradePeer.setContractSignature(ProtoUtil.stringOrNullFromProto(proto.getContractSignature())); tradePeer.setContractSignature(ProtoUtil.stringOrNullFromProto(proto.getContractSignature()));
tradePeer.setSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getSignature()));
tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null); tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null);
tradePeer.setMultiSigPubKey(ProtoUtil.byteArrayOrNullFromProto(proto.getMultiSigPubKey()));
List<RawTransactionInput> rawTransactionInputs = proto.getRawTransactionInputsList().isEmpty() ?
null :
proto.getRawTransactionInputsList().stream()
.map(RawTransactionInput::fromProto)
.collect(Collectors.toList());
tradePeer.setRawTransactionInputs(rawTransactionInputs);
tradePeer.setChangeOutputAddress(ProtoUtil.stringOrNullFromProto(proto.getChangeOutputAddress()));
tradePeer.setAccountAgeWitnessNonce(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessNonce())); tradePeer.setAccountAgeWitnessNonce(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessNonce()));
tradePeer.setAccountAgeWitnessSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessSignature())); tradePeer.setAccountAgeWitnessSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessSignature()));
protobuf.AccountAgeWitness protoAccountAgeWitness = proto.getAccountAgeWitness(); protobuf.AccountAgeWitness protoAccountAgeWitness = proto.getAccountAgeWitness();

View file

@ -91,8 +91,10 @@ public class TradeStatisticsManager {
if (!tradeStatistics.isValid()) { if (!tradeStatistics.isValid()) {
return; return;
} }
synchronized (observableTradeStatisticsSet) {
observableTradeStatisticsSet.add(tradeStatistics); observableTradeStatisticsSet.add(tradeStatistics);
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet); priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
}
maybeDumpStatistics(); maybeDumpStatistics();
} }
}); });
@ -102,8 +104,10 @@ public class TradeStatisticsManager {
.map(e -> (TradeStatistics3) e) .map(e -> (TradeStatistics3) e)
.filter(TradeStatistics3::isValid) .filter(TradeStatistics3::isValid)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
synchronized (observableTradeStatisticsSet) {
observableTradeStatisticsSet.addAll(set); observableTradeStatisticsSet.addAll(set);
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet); priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
}
maybeDumpStatistics(); maybeDumpStatistics();
} }

View file

@ -31,7 +31,7 @@ class TransactionAwareOpenOffer implements TransactionAwareTradable {
public boolean isRelatedToTransaction(MoneroTxWallet transaction) { public boolean isRelatedToTransaction(MoneroTxWallet transaction) {
Offer offer = delegate.getOffer(); Offer offer = delegate.getOffer();
String paymentTxId = offer.getOfferFeePaymentTxId(); String paymentTxId = offer.getOfferFeeTxId();
String txId = transaction.getHash(); String txId = transaction.getHash();

View file

@ -91,7 +91,7 @@ class TransactionAwareTrade implements TransactionAwareTradable {
private boolean isOfferFeeTx(String txId) { private boolean isOfferFeeTx(String txId) {
return Optional.ofNullable(trade.getOffer()) return Optional.ofNullable(trade.getOffer())
.map(Offer::getOfferFeePaymentTxId) .map(Offer::getOfferFeeTxId)
.map(paymentTxId -> paymentTxId.equals(txId)) .map(paymentTxId -> paymentTxId.equals(txId))
.orElse(false); .orElse(false);
} }

View file

@ -116,8 +116,8 @@ class TransactionsListItem {
Trade trade = (Trade) tradable; Trade trade = (Trade) tradable;
Offer offer = trade.getOffer(); Offer offer = trade.getOffer();
String offerFeePaymentTxID = offer.getOfferFeePaymentTxId(); String offerFeeTxId = offer.getOfferFeeTxId();
if (offerFeePaymentTxID != null && offerFeePaymentTxID.equals(txId)) { if (offerFeeTxId != null && offerFeeTxId.equals(txId)) {
details = Res.get("funds.tx.createOfferFee", tradeId); details = Res.get("funds.tx.createOfferFee", tradeId);
} else if (trade.getSelf().getDepositTxHash() != null && } else if (trade.getSelf().getDepositTxHash() != null &&
trade.getSelf().getDepositTxHash().equals(txId)) { trade.getSelf().getDepositTxHash().equals(txId)) {

View file

@ -202,7 +202,7 @@ class TakeOfferDataModel extends OfferDataModel {
mempoolStatus.setValue(txValidator.isFail() ? 0 : 1); mempoolStatus.setValue(txValidator.isFail() ? 0 : 1);
if (txValidator.isFail()) { if (txValidator.isFail()) {
mempoolStatusText = txValidator.toString(); mempoolStatusText = txValidator.toString();
log.info("Mempool check of OfferFeePaymentTxId returned errors: [{}]", mempoolStatusText); log.info("Mempool check of OfferFeeTxId returned errors: [{}]", mempoolStatusText);
} }
})); }));

View file

@ -192,7 +192,7 @@ class EditOfferDataModel extends MutableOfferDataModel {
newOfferPayload.getCounterCurrencyCode(), newOfferPayload.getCounterCurrencyCode(),
newOfferPayload.getPaymentMethodId(), newOfferPayload.getPaymentMethodId(),
newOfferPayload.getMakerPaymentAccountId(), newOfferPayload.getMakerPaymentAccountId(),
offerPayload.getOfferFeePaymentTxId(), offerPayload.getOfferFeeTxId(),
newOfferPayload.getCountryCode(), newOfferPayload.getCountryCode(),
newOfferPayload.getAcceptedCountryCodes(), newOfferPayload.getAcceptedCountryCodes(),
newOfferPayload.getBankId(), newOfferPayload.getBankId(),

View file

@ -325,7 +325,7 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
if (model.getDirectionLabel(item).contains(filterString)) { if (model.getDirectionLabel(item).contains(filterString)) {
return true; return true;
} }
if (offer.getOfferFeePaymentTxId().contains(filterString)) { if (offer.getOfferFeeTxId() != null && offer.getOfferFeeTxId().contains(filterString)) {
return true; return true;
} }

View file

@ -344,7 +344,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
if (model.getDirectionLabel(item).contains(filterString)) { if (model.getDirectionLabel(item).contains(filterString)) {
return true; return true;
} }
if (offer.getOfferFeePaymentTxId().contains(filterString)) { if (offer.getOfferFeeTxId() != null && offer.getOfferFeeTxId().contains(filterString)) {
return true; return true;
} }
return false; return false;

View file

@ -18,7 +18,6 @@
package haveno.desktop.util.filtering; package haveno.desktop.util.filtering;
import haveno.core.offer.Offer; import haveno.core.offer.Offer;
import haveno.core.trade.Contract;
import haveno.core.trade.Trade; import haveno.core.trade.Trade;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -30,7 +29,7 @@ public class FilteringUtils {
if (StringUtils.containsIgnoreCase(offer.getPaymentMethod().getDisplayString(), filterString)) { if (StringUtils.containsIgnoreCase(offer.getPaymentMethod().getDisplayString(), filterString)) {
return true; return true;
} }
return offer.getOfferFeePaymentTxId() != null && StringUtils.containsIgnoreCase(offer.getOfferFeePaymentTxId(), filterString); return offer.getOfferFeeTxId() != null && StringUtils.containsIgnoreCase(offer.getOfferFeeTxId(), filterString);
} }
public static boolean match(Trade trade, String filterString) { public static boolean match(Trade trade, String filterString) {

View file

@ -82,7 +82,7 @@ public class TransactionAwareTradeTest {
@Test @Test
public void testIsRelatedToTransactionWhenOfferFeeTx() { public void testIsRelatedToTransactionWhenOfferFeeTx() {
when(delegate.getOffer().getOfferFeePaymentTxId()).thenReturn(XID.toString()); when(delegate.getOffer().getOfferFeeTxId()).thenReturn(XID.toString());
assertTrue(trade.isRelatedToTransaction(transaction)); assertTrue(trade.isRelatedToTransaction(transaction));
} }

View file

@ -45,7 +45,7 @@ public class OfferMaker {
public static final Property<Offer, String> id = newProperty(); public static final Property<Offer, String> id = newProperty();
public static final Property<Offer, String> paymentMethodId = newProperty(); public static final Property<Offer, String> paymentMethodId = newProperty();
public static final Property<Offer, String> paymentAccountId = newProperty(); public static final Property<Offer, String> paymentAccountId = newProperty();
public static final Property<Offer, String> offerFeePaymentTxId = newProperty(); public static final Property<Offer, String> offerFeeTxId = newProperty();
public static final Property<Offer, String> countryCode = newProperty(); public static final Property<Offer, String> countryCode = newProperty();
public static final Property<Offer, List<String>> countryCodes = newProperty(); public static final Property<Offer, List<String>> countryCodes = newProperty();
public static final Property<Offer, Long> date = newProperty(); public static final Property<Offer, Long> date = newProperty();
@ -86,7 +86,7 @@ public class OfferMaker {
lookup.valueOf(counterCurrencyCode, "USD"), lookup.valueOf(counterCurrencyCode, "USD"),
lookup.valueOf(paymentMethodId, "SEPA"), lookup.valueOf(paymentMethodId, "SEPA"),
lookup.valueOf(paymentAccountId, "00002c4d-1ffc-4208-8ff3-e669817b0000"), lookup.valueOf(paymentAccountId, "00002c4d-1ffc-4208-8ff3-e669817b0000"),
lookup.valueOf(offerFeePaymentTxId, "0000dcd1d388b95714c96ce13f5cb000090c41a1faf89e4ce7680938cc170000"), lookup.valueOf(offerFeeTxId, "0000dcd1d388b95714c96ce13f5cb000090c41a1faf89e4ce7680938cc170000"),
lookup.valueOf(countryCode, "FR"), lookup.valueOf(countryCode, "FR"),
lookup.valueOf(countryCodes, new ArrayList<>() {{ lookup.valueOf(countryCodes, new ArrayList<>() {{
add("FR"); add("FR");

View file

@ -532,7 +532,7 @@ message OfferInfo {
uint64 date = 17; uint64 date = 17;
string state = 18; string state = 18;
uint64 seller_security_deposit = 19 [jstype = JS_STRING]; uint64 seller_security_deposit = 19 [jstype = JS_STRING];
string offer_fee_payment_tx_id = 20; string offer_fee_tx_id = 20;
uint64 maker_fee = 22 [jstype = JS_STRING]; uint64 maker_fee = 22 [jstype = JS_STRING];
bool is_activated = 23; bool is_activated = 23;
bool is_my_offer = 24; bool is_my_offer = 24;

View file

@ -614,7 +614,7 @@ message OfferPayload {
string counter_currency_code = 12; string counter_currency_code = 12;
string payment_method_id = 13; string payment_method_id = 13;
string maker_payment_account_id = 14; string maker_payment_account_id = 14;
string offer_fee_payment_tx_id = 15; string offer_fee_tx_id = 15;
string country_code = 16; string country_code = 16;
repeated string accepted_country_codes = 17; repeated string accepted_country_codes = 17;
string bank_id = 18; string bank_id = 18;
@ -784,7 +784,6 @@ message Contract {
string taker_payout_address_string = 17; string taker_payout_address_string = 17;
string maker_deposit_tx_hash = 18; string maker_deposit_tx_hash = 18;
string taker_deposit_tx_hash = 19; string taker_deposit_tx_hash = 19;
int64 lock_time = 20;
} }
message RawTransactionInput { message RawTransactionInput {
@ -1558,11 +1557,6 @@ message TradePeer {
string payout_address_string = 10; string payout_address_string = 10;
string contract_as_json = 11; string contract_as_json = 11;
string contract_signature = 12; 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_nonce = 18;
bytes account_age_witness_signature = 19; bytes account_age_witness_signature = 19;
AccountAgeWitness account_age_witness = 20; AccountAgeWitness account_age_witness = 20;