From 9957aa6256a567303adc03d0228bcf582f199ee7 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 27 Nov 2023 14:30:49 -0500 Subject: [PATCH] check that wallet is synced within tolerance --- .../haveno/core/api/XmrConnectionService.java | 15 ++++++------- .../java/haveno/core/app/AppStartupState.java | 2 +- .../tasks/MakerReserveOfferFunds.java | 2 +- .../haveno/core/support/SupportManager.java | 2 +- .../core/support/dispute/DisputeManager.java | 12 +---------- .../main/java/haveno/core/trade/Trade.java | 18 ++++++++-------- .../java/haveno/core/trade/TradeManager.java | 2 +- .../core/trade/protocol/TradeProtocol.java | 2 +- .../core/xmr/wallet/XmrWalletService.java | 21 +++++++++++++------ .../resources/i18n/displayStrings.properties | 2 +- .../i18n/displayStrings_cs.properties | 2 +- .../i18n/displayStrings_de.properties | 2 +- .../i18n/displayStrings_es.properties | 2 +- .../i18n/displayStrings_fa.properties | 2 +- .../i18n/displayStrings_fr.properties | 2 +- .../i18n/displayStrings_it.properties | 2 +- .../i18n/displayStrings_ja.properties | 2 +- .../i18n/displayStrings_pt-br.properties | 2 +- .../i18n/displayStrings_pt.properties | 2 +- .../i18n/displayStrings_ru.properties | 2 +- .../i18n/displayStrings_th.properties | 2 +- .../i18n/displayStrings_vi.properties | 2 +- .../i18n/displayStrings_zh-hans.properties | 2 +- .../i18n/displayStrings_zh-hant.properties | 2 +- .../desktop/components/TxIdTextField.java | 2 +- .../main/funds/withdrawal/WithdrawalView.java | 2 +- .../offer/offerbook/OfferBookViewModel.java | 2 +- .../pendingtrades/PendingTradesDataModel.java | 2 +- .../java/haveno/desktop/util/GUIUtil.java | 14 ++++++++----- 29 files changed, 66 insertions(+), 62 deletions(-) diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index a28261ea8e..c3bc739fad 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -260,17 +260,18 @@ public final class XmrConnectionService { } public boolean isSyncedWithinTolerance() { - if (daemon == null) return false; - Long targetHeight = lastInfo.getTargetHeight(); // the last time the node thought it was behind the network and was in active sync mode to catch up - if (targetHeight == 0) return true; // monero-daemon-rpc sync_info's target_height returns 0 when node is fully synced - long currentHeight = chainHeight.get(); - if (targetHeight - currentHeight <= 3) { // synced if not more than 3 blocks behind target height - return true; - } + Long targetHeight = getTargetHeight(); + if (targetHeight == null) return false; + if (targetHeight - chainHeight.get() <= 3) return true; // synced if within 3 blocks of target height log.warn("Our chain height: {} is out of sync with peer nodes chain height: {}", chainHeight.get(), targetHeight); return false; } + public Long getTargetHeight() { + if (daemon == null || lastInfo == null) return null; + return lastInfo.getTargetHeight() == 0 ? chainHeight.get() : lastInfo.getTargetHeight(); // monerod sync_info's target_height returns 0 when node is fully synced + } + // ----------------------------- APP METHODS ------------------------------ public ReadOnlyIntegerProperty numPeersProperty() { diff --git a/core/src/main/java/haveno/core/app/AppStartupState.java b/core/src/main/java/haveno/core/app/AppStartupState.java index 08d3f152a5..755af7bbf9 100644 --- a/core/src/main/java/haveno/core/app/AppStartupState.java +++ b/core/src/main/java/haveno/core/app/AppStartupState.java @@ -70,7 +70,7 @@ public class AppStartupState { }); xmrWalletService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { - if (xmrWalletService.isWalletSynced()) + if (xmrWalletService.isDownloadComplete()) isWalletSynced.set(true); }); 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 3ee549cb89..f766fcce51 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 @@ -47,7 +47,7 @@ public class MakerReserveOfferFunds extends Task { runInterceptHook(); // verify monero connection - model.getXmrWalletService().getConnectionsService().verifyConnection(); + model.getXmrWalletService().getConnectionService().verifyConnection(); // create reserve tx BigInteger makerFee = offer.getMakerFee(); diff --git a/core/src/main/java/haveno/core/support/SupportManager.java b/core/src/main/java/haveno/core/support/SupportManager.java index de4957a459..5c2e8b6f48 100644 --- a/core/src/main/java/haveno/core/support/SupportManager.java +++ b/core/src/main/java/haveno/core/support/SupportManager.java @@ -338,7 +338,7 @@ public abstract class SupportManager { p2PService.isBootstrapped() && xmrConnectionService.isDownloadComplete() && xmrConnectionService.hasSufficientPeersForBroadcast() && - xmrWalletService.isWalletSynced(); + xmrWalletService.isDownloadComplete(); } diff --git a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java index 0a7e0bf80a..faed3a89f6 100644 --- a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java @@ -252,18 +252,8 @@ public abstract class DisputeManager> extends Sup } }); - xmrConnectionService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { - if (xmrConnectionService.isDownloadComplete()) - tryApplyMessages(); - }); - xmrWalletService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { - if (xmrWalletService.isWalletSynced()) - tryApplyMessages(); - }); - - xmrConnectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> { - if (xmrConnectionService.hasSufficientPeersForBroadcast()) + if (xmrWalletService.isSyncedWithinTolerance()) tryApplyMessages(); }); diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index c027ffc0ac..e153889570 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -588,7 +588,7 @@ public abstract class Trade implements Tradable, Model { }); // handle daemon changes with max parallelization - xmrWalletService.getConnectionsService().addConnectionListener(newConnection -> { + xmrWalletService.getConnectionService().addConnectionListener(newConnection -> { HavenoUtils.submitTask(() -> onConnectionChanged(newConnection)); }); @@ -643,7 +643,7 @@ public abstract class Trade implements Tradable, Model { new Thread(() -> { GenUtils.waitFor(1000); if (isShutDownStarted) return; - if (Boolean.TRUE.equals(xmrWalletService.getConnectionsService().isConnected())) xmrWalletService.syncWallet(xmrWalletService.getWallet()); + if (Boolean.TRUE.equals(xmrWalletService.getConnectionService().isConnected())) xmrWalletService.syncWallet(xmrWalletService.getWallet()); }).start(); // complete disputed trade @@ -758,7 +758,7 @@ public abstract class Trade implements Tradable, Model { } public void checkDaemonConnection() { - XmrConnectionService xmrConnectionService = xmrWalletService.getConnectionsService(); + XmrConnectionService xmrConnectionService = xmrWalletService.getConnectionService(); xmrConnectionService.checkConnection(); xmrConnectionService.verifyConnection(); if (!getWallet().isConnectedToDaemon()) throw new RuntimeException("Trade wallet is not connected to a Monero node"); @@ -783,7 +783,7 @@ public abstract class Trade implements Tradable, Model { public void syncWalletNormallyForMs(long syncNormalDuration) { syncNormalStartTime = System.currentTimeMillis(); - setWalletRefreshPeriod(xmrWalletService.getConnectionsService().getRefreshPeriodMs()); + setWalletRefreshPeriod(xmrWalletService.getConnectionService().getRefreshPeriodMs()); UserThread.runAfter(() -> { if (!isShutDown && System.currentTimeMillis() >= syncNormalStartTime + syncNormalDuration) updateWalletRefreshPeriod(); }, syncNormalDuration); @@ -1684,7 +1684,7 @@ public abstract class Trade implements Tradable, Model { */ public long getReprocessDelayInSeconds(int reprocessCount) { int retryCycles = 3; // reprocess on next refresh periods for first few attempts (app might auto switch to a good connection) - if (reprocessCount < retryCycles) return xmrWalletService.getConnectionsService().getRefreshPeriodMs() / 1000; + if (reprocessCount < retryCycles) return xmrWalletService.getConnectionService().getRefreshPeriodMs() / 1000; long delay = 60; for (int i = retryCycles; i < reprocessCount; i++) delay *= 2; return Math.min(MAX_REPROCESS_DELAY_SECONDS, delay); @@ -1785,7 +1785,7 @@ public abstract class Trade implements Tradable, Model { if (!wasWalletSynced) { wasWalletSynced = true; if (xmrWalletService.isProxyApplied(wasWalletSynced)) { - onConnectionChanged(xmrWalletService.getConnectionsService().getConnection()); + onConnectionChanged(xmrWalletService.getConnectionService().getConnection()); } } @@ -1843,7 +1843,7 @@ public abstract class Trade implements Tradable, Model { try { // log warning if wallet is too far behind daemon - MoneroDaemonInfo lastInfo = xmrWalletService.getConnectionsService().getLastInfo(); + MoneroDaemonInfo lastInfo = xmrWalletService.getConnectionService().getLastInfo(); long walletHeight = wallet.getHeight(); if (wasWalletSynced && isDepositsPublished() && lastInfo != null && walletHeight < lastInfo.getHeight() - 3 && !Config.baseCurrencyNetwork().isTestnet()) { log.warn("Wallet is more than 3 blocks behind monerod for {} {}, wallet height={}, monerod height={},", getClass().getSimpleName(), getShortId(), walletHeight, lastInfo.getHeight()); @@ -1924,7 +1924,7 @@ public abstract class Trade implements Tradable, Model { } } catch (Exception e) { if (!isShutDownStarted && wallet != null && isWalletConnected()) { - log.warn("Error polling trade wallet for {} {}: {}. Monerod={}", getClass().getSimpleName(), getId(), e.getMessage(), getXmrWalletService().getConnectionsService().getConnection()); + log.warn("Error polling trade wallet for {} {}: {}. Monerod={}", getClass().getSimpleName(), getId(), e.getMessage(), getXmrWalletService().getConnectionService().getConnection()); } } } @@ -1932,7 +1932,7 @@ public abstract class Trade implements Tradable, Model { private long getWalletRefreshPeriod() { if (isIdling()) return IDLE_SYNC_PERIOD_MS; - return xmrWalletService.getConnectionsService().getRefreshPeriodMs(); + return xmrWalletService.getConnectionService().getRefreshPeriodMs(); } private void setStateDepositsPublished() { diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 5c78d61b1d..a10389c06e 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -1285,7 +1285,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi // listen for block confirmation to remove trade long startTime = System.currentTimeMillis(); - heightSubscription = EasyBind.subscribe(xmrWalletService.getConnectionsService().chainHeightProperty(), lastBlockHeight -> { + heightSubscription = EasyBind.subscribe(xmrWalletService.getConnectionService().chainHeightProperty(), lastBlockHeight -> { if (isShutDown) return; if (startHeight == null) startHeight = lastBlockHeight.longValue(); if (lastBlockHeight.longValue() >= startHeight + REMOVE_AFTER_NUM_CONFIRMATIONS) { 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 448eda5e33..53db1196c8 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -823,7 +823,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D } void handleTaskRunnerFault(NodeAddress ackReceiver, @Nullable TradeMessage message, String source, String errorMessage) { - log.error("Task runner failed with error {}. Triggered from {}. Monerod={}" , errorMessage, source, trade.getXmrWalletService().getConnectionsService().getConnection()); + log.error("Task runner failed with error {}. Triggered from {}. Monerod={}" , errorMessage, source, trade.getXmrWalletService().getConnectionService().getConnection()); if (message != null) { sendAckMessage(ackReceiver, message, false, errorMessage); 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 3df7f2aade..63372d9b66 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -215,10 +215,6 @@ public class XmrWalletService { return accountService.getPassword() != null; } - public boolean isWalletSynced() { - return downloadPercentageProperty().get() == 1d; - } - public ReadOnlyDoubleProperty downloadPercentageProperty() { return downloadListener.percentageProperty(); } @@ -226,16 +222,28 @@ public class XmrWalletService { private void doneDownload() { downloadListener.doneDownload(); } - + + public boolean isDownloadComplete() { + return downloadPercentageProperty().get() == 1d; + } + public LongProperty walletHeightProperty() { return walletHeight; } + public boolean isSyncedWithinTolerance() { + if (!xmrConnectionService.isSyncedWithinTolerance()) return false; + Long targetHeight = xmrConnectionService.getTargetHeight(); + if (targetHeight == null) return false; + if (targetHeight - walletHeight.get() <= 3) return true; // synced if within 3 blocks of target height + return false; + } + public MoneroDaemonRpc getDaemon() { return xmrConnectionService.getDaemon(); } - public XmrConnectionService getConnectionsService() { + public XmrConnectionService getConnectionService() { return xmrConnectionService; } @@ -721,6 +729,7 @@ public class XmrWalletService { log.info("Syncing main wallet"); long time = System.currentTimeMillis(); wallet.sync(); // blocking + walletHeight.set(wallet.getHeight()); wasWalletSynced = true; log.info("Done syncing main wallet in " + (System.currentTimeMillis() - time) + " ms"); wallet.startSyncing(xmrConnectionService.getRefreshPeriodMs()); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 3f679a12fc..0f4b6ed85f 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2100,7 +2100,7 @@ popup.warning.noMediatorsAvailable=There are no mediators available. popup.warning.notFullyConnected=You need to wait until you are fully connected to the network.\nThat might take up to about 2 minutes at startup. popup.warning.notSufficientConnectionsToXmrNetwork=You need to wait until you have at least {0} connections to the Monero network. popup.warning.downloadNotComplete=You need to wait until the download of missing Monero blocks is complete. -popup.warning.chainNotSynced=The Haveno wallet is not synced with the latest blockchain height. Please wait until the wallet syncs or check your connection. +popup.warning.walletNotSynced=The Haveno wallet is not synced with the latest blockchain height. Please wait until the wallet syncs or check your connection. popup.warning.removeOffer=Are you sure you want to remove that offer? popup.warning.tooLargePercentageValue=You cannot set a percentage of 100% or larger. popup.warning.examplePercentageValue=Please enter a percentage number like \"5.4\" for 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_cs.properties b/core/src/main/resources/i18n/displayStrings_cs.properties index 2963de7425..f7cc393923 100644 --- a/core/src/main/resources/i18n/displayStrings_cs.properties +++ b/core/src/main/resources/i18n/displayStrings_cs.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=Nejsou k dispozici žádní mediátoři. popup.warning.notFullyConnected=Musíte počkat, až budete plně připojeni k síti.\nTo může při spuštění trvat až 2 minuty. popup.warning.notSufficientConnectionsToXmrNetwork=Musíte počkat, až budete mít alespoň {0} připojení k moneroové síti. popup.warning.downloadNotComplete=Musíte počkat, až bude stahování chybějících moneroových bloků kompletní. -popup.warning.chainNotSynced=Haveno peněženka není synchronizována s nejnovější výškou blockchainu. Počkejte, dokud se peněženka nesynchronizuje, nebo zkontrolujte své připojení. +popup.warning.walletNotSynced=Haveno peněženka není synchronizována s nejnovější výškou blockchainu. Počkejte, dokud se peněženka nesynchronizuje, nebo zkontrolujte své připojení. popup.warning.removeOffer=Opravdu chcete tuto nabídku odebrat? popup.warning.tooLargePercentageValue=Nelze nastavit procento 100% nebo větší. popup.warning.examplePercentageValue=Zadejte procento jako číslo \"5.4\" pro 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_de.properties b/core/src/main/resources/i18n/displayStrings_de.properties index 821484ef8f..9b866bcef4 100644 --- a/core/src/main/resources/i18n/displayStrings_de.properties +++ b/core/src/main/resources/i18n/displayStrings_de.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=Es sind keine Mediatoren verfügbar. popup.warning.notFullyConnected=Sie müssen warten, bis Sie vollständig mit dem Netzwerk verbunden sind.\nDas kann bis ungefähr 2 Minuten nach dem Start dauern. popup.warning.notSufficientConnectionsToXmrNetwork=Sie müssen warten, bis Sie wenigstens {0} Verbindungen zum Moneronetzwerk haben. popup.warning.downloadNotComplete=Sie müssen warten bis der Download der fehlenden Moneroblöcke abgeschlossen ist. -popup.warning.chainNotSynced=Die Haveno-Brieftasche ist nicht mit der neuesten Höhe der Blockchain synchronisiert. Bitte warten Sie, bis die Brieftasche synchronisiert ist, oder überprüfen Sie Ihre Verbindung. +popup.warning.walletNotSynced=Die Haveno-Brieftasche ist nicht mit der neuesten Höhe der Blockchain synchronisiert. Bitte warten Sie, bis die Brieftasche synchronisiert ist, oder überprüfen Sie Ihre Verbindung. popup.warning.removeOffer=Sind Sie sicher, dass Sie das Angebot entfernen wollen? popup.warning.tooLargePercentageValue=Es kann kein Prozentsatz von 100% oder mehr verwendet werden. popup.warning.examplePercentageValue=Bitte geben sei einen Prozentsatz wie folgt ein \"5.4\" für 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_es.properties b/core/src/main/resources/i18n/displayStrings_es.properties index a252c31889..bfe3e9b60d 100644 --- a/core/src/main/resources/i18n/displayStrings_es.properties +++ b/core/src/main/resources/i18n/displayStrings_es.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=No hay mediadores disponibles. popup.warning.notFullyConnected=Necesita esperar hasta que esté completamente conectado a la red.\nPuede llevar hasta 2 minutos al inicio. popup.warning.notSufficientConnectionsToXmrNetwork=Necesita esperar hasta que tenga al menos {0} conexiones a la red Monero. popup.warning.downloadNotComplete=Tiene que esperar hasta que finalice la descarga de los bloques Monero que faltan. -popup.warning.chainNotSynced=La billetera Haveno no está sincronizada con la última altura de la cadena de bloques. Por favor, espere hasta que la billetera se sincronice o verifique su conexión. +popup.warning.walletNotSynced=La billetera Haveno no está sincronizada con la última altura de la cadena de bloques. Por favor, espere hasta que la billetera se sincronice o verifique su conexión. popup.warning.removeOffer=¿Está seguro que quiere eliminar la oferta? popup.warning.tooLargePercentageValue=No puede establecer un porcentaje del 100% o superior. popup.warning.examplePercentageValue=Por favor, introduzca un número de porcentaje como \"5.4\" para 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_fa.properties b/core/src/main/resources/i18n/displayStrings_fa.properties index 707d6d35b1..b14e0ecf5e 100644 --- a/core/src/main/resources/i18n/displayStrings_fa.properties +++ b/core/src/main/resources/i18n/displayStrings_fa.properties @@ -1578,7 +1578,7 @@ popup.warning.noMediatorsAvailable=There are no mediators available. popup.warning.notFullyConnected=شما باید منتظر بمانید تا به طور کامل به شبکه متصل شوید. \nاین ممکن است در هنگام راه اندازی حدود 2 دقیقه طول بکشد. popup.warning.notSufficientConnectionsToXmrNetwork=شما باید منتظر بمانید تا حداقل {0} اتصال به شبکه بیتکوین داشته باشید. popup.warning.downloadNotComplete=شما باید منتظر بمانید تا بارگیری بلاک های بیتکوین باقیمانده کامل شود. -popup.warning.chainNotSynced=کیف پول Haveno با ارتفاع آخرین بلوکچین هماهنگ نشده است. لطفاً منتظر بمانید تا کیف پول هماهنگ شود یا اتصال خود را بررسی کنید. +popup.warning.walletNotSynced=کیف پول Haveno با ارتفاع آخرین بلوکچین هماهنگ نشده است. لطفاً منتظر بمانید تا کیف پول هماهنگ شود یا اتصال خود را بررسی کنید. popup.warning.removeOffer=آیا شما مطمئن هستید که می خواهید این پیشنهاد را حذف کنید؟ popup.warning.tooLargePercentageValue=شما نمیتوانید درصد 100٪ یا بیشتر را تنظیم کنید. popup.warning.examplePercentageValue=لطفا یک عدد درصد مانند \"5.4\" برای 5.4% وارد کنید diff --git a/core/src/main/resources/i18n/displayStrings_fr.properties b/core/src/main/resources/i18n/displayStrings_fr.properties index 1a0e67033b..bd753a6d9f 100644 --- a/core/src/main/resources/i18n/displayStrings_fr.properties +++ b/core/src/main/resources/i18n/displayStrings_fr.properties @@ -1582,7 +1582,7 @@ popup.warning.noMediatorsAvailable=Il n'y a pas de médiateurs disponibles. popup.warning.notFullyConnected=Vous devez attendre d'être complètement connecté au réseau.\nCela peut prendre jusqu'à 2 minutes au démarrage. popup.warning.notSufficientConnectionsToXmrNetwork=Vous devez attendre d''avoir au minimum {0} connexions au réseau Monero. popup.warning.downloadNotComplete=Vous devez attendre que le téléchargement des blocs Monero manquants soit terminé. -popup.warning.chainNotSynced=Le portefeuille Haveno n'est pas synchronisé avec la hauteur la plus récente de la blockchain. Veuillez patienter jusqu'à ce que le portefeuille soit synchronisé ou vérifiez votre connexion. +popup.warning.walletNotSynced=Le portefeuille Haveno n'est pas synchronisé avec la hauteur la plus récente de la blockchain. Veuillez patienter jusqu'à ce que le portefeuille soit synchronisé ou vérifiez votre connexion. popup.warning.removeOffer=Vous êtes certain de vouloir retirer cet ordre? popup.warning.tooLargePercentageValue=Vous ne pouvez pas définir un pourcentage de 100% ou plus grand. popup.warning.examplePercentageValue=Merci de saisir un nombre sous la forme d'un pourcentage tel que \"5.4\" pour 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_it.properties b/core/src/main/resources/i18n/displayStrings_it.properties index aaab4ca6db..47a37a3b72 100644 --- a/core/src/main/resources/i18n/displayStrings_it.properties +++ b/core/src/main/resources/i18n/displayStrings_it.properties @@ -1580,7 +1580,7 @@ popup.warning.noMediatorsAvailable=Non ci sono mediatori disponibili. popup.warning.notFullyConnected=È necessario attendere fino a quando non si è completamente connessi alla rete.\nQuesto potrebbe richiedere fino a circa 2 minuti all'avvio. popup.warning.notSufficientConnectionsToXmrNetwork=Devi aspettare fino a quando non hai almeno {0} connessioni alla rete Monero. popup.warning.downloadNotComplete=Devi aspettare fino al completamento del download dei blocchi Monero mancanti. -popup.warning.chainNotSynced=Il portafoglio Haveno non è sincronizzato con l'altezza più recente della blockchain. Si prega di attendere finché il portafoglio si sincronizza o controllare la connessione. +popup.warning.walletNotSynced=Il portafoglio Haveno non è sincronizzato con l'altezza più recente della blockchain. Si prega di attendere finché il portafoglio si sincronizza o controllare la connessione. popup.warning.removeOffer=Sei sicuro di voler rimuovere quell'offerta? popup.warning.tooLargePercentageValue=Non è possibile impostare una percentuale del 100% o superiore. popup.warning.examplePercentageValue=Inserisci un numero percentuale come \"5.4\" per il 5,4% diff --git a/core/src/main/resources/i18n/displayStrings_ja.properties b/core/src/main/resources/i18n/displayStrings_ja.properties index e8c7ef940f..d49776510c 100644 --- a/core/src/main/resources/i18n/displayStrings_ja.properties +++ b/core/src/main/resources/i18n/displayStrings_ja.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=利用可能な調停人がいません。 popup.warning.notFullyConnected=ネットワークへ完全に接続するまで待つ必要があります。\n起動までに約2分かかります。 popup.warning.notSufficientConnectionsToXmrNetwork=少なくとも{0}のビットコインネットワークへの接続が確立されるまでお待ちください。 popup.warning.downloadNotComplete=欠落しているビットコインブロックのダウンロードが完了するまで待つ必要があります。 -popup.warning.chainNotSynced=Havenoウォレットのブロックチェーン高さは正しく同期されていません。アプリを最近起動した場合、1つのビットコインブロックが発行されるまで待って下さい。\n\nブロックチェーン高さは\"設定/ネットワーク情報\"に表示されます。 2つ以上のブロックが発行されても問題が解決されない場合、フリーズしている可能性があります。その場合には、SPV再同期を行って下さい [HYPERLINK: https://haveno.exchange/wiki/Resyncing_SPV_file ]。 +popup.warning.walletNotSynced=Havenoウォレットのブロックチェーン高さは正しく同期されていません。アプリを最近起動した場合、1つのビットコインブロックが発行されるまで待って下さい。\n\nブロックチェーン高さは\"設定/ネットワーク情報\"に表示されます。 2つ以上のブロックが発行されても問題が解決されない場合、フリーズしている可能性があります。その場合には、SPV再同期を行って下さい [HYPERLINK: https://haveno.exchange/wiki/Resyncing_SPV_file ]。 popup.warning.removeOffer=本当にオファーを削除しますか? popup.warning.tooLargePercentageValue=100%以上のパーセントを設定できません popup.warning.examplePercentageValue=パーセントの数字を入力してください。5.4%は「5.4」のように入力します。 diff --git a/core/src/main/resources/i18n/displayStrings_pt-br.properties b/core/src/main/resources/i18n/displayStrings_pt-br.properties index 9cd8fa5817..61ff156ff4 100644 --- a/core/src/main/resources/i18n/displayStrings_pt-br.properties +++ b/core/src/main/resources/i18n/displayStrings_pt-br.properties @@ -1586,7 +1586,7 @@ popup.warning.noMediatorsAvailable=Não há mediadores disponíveis. popup.warning.notFullyConnected=Você precisa aguardar até estar totalmente conectado à rede.\nIsto pode levar até 2 minutos na inicialização do programa. popup.warning.notSufficientConnectionsToXmrNetwork=Você precisa esperar até ter pelo menos {0} conexões à rede Monero. popup.warning.downloadNotComplete=Você precisa aguardar até que termine o download dos blocos de Monero restantes -popup.warning.chainNotSynced=A carteira Haveno não está sincronizada com a altura mais recente da blockchain. Por favor, aguarde até que a carteira seja sincronizada ou verifique sua conexão. +popup.warning.walletNotSynced=A carteira Haveno não está sincronizada com a altura mais recente da blockchain. Por favor, aguarde até que a carteira seja sincronizada ou verifique sua conexão. popup.warning.removeOffer=Tem certeza que deseja remover essa oferta? popup.warning.tooLargePercentageValue=Você não pode definir uma porcentagem superior a 100%. popup.warning.examplePercentageValue=Digite um número percentual, como \"5.4\" para 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_pt.properties b/core/src/main/resources/i18n/displayStrings_pt.properties index 290a2b5c14..0504ce09c2 100644 --- a/core/src/main/resources/i18n/displayStrings_pt.properties +++ b/core/src/main/resources/i18n/displayStrings_pt.properties @@ -1578,7 +1578,7 @@ popup.warning.noMediatorsAvailable=Não há mediadores disponíveis. popup.warning.notFullyConnected=Você precisa esperar até estar totalmente conectado à rede.\nIsso pode levar cerca de 2 minutos na inicialização. popup.warning.notSufficientConnectionsToXmrNetwork=Você precisa esperar até que você tenha pelo menos {0} conexões com a rede Monero. popup.warning.downloadNotComplete=Você precisa esperar até que o download dos blocos de Monero ausentes esteja completo. -popup.warning.chainNotSynced=A carteira Haveno não está sincronizada com a altura mais recente da blockchain. Por favor, aguarde até que a carteira seja sincronizada ou verifique a sua conexão. +popup.warning.walletNotSynced=A carteira Haveno não está sincronizada com a altura mais recente da blockchain. Por favor, aguarde até que a carteira seja sincronizada ou verifique a sua conexão. popup.warning.removeOffer=Tem certeza de que deseja remover essa oferta? popup.warning.tooLargePercentageValue=Você não pode definir uma percentagem superior à 100%. popup.warning.examplePercentageValue=Por favor digitar um número percentual como \"5.4\" para 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_ru.properties b/core/src/main/resources/i18n/displayStrings_ru.properties index c3ad8f0952..dd08443c3e 100644 --- a/core/src/main/resources/i18n/displayStrings_ru.properties +++ b/core/src/main/resources/i18n/displayStrings_ru.properties @@ -1579,7 +1579,7 @@ popup.warning.noMediatorsAvailable=There are no mediators available. popup.warning.notFullyConnected=Необходимо дождаться полного подключения к сети.\nОно может занять до 2 минут. popup.warning.notSufficientConnectionsToXmrNetwork=Необходимо дождаться не менее {0} соединений с сетью Биткойн. popup.warning.downloadNotComplete=Необходимо дождаться завершения загрузки недостающих блоков сети Биткойн. -popup.warning.chainNotSynced=Кошелек Haveno не синхронизирован с последней высотой блокчейна. Пожалуйста, подождите, пока кошелек синхронизируется, или проверьте ваше соединение. +popup.warning.walletNotSynced=Кошелек Haveno не синхронизирован с последней высотой блокчейна. Пожалуйста, подождите, пока кошелек синхронизируется, или проверьте ваше соединение. popup.warning.removeOffer=Действительно хотите удалить это предложение? popup.warning.tooLargePercentageValue=Нельзя установить процент в размере 100% или выше. popup.warning.examplePercentageValue=Введите процент, например \«5,4\» для 5,4% diff --git a/core/src/main/resources/i18n/displayStrings_th.properties b/core/src/main/resources/i18n/displayStrings_th.properties index a709029a57..644eb2000c 100644 --- a/core/src/main/resources/i18n/displayStrings_th.properties +++ b/core/src/main/resources/i18n/displayStrings_th.properties @@ -1579,7 +1579,7 @@ popup.warning.noMediatorsAvailable=There are no mediators available. popup.warning.notFullyConnected=คุณต้องรอจนกว่าคุณจะเชื่อมต่อกับเครือข่ายอย่างสมบูรณ์\nอาจใช้เวลาประมาณ 2 นาทีเมื่อเริ่มต้น popup.warning.notSufficientConnectionsToXmrNetwork=คุณต้องรอจนกว่าจะมีการเชื่อมต่อกับเครือข่าย Monero อย่างน้อย {0} รายการ popup.warning.downloadNotComplete=คุณต้องรอจนกว่าการดาวน์โหลดบล็อค Monero ที่ขาดหายไปจะเสร็จสมบูรณ์ -popup.warning.chainNotSynced=กระเป๋า Haveno ไม่ได้ปรับข้อมูลกับความสูงของบล็อกเชนล่าสุด โปรดรอให้กระเป๋าปรับข้อมูลหรือตรวจสอบการเชื่อมต่อของคุณ +popup.warning.walletNotSynced=กระเป๋า Haveno ไม่ได้ปรับข้อมูลกับความสูงของบล็อกเชนล่าสุด โปรดรอให้กระเป๋าปรับข้อมูลหรือตรวจสอบการเชื่อมต่อของคุณ popup.warning.removeOffer=คุณแน่ใจหรือไม่ว่าต้องการนำข้อเสนอนั้นออก popup.warning.tooLargePercentageValue=คุณไม่สามารถกำหนดเปอร์เซ็นต์เป็น 100% หรือมากกว่าได้ popup.warning.examplePercentageValue=โปรดป้อนตัวเลขเปอร์เซ็นต์เช่น \"5.4 \" เป็น 5.4% diff --git a/core/src/main/resources/i18n/displayStrings_vi.properties b/core/src/main/resources/i18n/displayStrings_vi.properties index 8ace0e63f5..08bae4f12c 100644 --- a/core/src/main/resources/i18n/displayStrings_vi.properties +++ b/core/src/main/resources/i18n/displayStrings_vi.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=There are no mediators available. popup.warning.notFullyConnected=Bạn cần phải đợi cho đến khi kết nối hoàn toàn với mạng.\nĐiều này mất khoảng 2 phút khi khởi động. popup.warning.notSufficientConnectionsToXmrNetwork=Bạn cần phải đợi cho đến khi bạn có ít nhất {0} kết nối với mạng Monero. popup.warning.downloadNotComplete=Bạn cần phải đợi cho đến khi download xong các block Monero còn thiếu. -popup.warning.chainNotSynced=Ví Haveno chưa được đồng bộ với chiều cao khối chuỗi khối mới nhất. Vui lòng đợi cho đến khi ví được đồng bộ hoặc kiểm tra kết nối của bạn. +popup.warning.walletNotSynced=Ví Haveno chưa được đồng bộ với chiều cao khối chuỗi khối mới nhất. Vui lòng đợi cho đến khi ví được đồng bộ hoặc kiểm tra kết nối của bạn. popup.warning.removeOffer=Bạn có chắc bạn muốn gỡ bỏ Báo giá này? popup.warning.tooLargePercentageValue=Bạn không thể cài đặt phần trăm là 100% hoặc cao hơn. popup.warning.examplePercentageValue=Vui lòng nhập số phần trăm như \"5.4\" cho 5,4% diff --git a/core/src/main/resources/i18n/displayStrings_zh-hans.properties b/core/src/main/resources/i18n/displayStrings_zh-hans.properties index 00331d05d4..b1a359231f 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hans.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hans.properties @@ -1583,7 +1583,7 @@ popup.warning.noMediatorsAvailable=没有调解员可用。 popup.warning.notFullyConnected=您需要等到您完全连接到网络\n在启动时可能需要2分钟。 popup.warning.notSufficientConnectionsToXmrNetwork=你需要等待至少有{0}个与比特币网络的连接点。 popup.warning.downloadNotComplete=您需要等待,直到丢失的比特币区块被下载完毕。 -popup.warning.chainNotSynced=Haveno 钱包尚未与最新的区块链高度同步。请等待钱包同步完成或检查您的连接。 +popup.warning.walletNotSynced=Haveno 钱包尚未与最新的区块链高度同步。请等待钱包同步完成或检查您的连接。 popup.warning.removeOffer=您确定要移除该报价吗? popup.warning.tooLargePercentageValue=您不能设置100%或更大的百分比。 popup.warning.examplePercentageValue=请输入百分比数字,如 5.4% 是“5.4” diff --git a/core/src/main/resources/i18n/displayStrings_zh-hant.properties b/core/src/main/resources/i18n/displayStrings_zh-hant.properties index 610de8f57c..fcea1406c4 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hant.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hant.properties @@ -1581,7 +1581,7 @@ popup.warning.noMediatorsAvailable=沒有調解員可用。 popup.warning.notFullyConnected=您需要等到您完全連接到網絡\n在啟動時可能需要2分鐘。 popup.warning.notSufficientConnectionsToXmrNetwork=你需要等待至少有{0}個與比特幣網絡的連接點。 popup.warning.downloadNotComplete=您需要等待,直到丟失的比特幣區塊被下載完畢。 -popup.warning.chainNotSynced=Haveno 錢包尚未與最新的區塊鏈高度同步。請等待錢包同步完成或檢查您的連接。 +popup.warning.walletNotSynced=Haveno 錢包尚未與最新的區塊鏈高度同步。請等待錢包同步完成或檢查您的連接。 popup.warning.removeOffer=您確定要移除該報價嗎? popup.warning.tooLargePercentageValue=您不能設置100%或更大的百分比。 popup.warning.examplePercentageValue=請輸入百分比數字,如 5.4% 是“5.4” diff --git a/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java b/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java index 360b0f5af1..a0eac01fa7 100644 --- a/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java @@ -172,7 +172,7 @@ public class TxIdTextField extends AnchorPane { MoneroTx tx = null; try { tx = useCache ? xmrWalletService.getTxWithCache(txId) : xmrWalletService.getTx(txId); - tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionsService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet + tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet } catch (Exception e) { // do nothing } diff --git a/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java b/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java index 61b49614d8..9b09e8c963 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java @@ -193,7 +193,7 @@ public class WithdrawalView extends ActivatableView { /////////////////////////////////////////////////////////////////////////////////////////// private void onWithdraw() { - if (GUIUtil.isReadyForTxBroadcastOrShowPopup(xmrWalletService.getConnectionsService())) { + if (GUIUtil.isReadyForTxBroadcastOrShowPopup(xmrWalletService)) { try { // get withdraw address diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java index 623940f45d..9daf6a561c 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -553,7 +553,7 @@ abstract class OfferBookViewModel extends ActivatableViewModel { boolean canCreateOrTakeOffer() { return GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation) && - GUIUtil.isChainHeightSyncedWithinToleranceOrShowPopup(openOfferManager.getXmrConnectionService()) && + GUIUtil.isWalletSyncedWithinToleranceOrShowPopup(openOfferManager.getXmrWalletService()) && GUIUtil.isBootstrappedOrShowPopup(p2PService); } diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java index b7a9df864f..5c1acd4754 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java @@ -544,7 +544,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { } public boolean isReadyForTxBroadcast() { - return GUIUtil.isBootstrappedOrShowPopup(p2PService) && GUIUtil.isReadyForTxBroadcastOrShowPopup(xmrConnectionService); + return GUIUtil.isBootstrappedOrShowPopup(p2PService) && GUIUtil.isReadyForTxBroadcastOrShowPopup(xmrWalletService); } public boolean isBootstrappedOrShowPopup() { diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index d32d0307e8..1f5c0d1ecd 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -689,7 +689,8 @@ public class GUIUtil { return false; } - public static boolean isReadyForTxBroadcastOrShowPopup(XmrConnectionService xmrConnectionService) { + public static boolean isReadyForTxBroadcastOrShowPopup(XmrWalletService xmrWalletService) { + XmrConnectionService xmrConnectionService = xmrWalletService.getConnectionService(); if (!xmrConnectionService.hasSufficientPeersForBroadcast()) { new Popup().information(Res.get("popup.warning.notSufficientConnectionsToXmrNetwork", xmrConnectionService.getMinBroadcastConnections())).show(); return false; @@ -700,6 +701,10 @@ public class GUIUtil { return false; } + if (!isWalletSyncedWithinToleranceOrShowPopup(xmrWalletService)) { + return false; + } + try { xmrConnectionService.verifyConnection(); } catch (Exception e) { @@ -710,12 +715,11 @@ public class GUIUtil { return true; } - public static boolean isChainHeightSyncedWithinToleranceOrShowPopup(XmrConnectionService xmrConnectionService) { - if (!xmrConnectionService.isSyncedWithinTolerance()) { - new Popup().information(Res.get("popup.warning.chainNotSynced")).show(); + public static boolean isWalletSyncedWithinToleranceOrShowPopup(XmrWalletService xmrWalletService) { + if (!xmrWalletService.isSyncedWithinTolerance()) { + new Popup().information(Res.get("popup.warning.walletNotSynced")).show(); return false; } - return true; }