reset address entries of taker's offer model when done

fixes the "outdated addressEntry" warning
This commit is contained in:
woodser 2022-10-02 14:45:29 -04:00
parent 139896bced
commit 767f4cf8c0
8 changed files with 27 additions and 12 deletions

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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<Trade> taskHandler, Trade trade) {
public class RemoveOffer extends TradeTask {
public RemoveOffer(TaskRunner<Trade> 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);
}
}
}
}

View file

@ -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<GridPane, Void> {
VerifyPeersAccountAgeWitness.class,
MakerSetLockTime.class,
MakerRemoveOpenOffer.class,
RemoveOffer.class,
ApplyFilter.class,
BuyerPreparePaymentSentMessage.class,
@ -154,7 +154,7 @@ public class DebugView extends InitializableView<GridPane, Void> {
MakerSetLockTime.class,
//SellerAsMakerProcessDepositTxMessage.class,
MakerRemoveOpenOffer.class,
RemoveOffer.class,
//SellerSendsDepositTxAndDelayedPayoutTxMessage.class,
SellerPublishDepositTx.class,

View file

@ -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());
}

View file

@ -849,10 +849,10 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
super.updateItem(newItem, empty);
if (!empty && newItem != null) {
final Trade trade = newItem.getTrade();
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeer().getNodeAddress();
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeer() == null ? null : trade.getTradingPeer().getNodeAddress();
int numPastTrades = model.getNumPastTrades(trade);
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress,
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress, // TODO: display maker and taker node addresses for arbitrator
role,
numPastTrades,
privateNotificationManager,