do not reset offer address entries on error from desktop ui form

This commit is contained in:
woodser 2024-10-02 08:19:02 -04:00
parent 047f1a1c1f
commit 5c0f49d58f
3 changed files with 10 additions and 3 deletions

View file

@ -284,6 +284,7 @@ public class CoreOffersService {
useSavingsWallet, useSavingsWallet,
triggerPriceAsLong, triggerPriceAsLong,
reserveExactAmount, reserveExactAmount,
true,
resultHandler::accept, resultHandler::accept,
errorMessageHandler); errorMessageHandler);
} }

View file

@ -541,6 +541,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
boolean useSavingsWallet, boolean useSavingsWallet,
long triggerPrice, long triggerPrice,
boolean reserveExactAmount, boolean reserveExactAmount,
boolean resetAddressEntriesOnError,
TransactionResultHandler resultHandler, TransactionResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
@ -559,7 +560,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
}, (errorMessage) -> { }, (errorMessage) -> {
if (!openOffer.isCanceled()) { if (!openOffer.isCanceled()) {
log.warn("Error processing pending offer {}: {}", openOffer.getId(), errorMessage); log.warn("Error processing pending offer {}: {}", openOffer.getId(), errorMessage);
doCancelOffer(openOffer); doCancelOffer(openOffer, resetAddressEntriesOnError);
} }
latch.countDown(); latch.countDown();
errorMessageHandler.handleErrorMessage(errorMessage); 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 // 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 offer = openOffer.getOffer();
offer.setState(Offer.State.REMOVED); offer.setState(Offer.State.REMOVED);
openOffer.setState(OpenOffer.State.CANCELED); openOffer.setState(OpenOffer.State.CANCELED);
removeOpenOffer(openOffer); removeOpenOffer(openOffer);
closedTradableManager.add(openOffer); // TODO: don't add these to closed tradables? closedTradableManager.add(openOffer); // TODO: don't add these to closed tradables?
xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); if (resetAddressEntries) xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId());
requestPersistence(); requestPersistence();
xmrWalletService.thawOutputs(offer.getOfferPayload().getReserveTxKeyImages()); xmrWalletService.thawOutputs(offer.getOfferPayload().getReserveTxKeyImages());
} }

View file

@ -296,6 +296,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
useSavingsWallet, useSavingsWallet,
triggerPrice, triggerPrice,
reserveExactAmount, reserveExactAmount,
false, // desktop ui resets address entries on cancel
resultHandler, resultHandler,
errorMessageHandler); errorMessageHandler);
} }