check and extend timeout after taker creates reserve tx
This commit is contained in:
parent
fe70a087c4
commit
e11d65c038
@ -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(() -> {
|
||||
|
@ -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<String> reservedKeyImages = new ArrayList<String>();
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user