Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update offer address to new hidden service files #4021

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions core/src/main/java/bisq/core/offer/OpenOfferManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -732,25 +732,46 @@ 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())) {

Map<String, String> originalExtraDataMap = originalOfferPayload.getExtraDataMap();
// - Capabilities changed?
// We rewrite our offer with the additional capabilities entry
Map<String, String> updatedExtraDataMap = new HashMap<>();
if (!OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.MEDIATION) ||
!OfferRestrictions.hasOfferMandatoryCapability(originalOffer, Capability.REFUND_AGENT)) {
Map<String, String> 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());

log.info("Converted offer to support new Capability.MEDIATION and Capability.REFUND_AGENT capability. id={}", originalOffer.getId());
} else {
updatedExtraDataMap = originalOfferPayload.getExtraDataMap();
}

// We overwrite any entry with our current capabilities
updatedExtraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList());
// - 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());
}

// We update the trade protocol version
int protocolVersion = Version.TRADE_PROTOCOL_VERSION;
// - 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(),
Expand Down Expand Up @@ -807,7 +828,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());
}
});
}
Expand Down