From 8abc52b25719cd5ef4add1a61accf3cc333dda0a Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 28 Feb 2020 11:02:26 +0100 Subject: [PATCH 1/3] Move protocol version update --- .../main/java/bisq/core/offer/OpenOfferManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 8407ae433ab..a8c4319db96 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -745,8 +745,13 @@ private void maybeUpdatePersistedOffers() { // We overwrite any entry with our current capabilities updatedExtraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList()); - // We update the trade protocol version - int protocolVersion = Version.TRADE_PROTOCOL_VERSION; + // - Protocol version changed? + int protocolVersion = originalOfferPayload.getProtocolVersion(); + if (protocolVersion < Version.TRADE_PROTOCOL_VERSION) { + // We update the trade protocol version + protocolVersion = Version.TRADE_PROTOCOL_VERSION; + log.info("Updated the protocol version of offer id={}", originalOffer.getId()); + } OfferPayload updatedPayload = new OfferPayload(originalOfferPayload.getId(), originalOfferPayload.getDate(), @@ -807,7 +812,7 @@ private void maybeUpdatePersistedOffers() { updatedOpenOffer.setStorage(openOfferTradableListStorage); openOffers.add(updatedOpenOffer); - log.info("Converted offer to support new Capability.MEDIATION and Capability.REFUND_AGENT capability. id={}", originalOffer.getId()); + log.info("Updating offer completed. id={}", originalOffer.getId()); } }); } From b8f0532dbaeeb06c17dcf386f3d409b3ffa446dd Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 28 Feb 2020 11:08:00 +0100 Subject: [PATCH 2/3] Move capabilities update --- .../bisq/core/offer/OpenOfferManager.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index a8c4319db96..8432ebbacbc 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -735,15 +735,24 @@ private void maybeUpdatePersistedOffers() { !OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.REFUND_AGENT)) { // We rewrite our offer with the additional capabilities entry - Map originalExtraDataMap = originalOfferPayload.getExtraDataMap(); + // - Capabilities changed? + // We rewrite our offer with the additional capabilities entry Map updatedExtraDataMap = new HashMap<>(); + if (!OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.MEDIATION) || + !OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.REFUND_AGENT)) { + Map originalExtraDataMap = originalOfferPayload.getExtraDataMap(); - if (originalExtraDataMap != null) { - updatedExtraDataMap.putAll(originalExtraDataMap); - } + if (originalExtraDataMap != null) { + updatedExtraDataMap.putAll(originalExtraDataMap); + } - // We overwrite any entry with our current capabilities - updatedExtraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList()); + // We overwrite any entry with our current capabilities + updatedExtraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList()); + + log.info("Converted offer to support new Capability.MEDIATION and Capability.REFUND_AGENT capability. id={}", originalOffer.getId()); + } else { + updatedExtraDataMap = originalOfferPayload.getExtraDataMap(); + } // - Protocol version changed? int protocolVersion = originalOfferPayload.getProtocolVersion(); From ff0d47377803c8f0ccf993cdf17756ed7e1b5931 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 28 Feb 2020 11:19:18 +0100 Subject: [PATCH 3/3] Added node address update --- .../main/java/bisq/core/offer/OpenOfferManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 8432ebbacbc..df5a04e774b 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -732,8 +732,8 @@ private void maybeUpdatePersistedOffers() { if (originalOfferPayload.getProtocolVersion() < Version.TRADE_PROTOCOL_VERSION || !OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.MEDIATION) || - !OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.REFUND_AGENT)) { - // We rewrite our offer with the additional capabilities entry + !OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.REFUND_AGENT) || + !originalOfferPayload.getOwnerNodeAddress().equals(p2PService.getAddress())) { // - Capabilities changed? // We rewrite our offer with the additional capabilities entry @@ -762,9 +762,16 @@ private void maybeUpdatePersistedOffers() { log.info("Updated the protocol version of offer id={}", originalOffer.getId()); } + // - node address changed? (due to a faulty tor dir) + NodeAddress ownerNodeAddress = originalOfferPayload.getOwnerNodeAddress(); + if (!ownerNodeAddress.equals(p2PService.getAddress())) { + ownerNodeAddress = p2PService.getAddress(); + log.info("Updated the owner nodeaddress of offer id={}", originalOffer.getId()); + } + OfferPayload updatedPayload = new OfferPayload(originalOfferPayload.getId(), originalOfferPayload.getDate(), - originalOfferPayload.getOwnerNodeAddress(), + ownerNodeAddress, originalOfferPayload.getPubKeyRing(), originalOfferPayload.getDirection(), originalOfferPayload.getPrice(),