diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index ddce8e97..b673b9c6 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -716,7 +716,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D // Timeout /////////////////////////////////////////////////////////////////////////////////////////// - protected synchronized void startTimeout(long timeoutSec) { + public synchronized void startTimeout(long timeoutSec) { synchronized (timeoutTimerLock) { stopTimeout(); timeoutTimer = UserThread.runAfter(() -> { diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java b/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java index 78daef51..a79cc046 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java @@ -20,6 +20,7 @@ package haveno.core.trade.protocol.tasks; import haveno.common.taskrunner.TaskRunner; import haveno.core.offer.OfferDirection; import haveno.core.trade.Trade; +import haveno.core.trade.protocol.TradeProtocol; import haveno.core.xmr.model.XmrAddressEntry; import monero.daemon.model.MoneroOutput; import monero.wallet.model.MoneroTxWallet; @@ -50,6 +51,15 @@ public class TakerReserveTradeFunds extends TradeTask { List reservedKeyImages = new ArrayList(); for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex()); + // check for error in case creating reserve tx exceeded timeout + // TODO: better way? + if (!model.getXmrWalletService().getAddressEntry(trade.getId(), XmrAddressEntry.Context.TRADE_PAYOUT).isPresent()) { + throw new RuntimeException("An error has occurred taking trade " + trade.getId() + " causing its subaddress entry to be deleted"); + } + + // extend protocol timeout + trade.getProtocol().startTimeout(TradeProtocol.TRADE_TIMEOUT); + // save process state processModel.setReserveTx(reserveTx); processModel.getTaker().setReserveTxKeyImages(reservedKeyImages);