From 767f4cf8c0bc910be591efa07bae2dea5ae11d09 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 2 Oct 2022 14:45:29 -0400 Subject: [PATCH] reset address entries of taker's offer model when done fixes the "outdated addressEntry" warning --- .../main/java/bisq/core/offer/OpenOfferManager.java | 1 + .../bisq/core/trade/protocol/BuyerAsTakerProtocol.java | 6 ++++++ .../core/trade/protocol/SellerAsTakerProtocol.java | 6 ++++++ .../java/bisq/core/trade/protocol/TradeProtocol.java | 4 ++-- .../{MakerRemoveOpenOffer.java => RemoveOffer.java} | 10 ++++++---- .../main/java/bisq/desktop/main/debug/DebugView.java | 6 +++--- .../main/offer/takeoffer/TakeOfferDataModel.java | 2 +- .../portfolio/pendingtrades/PendingTradesView.java | 4 ++-- 8 files changed, 27 insertions(+), 12 deletions(-) rename core/src/main/java/bisq/core/trade/protocol/tasks/{MakerRemoveOpenOffer.java => RemoveOffer.java} (85%) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 99bda59a..c79b3ed4 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -579,6 +579,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe getOpenOfferById(offer.getId()).ifPresent(openOffer -> { openOffers.remove(openOffer); openOffer.setState(OpenOffer.State.CLOSED); + xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); offerBookService.removeOffer(openOffer.getOffer().getOfferPayload(), () -> log.info("Successfully removed offer {}", offer.getId()), log::error); diff --git a/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java index 240e5c24..371cdaf4 100644 --- a/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/BuyerAsTakerProtocol.java @@ -145,4 +145,10 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); } + + @Override + protected void handleError(String errorMessage) { + trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId()); + super.handleError(errorMessage); + } } diff --git a/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java b/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java index 24435518..31312165 100644 --- a/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/SellerAsTakerProtocol.java @@ -138,4 +138,10 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc protected void onTradeMessage(TradeMessage message, NodeAddress peer) { super.onTradeMessage(message, peer); } + + @Override + protected void handleError(String errorMessage) { + trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId()); + super.handleError(errorMessage); + } } diff --git a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java index f4d35838..5fe4ca92 100644 --- a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java @@ -29,7 +29,7 @@ import bisq.core.trade.messages.SignContractRequest; import bisq.core.trade.messages.SignContractResponse; import bisq.core.trade.messages.TradeMessage; import bisq.core.trade.messages.UpdateMultisigRequest; -import bisq.core.trade.protocol.tasks.MakerRemoveOpenOffer; +import bisq.core.trade.protocol.tasks.RemoveOffer; import bisq.core.trade.protocol.tasks.MaybeSendSignContractRequest; import bisq.core.trade.protocol.tasks.ProcessDepositResponse; import bisq.core.trade.protocol.tasks.ProcessInitMultisigRequest; @@ -306,7 +306,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D .setup(tasks( // TODO (woodser): validate request ProcessSignContractResponse.class, - MakerRemoveOpenOffer.class) + RemoveOffer.class) .using(new TradeTaskRunner(trade, () -> { startTimeout(TRADE_TIMEOUT); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/MakerRemoveOpenOffer.java b/core/src/main/java/bisq/core/trade/protocol/tasks/RemoveOffer.java similarity index 85% rename from core/src/main/java/bisq/core/trade/protocol/tasks/MakerRemoveOpenOffer.java rename to core/src/main/java/bisq/core/trade/protocol/tasks/RemoveOffer.java index 784eea02..21e74c2d 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/MakerRemoveOpenOffer.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/RemoveOffer.java @@ -26,8 +26,8 @@ import lombok.extern.slf4j.Slf4j; import static com.google.common.base.Preconditions.checkNotNull; @Slf4j -public class MakerRemoveOpenOffer extends TradeTask { - public MakerRemoveOpenOffer(TaskRunner taskHandler, Trade trade) { +public class RemoveOffer extends TradeTask { + public RemoveOffer(TaskRunner taskHandler, Trade trade) { super(taskHandler, trade); } @@ -35,9 +35,11 @@ public class MakerRemoveOpenOffer extends TradeTask { protected void run() { try { runInterceptHook(); - + if (trade instanceof MakerTrade) { processModel.getOpenOfferManager().closeOpenOffer(checkNotNull(trade.getOffer())); + } else { + trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId()); } complete(); @@ -45,4 +47,4 @@ public class MakerRemoveOpenOffer extends TradeTask { failed(t); } } -} +} \ No newline at end of file diff --git a/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java b/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java index 76f71712..718a7219 100644 --- a/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java +++ b/desktop/src/main/java/bisq/desktop/main/debug/DebugView.java @@ -31,7 +31,7 @@ import bisq.core.trade.protocol.tasks.BuyerPreparePaymentSentMessage; import bisq.core.trade.protocol.tasks.BuyerProcessPaymentReceivedMessage; import bisq.core.trade.protocol.tasks.BuyerSendPaymentSentMessage; import bisq.core.trade.protocol.tasks.MakerSetLockTime; -import bisq.core.trade.protocol.tasks.MakerRemoveOpenOffer; +import bisq.core.trade.protocol.tasks.RemoveOffer; import bisq.core.trade.protocol.tasks.SellerPreparePaymentReceivedMessage; import bisq.core.trade.protocol.tasks.SellerProcessPaymentSentMessage; import bisq.core.trade.protocol.tasks.SellerPublishDepositTx; @@ -119,7 +119,7 @@ public class DebugView extends InitializableView { VerifyPeersAccountAgeWitness.class, MakerSetLockTime.class, - MakerRemoveOpenOffer.class, + RemoveOffer.class, ApplyFilter.class, BuyerPreparePaymentSentMessage.class, @@ -154,7 +154,7 @@ public class DebugView extends InitializableView { MakerSetLockTime.class, //SellerAsMakerProcessDepositTxMessage.class, - MakerRemoveOpenOffer.class, + RemoveOffer.class, //SellerSendsDepositTxAndDelayedPayoutTxMessage.class, SellerPublishDepositTx.class, diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java index 0c6a4d41..e8722ad0 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java @@ -292,7 +292,7 @@ class TakeOfferDataModel extends OfferDataModel { offerBook.removeOffer(checkNotNull(offer)); } - //xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); // TODO (woodser): this removes address entries for reserved trades before completion. how doesn't this delete the multisig address entry in bisq before completion? + xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId()); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java index 2571ba4e..3b4216c2 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -849,10 +849,10 @@ public class PendingTradesView extends ActivatableViewAndModel