From 5c0f49d58f055b64fa12c3755705a531456148ef Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 2 Oct 2024 08:19:02 -0400 Subject: [PATCH] do not reset offer address entries on error from desktop ui form --- .../main/java/haveno/core/api/CoreOffersService.java | 1 + .../main/java/haveno/core/offer/OpenOfferManager.java | 11 ++++++++--- .../desktop/main/offer/MutableOfferDataModel.java | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/haveno/core/api/CoreOffersService.java b/core/src/main/java/haveno/core/api/CoreOffersService.java index 7e67965c..5bdd2f16 100644 --- a/core/src/main/java/haveno/core/api/CoreOffersService.java +++ b/core/src/main/java/haveno/core/api/CoreOffersService.java @@ -284,6 +284,7 @@ public class CoreOffersService { useSavingsWallet, triggerPriceAsLong, reserveExactAmount, + true, resultHandler::accept, errorMessageHandler); } diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 4824579d..38ee71f6 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -541,6 +541,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe boolean useSavingsWallet, long triggerPrice, boolean reserveExactAmount, + boolean resetAddressEntriesOnError, TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { @@ -559,7 +560,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe }, (errorMessage) -> { if (!openOffer.isCanceled()) { log.warn("Error processing pending offer {}: {}", openOffer.getId(), errorMessage); - doCancelOffer(openOffer); + doCancelOffer(openOffer, resetAddressEntriesOnError); } latch.countDown(); errorMessageHandler.handleErrorMessage(errorMessage); @@ -715,14 +716,18 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } } + private void doCancelOffer(OpenOffer openOffer) { + doCancelOffer(openOffer, true); + } + // remove open offer which thaws its key images - private void doCancelOffer(@NotNull OpenOffer openOffer) { + private void doCancelOffer(@NotNull OpenOffer openOffer, boolean resetAddressEntries) { Offer offer = openOffer.getOffer(); offer.setState(Offer.State.REMOVED); openOffer.setState(OpenOffer.State.CANCELED); removeOpenOffer(openOffer); closedTradableManager.add(openOffer); // TODO: don't add these to closed tradables? - xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); + if (resetAddressEntries) xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); requestPersistence(); xmrWalletService.thawOutputs(offer.getOfferPayload().getReserveTxKeyImages()); } diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java index e6d1d9d4..d48a1d2e 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java @@ -296,6 +296,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel { useSavingsWallet, triggerPrice, reserveExactAmount, + false, // desktop ui resets address entries on cancel resultHandler, errorMessageHandler); }