From 78ec06b851ea2c3f19928dcdf6e1ab1560d366df Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 5 May 2024 19:32:07 -0400 Subject: [PATCH] add trade init steps and reset timeout --- .../haveno/core/offer/OpenOfferManager.java | 3 ++- .../offer/placeoffer/PlaceOfferModel.java | 7 ++++++- .../tasks/MakerReserveOfferFunds.java | 19 +++++++++++++++---- .../main/java/haveno/core/trade/Trade.java | 7 ++++++- .../java/haveno/core/trade/TradeManager.java | 2 +- .../trade/protocol/ArbitratorProtocol.java | 2 +- .../trade/protocol/BuyerAsMakerProtocol.java | 2 +- .../trade/protocol/BuyerAsTakerProtocol.java | 2 +- .../trade/protocol/SellerAsMakerProtocol.java | 2 +- .../trade/protocol/SellerAsTakerProtocol.java | 2 +- .../core/trade/protocol/TradeProtocol.java | 14 +++++++++++--- .../ArbitratorProcessDepositRequest.java | 3 +-- .../tasks/MaybeSendSignContractRequest.java | 5 +++-- .../tasks/ProcessDepositResponse.java | 5 ----- .../tasks/ProcessInitMultisigRequest.java | 1 - .../protocol/tasks/SendDepositRequest.java | 2 +- .../tasks/TakerReserveTradeFunds.java | 5 +++-- .../core/xmr/wallet/XmrWalletService.java | 16 +++++++++------- 18 files changed, 63 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 9b5b219a..79ddbe3f 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -1151,7 +1151,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe user, keyRing, filterManager, - accountAgeWitnessService); + accountAgeWitnessService, + this); // create protocol PlaceOfferProtocol placeOfferProtocol = new PlaceOfferProtocol(model, diff --git a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java index fcbff529..0e289aa5 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java @@ -23,6 +23,7 @@ import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.filter.FilterManager; import haveno.core.offer.OfferBookService; import haveno.core.offer.OpenOffer; +import haveno.core.offer.OpenOfferManager; import haveno.core.offer.messages.SignOfferResponse; import haveno.core.support.dispute.arbitration.arbitrator.ArbitratorManager; import haveno.core.support.dispute.mediation.mediator.MediatorManager; @@ -61,6 +62,8 @@ public class PlaceOfferModel implements Model { private final FilterManager filterManager; @Getter private final AccountAgeWitnessService accountAgeWitnessService; + @Getter + private final OpenOfferManager openOfferManager; // Mutable @Setter @@ -89,7 +92,8 @@ public class PlaceOfferModel implements Model { User user, KeyRing keyRing, FilterManager filterManager, - AccountAgeWitnessService accountAgeWitnessService) { + AccountAgeWitnessService accountAgeWitnessService, + OpenOfferManager openOfferManager) { this.openOffer = openOffer; this.reservedFundsForOffer = reservedFundsForOffer; this.useSavingsWallet = useSavingsWallet; @@ -105,6 +109,7 @@ public class PlaceOfferModel implements Model { this.keyRing = keyRing; this.filterManager = filterManager; this.accountAgeWitnessService = accountAgeWitnessService; + this.openOfferManager = openOfferManager; } @Override diff --git a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java index 9be0425e..e0fd1a7b 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java @@ -58,6 +58,10 @@ public class MakerReserveOfferFunds extends Task { MoneroTxWallet reserveTx = null; synchronized (XmrWalletService.WALLET_LOCK) { + // reset protocol timeout + verifyOpen(); + model.getProtocol().startTimeoutTimer(); + // collect relevant info BigInteger penaltyFee = HavenoUtils.multiply(offer.getAmount(), offer.getPenaltyFeePct()); BigInteger makerFee = offer.getMaxMakerFee(); @@ -71,6 +75,7 @@ public class MakerReserveOfferFunds extends Task { synchronized (HavenoUtils.getWalletFunctionLock()) { for (int i = 0; i < TradeProtocol.MAX_ATTEMPTS; i++) { try { + //if (true) throw new RuntimeException("Pretend error"); reserveTx = model.getXmrWalletService().createReserveTx(penaltyFee, makerFee, sendAmount, securityDeposit, returnAddress, openOffer.isReserveExactAmount(), preferredSubaddressIndex); } catch (Exception e) { log.warn("Error creating reserve tx, attempt={}/{}, offerId={}, error={}", i + 1, TradeProtocol.MAX_ATTEMPTS, openOffer.getShortId(), e.getMessage()); @@ -78,10 +83,8 @@ public class MakerReserveOfferFunds extends Task { HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying } - // check for error in case creating reserve tx exceeded timeout // TODO: better way? - if (!model.getXmrWalletService().getAddressEntry(offer.getId(), XmrAddressEntry.Context.TRADE_PAYOUT).isPresent()) { - throw new RuntimeException("An error has occurred posting offer " + offer.getId() + " causing its subaddress entry to be deleted"); - } + // verify still open + verifyOpen(); if (reserveTx != null) break; } } @@ -108,4 +111,12 @@ public class MakerReserveOfferFunds extends Task { failed(t); } } + + public void verifyOpen() { + if (!isOpen()) throw new RuntimeException("Offer " + model.getOpenOffer().getOffer().getId() + " is no longer open"); + } + + public boolean isOpen() { + return model.getOpenOfferManager().getOpenOfferById(model.getOpenOffer().getId()).isPresent(); + } } diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 568e5874..2813d307 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -359,7 +359,7 @@ public abstract class Trade implements Tradable, Model { private long takeOfferDate; // Initialization - private static final int TOTAL_INIT_STEPS = 15; // total estimated steps + private static final int TOTAL_INIT_STEPS = 23; // total estimated steps private int initStep = 0; @Getter private double initProgress = 0; @@ -1537,10 +1537,15 @@ public abstract class Trade implements Tradable, Model { } public void addInitProgressStep() { + startProtocolTimeout(); initProgress = Math.min(1.0, (double) ++initStep / TOTAL_INIT_STEPS); UserThread.execute(() -> initProgressProperty.set(initProgress)); } + public void startProtocolTimeout() { + getProtocol().startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); + } + public void setState(State state) { if (isInitialized) { // We don't want to log at startup the setState calls from all persisted trades diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 564c844e..81dce3d3 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -869,7 +869,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi trade.getMaker().setPubKeyRing(trade.getOffer().getPubKeyRing()); trade.getSelf().setPubKeyRing(model.getPubKeyRing()); trade.getSelf().setPaymentAccountId(paymentAccountId); - trade.addInitProgressStep(); // ensure trade is not already open Optional tradeOptional = getOpenTrade(offer.getId()); @@ -880,6 +879,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi addTrade(trade); initTradeAndProtocol(trade, tradeProtocol); + trade.addInitProgressStep(); // process with protocol ((TakerProtocol) tradeProtocol).onTakeOffer(result -> { diff --git a/core/src/main/java/haveno/core/trade/protocol/ArbitratorProtocol.java b/core/src/main/java/haveno/core/trade/protocol/ArbitratorProtocol.java index ff3c09a9..59dd8d7c 100644 --- a/core/src/main/java/haveno/core/trade/protocol/ArbitratorProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/ArbitratorProtocol.java @@ -59,7 +59,7 @@ public class ArbitratorProtocol extends DisputeProtocol { ArbitratorSendInitTradeOrMultisigRequests.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(peer, message); }, errorMessage -> { diff --git a/core/src/main/java/haveno/core/trade/protocol/BuyerAsMakerProtocol.java b/core/src/main/java/haveno/core/trade/protocol/BuyerAsMakerProtocol.java index 4ca7f37a..80ca4cf2 100644 --- a/core/src/main/java/haveno/core/trade/protocol/BuyerAsMakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/BuyerAsMakerProtocol.java @@ -74,7 +74,7 @@ public class BuyerAsMakerProtocol extends BuyerProtocol implements MakerProtocol MakerSendInitTradeRequest.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(peer, message); }, 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 dc921b08..bc683734 100644 --- a/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/BuyerAsTakerProtocol.java @@ -79,7 +79,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol TakerSendInitTradeRequestToArbitrator.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); unlatchTrade(); }, errorMessage -> { diff --git a/core/src/main/java/haveno/core/trade/protocol/SellerAsMakerProtocol.java b/core/src/main/java/haveno/core/trade/protocol/SellerAsMakerProtocol.java index 88c3e24b..e6a8ec0b 100644 --- a/core/src/main/java/haveno/core/trade/protocol/SellerAsMakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/SellerAsMakerProtocol.java @@ -79,7 +79,7 @@ public class SellerAsMakerProtocol extends SellerProtocol implements MakerProtoc MakerSendInitTradeRequest.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(peer, message); }, 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 9dcd761b..c0290008 100644 --- a/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/SellerAsTakerProtocol.java @@ -80,7 +80,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc TakerSendInitTradeRequestToArbitrator.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); unlatchTrade(); }, errorMessage -> { 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 396285a4..24617ecc 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -299,6 +299,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D public void handleInitMultisigRequest(InitMultisigRequest request, NodeAddress sender) { System.out.println(getClass().getSimpleName() + ".handleInitMultisigRequest()"); + trade.addInitProgressStep(); ThreadUtils.execute(() -> { synchronized (trade) { @@ -320,7 +321,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D MaybeSendSignContractRequest.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(sender, request); }, errorMessage -> { @@ -335,6 +336,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D public void handleSignContractRequest(SignContractRequest message, NodeAddress sender) { System.out.println(getClass().getSimpleName() + ".handleSignContractRequest() " + trade.getId()); + trade.addInitProgressStep(); ThreadUtils.execute(() -> { synchronized (trade) { @@ -358,7 +360,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D ProcessSignContractRequest.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(sender, message); }, errorMessage -> { @@ -380,6 +382,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D public void handleSignContractResponse(SignContractResponse message, NodeAddress sender) { System.out.println(getClass().getSimpleName() + ".handleSignContractResponse() " + trade.getId()); + trade.addInitProgressStep(); ThreadUtils.execute(() -> { synchronized (trade) { @@ -403,7 +406,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D SendDepositRequest.class) .using(new TradeTaskRunner(trade, () -> { - startTimeout(TRADE_STEP_TIMEOUT_SECONDS); + startTimeout(); handleTaskRunnerSuccess(sender, message); }, errorMessage -> { @@ -425,6 +428,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D public void handleDepositResponse(DepositResponse response, NodeAddress sender) { System.out.println(getClass().getSimpleName() + ".handleDepositResponse()"); + trade.addInitProgressStep(); ThreadUtils.execute(() -> { synchronized (trade) { Validator.checkTradeId(processModel.getOfferId(), response); @@ -716,6 +720,10 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D // Timeout /////////////////////////////////////////////////////////////////////////////////////////// + public synchronized void startTimeout() { + startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); + } + public synchronized void startTimeout(long timeoutSec) { synchronized (timeoutTimerLock) { stopTimeout(); diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java index 1feb2b6b..6c59239b 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorProcessDepositRequest.java @@ -28,7 +28,6 @@ import haveno.core.trade.Trade; import haveno.core.trade.messages.DepositRequest; import haveno.core.trade.messages.DepositResponse; import haveno.core.trade.protocol.TradePeer; -import haveno.core.trade.protocol.TradeProtocol; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.SendDirectMessageListener; import lombok.extern.slf4j.Slf4j; @@ -104,7 +103,7 @@ public class ArbitratorProcessDepositRequest extends TradeTask { // extend timeout if (isTimedOut()) throw new RuntimeException("Trade protocol has timed out while verifying deposit tx for {} {}" + trade.getClass().getSimpleName() + " " + trade.getShortId()); - trade.getProtocol().startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); + trade.startProtocolTimeout(); // set deposit info trader.setSecurityDeposit(securityDeposit.subtract(verifiedTx.getFee())); // subtract mining fee from security deposit diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java index 6870742b..7536617c 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java @@ -83,7 +83,8 @@ public class MaybeSendSignContractRequest extends TradeTask { synchronized (XmrWalletService.WALLET_LOCK) { // check for timeout - if (isTimedOut()) throw new RuntimeException("Trade protocol has timed out while creating deposit tx, tradeId=" + trade.getShortId()); + if (isTimedOut()) throw new RuntimeException("Trade protocol has timed out while getting lock to create deposit tx, tradeId=" + trade.getShortId()); + trade.startProtocolTimeout(); // collect relevant info Integer subaddressIndex = null; @@ -126,7 +127,7 @@ public class MaybeSendSignContractRequest extends TradeTask { } // reset protocol timeout - trade.getProtocol().startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); + trade.addInitProgressStep(); // collect reserved key images List reservedKeyImages = new ArrayList(); diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessDepositResponse.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessDepositResponse.java index 1140a5d5..e37c6121 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessDepositResponse.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessDepositResponse.java @@ -23,7 +23,6 @@ import java.math.BigInteger; import haveno.common.taskrunner.TaskRunner; import haveno.core.trade.Trade; import haveno.core.trade.messages.DepositResponse; -import haveno.core.trade.protocol.TradeProtocol; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -47,16 +46,12 @@ public class ProcessDepositResponse extends TradeTask { throw new RuntimeException(message.getErrorMessage()); } - // reset protocol timeout - trade.getProtocol().startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); - // record security deposits trade.getBuyer().setSecurityDeposit(BigInteger.valueOf(message.getBuyerSecurityDeposit())); trade.getSeller().setSecurityDeposit(BigInteger.valueOf(message.getSellerSecurityDeposit())); // set success state trade.setStateIfValidTransitionTo(Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS); - trade.addInitProgressStep(); processModel.getTradeManager().requestPersistence(); // update balances diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java index 8b4a8027..18761926 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java @@ -81,7 +81,6 @@ public class ProcessInitMultisigRequest extends TradeTask { // prepare multisig if applicable boolean updateParticipants = false; if (trade.getSelf().getPreparedMultisigHex() == null) { - trade.addInitProgressStep(); log.info("Preparing multisig wallet for {} {}", trade.getClass().getSimpleName(), trade.getId()); multisigWallet = trade.createWallet(); trade.getSelf().setPreparedMultisigHex(multisigWallet.prepareMultisig()); diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/SendDepositRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/SendDepositRequest.java index ccf54991..dd43d694 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/SendDepositRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/SendDepositRequest.java @@ -89,7 +89,6 @@ public class SendDepositRequest extends TradeTask { // update trade state trade.setState(Trade.State.SENT_PUBLISH_DEPOSIT_TX_REQUEST); processModel.getTradeManager().requestPersistence(); - trade.addInitProgressStep(); // send request to arbitrator log.info("Sending {} to arbitrator {}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), request.getUid()); @@ -99,6 +98,7 @@ public class SendDepositRequest extends TradeTask { log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitrator().getNodeAddress(), trade.getId(), request.getUid()); trade.setStateIfValidTransitionTo(Trade.State.SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST); processModel.getTradeManager().requestPersistence(); + trade.addInitProgressStep(); complete(); } @Override 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 f3a47d28..5b1e0f33 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 @@ -49,7 +49,8 @@ public class TakerReserveTradeFunds extends TradeTask { synchronized (XmrWalletService.WALLET_LOCK) { // check for timeout - if (isTimedOut()) throw new RuntimeException("Trade protocol has timed out while creating reserve tx, tradeId=" + trade.getShortId()); + if (isTimedOut()) throw new RuntimeException("Trade protocol has timed out while getting lock to create reserve tx, tradeId=" + trade.getShortId()); + trade.startProtocolTimeout(); // collect relevant info BigInteger penaltyFee = HavenoUtils.multiply(trade.getAmount(), trade.getOffer().getPenaltyFeePct()); @@ -76,7 +77,7 @@ public class TakerReserveTradeFunds extends TradeTask { } // reset protocol timeout - trade.getProtocol().startTimeout(TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS); + trade.startProtocolTimeout(); // collect reserved key images List reservedKeyImages = new ArrayList(); diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index b681b2c4..f3b1ff7f 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -372,12 +372,6 @@ public class XmrWalletService { return useNativeXmrWallet && MoneroUtils.isNativeLibraryLoaded(); } - public MoneroSyncResult syncWallet() { - MoneroSyncResult result = syncWallet(wallet); - walletHeight.set(wallet.getHeight()); - return result; - } - /** * Sync the given wallet in a thread pool with other wallets. */ @@ -1799,7 +1793,7 @@ public class XmrWalletService { // sync wallet if behind daemon if (walletHeight.get() < xmrConnectionService.getTargetHeight()) { synchronized (WALLET_LOCK) { // avoid long sync from blocking other operations - syncWallet(); + syncMainWallet(); } } @@ -1833,6 +1827,14 @@ public class XmrWalletService { } } + private MoneroSyncResult syncMainWallet() { + synchronized (WALLET_LOCK) { + MoneroSyncResult result = syncWallet(wallet); + walletHeight.set(wallet.getHeight()); + return result; + } + } + public boolean isWalletConnectedToDaemon() { synchronized (WALLET_LOCK) { try {