From dffb676f4e7c87ad36f516563b49b7b2928e2af8 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 17 Dec 2023 07:38:48 -0500 Subject: [PATCH] reset address entries for open offer on error taking offer --- core/src/main/java/haveno/core/offer/OpenOfferManager.java | 3 ++- core/src/main/java/haveno/core/trade/TradeManager.java | 1 + .../haveno/core/trade/protocol/BuyerAsTakerProtocol.java | 6 ------ .../haveno/core/trade/protocol/SellerAsTakerProtocol.java | 6 ------ 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 66928a4721..5e8e42858e 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -1007,13 +1007,14 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe xmrWalletService.swapAddressEntryToAvailable(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING); // change funding subaddress in case funded with unsuitable output(s) XmrAddressEntry entry = xmrWalletService.getOrCreateAddressEntry(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING); log.info("Creating split output tx to fund offer {} at subaddress {}", openOffer.getId(), entry.getSubaddressIndex()); + long startTime = System.currentTimeMillis(); MoneroTxWallet splitOutputTx = xmrWalletService.getWallet().createTx(new MoneroTxConfig() .setAccountIndex(0) .setAddress(entry.getAddressString()) .setAmount(reserveAmount) .setRelay(true) .setPriority(XmrWalletService.PROTOCOL_FEE_PRIORITY)); - log.info("Done creating split output tx to fund offer {}", openOffer.getId()); + log.info("Done creating split output tx to fund offer {} in {} ms", openOffer.getId(), System.currentTimeMillis() - startTime); // schedule txs openOffer.setSplitOutputTxHash(splitOutputTx.getHash()); diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 1fc048a296..64598053ec 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -878,6 +878,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi requestPersistence(); }, errorMessage -> { log.warn("Taker error during trade initialization: " + errorMessage); + xmrWalletService.resetAddressEntriesForOpenOffer(trade.getId()); maybeRemoveTradeOnError(trade); errorMessageHandler.handleErrorMessage(errorMessage); if (takeOfferRequestErrorMessageHandler != null) takeOfferRequestErrorMessageHandler.handleErrorMessage(errorMessage); diff --git a/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java b/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java index 4d96d6ceb9..962fc6fb14 100644 --- a/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java @@ -73,10 +73,4 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol } }).start(); } - - @Override - protected void handleError(String errorMessage) { - trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId()); - super.handleError(errorMessage); - } } diff --git a/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java b/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java index cb42c51bfa..98bfa7e6ef 100644 --- a/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java @@ -74,10 +74,4 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc } }).start(); } - - @Override - protected void handleError(String errorMessage) { - trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId()); - super.handleError(errorMessage); - } }