From f7dfcd96367418b9d930f194bba714e342439961 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Tue, 20 Oct 2020 19:20:27 -0500 Subject: [PATCH 1/2] Show current tx fee rate on main screen Tx fee rate is shown in the footer alongside "Synchronized with Bitcoin Mainnet (using Tor) (x sat/vB)". Fixes #4412 --- core/src/main/java/bisq/core/app/WalletAppSetup.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index 74049ae6376..ed123fab97b 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -22,6 +22,7 @@ import bisq.core.btc.setup.WalletsSetup; import bisq.core.btc.wallet.WalletsManager; import bisq.core.locale.Res; +import bisq.core.provider.fee.FeeService; import bisq.core.offer.OpenOfferManager; import bisq.core.trade.TradeManager; import bisq.core.user.Preferences; @@ -64,6 +65,7 @@ public class WalletAppSetup { private final WalletsManager walletsManager; private final WalletsSetup walletsSetup; + private final FeeService feeService; private final Config config; private final Preferences preferences; @@ -88,10 +90,12 @@ public class WalletAppSetup { @Inject public WalletAppSetup(WalletsManager walletsManager, WalletsSetup walletsSetup, + FeeService feeService, Config config, Preferences preferences) { this.walletsManager = walletsManager; this.walletsSetup = walletsSetup; + this.feeService = feeService; this.config = config; this.preferences = preferences; this.useTorForBTC.set(preferences.getUseTorForBitcoinJ()); @@ -110,18 +114,20 @@ void init(@Nullable Consumer chainFileLockedExceptionHandler, ObjectProperty walletServiceException = new SimpleObjectProperty<>(); btcInfoBinding = EasyBind.combine(walletsSetup.downloadPercentageProperty(), walletsSetup.numPeersProperty(), + feeService.feeUpdateCounterProperty(), walletServiceException, - (downloadPercentage, numPeers, exception) -> { + (downloadPercentage, numPeers, feeUpdate, exception) -> { String result; if (exception == null) { double percentage = (double) downloadPercentage; int peers = (int) numPeers; + long fees = feeService.getTxFeePerByte().longValue(); btcSyncProgress.set(percentage); if (percentage == 1) { result = Res.get("mainView.footer.btcInfo", peers, Res.get("mainView.footer.btcInfo.synchronizedWith"), - getBtcNetworkAsString()); + getBtcNetworkAsString() + " (" + fees + " sat/vB)"); getBtcSplashSyncIconId().set("image-connection-synced"); downloadCompleteHandler.run(); From 7c7887d91f52bb637fd13d455b78870fbb3c58b4 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Thu, 22 Oct 2020 22:01:37 -0500 Subject: [PATCH 2/2] Changes requested: Shorten "synchronized" to "synced" Move Bitcoin network peer count to right with Bisq network peer count Moved "Synchronizing DAO" to center for clarity/balance. --- .../java/bisq/core/app/P2PNetworkSetup.java | 17 +++++++---- .../java/bisq/core/app/WalletAppSetup.java | 15 ++-------- .../resources/i18n/displayStrings.properties | 7 +++-- .../main/java/bisq/desktop/main/MainView.java | 28 +++++++++---------- .../java/bisq/desktop/main/MainViewModel.java | 19 ++++++++++++- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java index 76527919dc4..0516863c91a 100644 --- a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java @@ -17,6 +17,7 @@ package bisq.core.app; +import bisq.core.btc.setup.WalletsSetup; import bisq.core.locale.Res; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; @@ -50,6 +51,7 @@ public class P2PNetworkSetup { private final PriceFeedService priceFeedService; private final P2PService p2PService; + private final WalletsSetup walletsSetup; private final Preferences preferences; @SuppressWarnings("FieldCanBeLocal") @@ -73,10 +75,12 @@ public class P2PNetworkSetup { @Inject public P2PNetworkSetup(PriceFeedService priceFeedService, P2PService p2PService, + WalletsSetup walletsSetup, Preferences preferences) { this.priceFeedService = priceFeedService; this.p2PService = p2PService; + this.walletsSetup = walletsSetup; this.preferences = preferences; } @@ -86,18 +90,19 @@ BooleanProperty init(Runnable initWalletServiceHandler, @Nullable Consumer { + p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), + walletsSetup.numPeersProperty(), hiddenServicePublished, initialP2PNetworkDataReceived, + (state, warning, numP2pPeers, numBtcPeers, hiddenService, dataReceived) -> { String result; String daoFullNode = preferences.isDaoFullNode() ? Res.get("mainView.footer.daoFullNode") + " / " : ""; - int peers = (int) numPeers; - if (warning != null && peers == 0) { + int p2pPeers = (int) numP2pPeers; + if (warning != null && p2pPeers == 0) { result = warning; } else { - String p2pInfo = Res.get("mainView.footer.p2pInfo", numPeers); + String p2pInfo = Res.get("mainView.footer.p2pInfo", numBtcPeers, numP2pPeers); if (dataReceived && hiddenService) { result = p2pInfo; - } else if (peers == 0) + } else if (p2pPeers == 0) result = state; else result = state + " / " + p2pInfo; diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index ed123fab97b..b299a6f98fe 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -83,8 +83,6 @@ public class WalletAppSetup { @Getter private final ObjectProperty rejectedTxException = new SimpleObjectProperty<>(); @Getter - private int numBtcPeers = 0; - @Getter private final BooleanProperty useTorForBTC = new SimpleBooleanProperty(); @Inject @@ -113,38 +111,33 @@ void init(@Nullable Consumer chainFileLockedExceptionHandler, ObjectProperty walletServiceException = new SimpleObjectProperty<>(); btcInfoBinding = EasyBind.combine(walletsSetup.downloadPercentageProperty(), - walletsSetup.numPeersProperty(), feeService.feeUpdateCounterProperty(), walletServiceException, - (downloadPercentage, numPeers, feeUpdate, exception) -> { + (downloadPercentage, feeUpdate, exception) -> { String result; if (exception == null) { double percentage = (double) downloadPercentage; - int peers = (int) numPeers; long fees = feeService.getTxFeePerByte().longValue(); btcSyncProgress.set(percentage); if (percentage == 1) { + String feeRate = Res.get("mainView.footer.btcFeeRate", fees); result = Res.get("mainView.footer.btcInfo", - peers, Res.get("mainView.footer.btcInfo.synchronizedWith"), - getBtcNetworkAsString() + " (" + fees + " sat/vB)"); + getBtcNetworkAsString() + " / " + feeRate); getBtcSplashSyncIconId().set("image-connection-synced"); downloadCompleteHandler.run(); } else if (percentage > 0.0) { result = Res.get("mainView.footer.btcInfo", - peers, Res.get("mainView.footer.btcInfo.synchronizingWith"), getBtcNetworkAsString() + ": " + FormattingUtils.formatToPercentWithSymbol(percentage)); } else { result = Res.get("mainView.footer.btcInfo", - peers, Res.get("mainView.footer.btcInfo.connectingTo"), getBtcNetworkAsString()); } } else { result = Res.get("mainView.footer.btcInfo", - getNumBtcPeers(), Res.get("mainView.footer.btcInfo.connectionFailed"), getBtcNetworkAsString()); log.error(exception.toString()); @@ -170,8 +163,6 @@ void init(@Nullable Consumer chainFileLockedExceptionHandler, walletsSetup.initialize(null, () -> { - numBtcPeers = walletsSetup.numPeersProperty().get(); - // We only check one wallet as we apply encryption to all or none if (walletsManager.areWalletsEncrypted()) { walletPasswordHandler.run(); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 3afb4f273af..8e8369af490 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -252,14 +252,15 @@ mainView.balance.locked.short=Locked mainView.footer.usingTor=(using Tor) mainView.footer.localhostBitcoinNode=(localhost) -mainView.footer.btcInfo=Bitcoin network peers: {0} / {1} {2} +mainView.footer.btcInfo={0} {1} +mainView.footer.btcFeeRate=Current fee rate: {0} sat/vB mainView.footer.btcInfo.initializing=Connecting to Bitcoin network mainView.footer.bsqInfo.synchronizing=/ Synchronizing DAO mainView.footer.btcInfo.synchronizingWith=Synchronizing with -mainView.footer.btcInfo.synchronizedWith=Synchronized with +mainView.footer.btcInfo.synchronizedWith=Synced with mainView.footer.btcInfo.connectingTo=Connecting to mainView.footer.btcInfo.connectionFailed=Connection failed to -mainView.footer.p2pInfo=Bisq network peers: {0} +mainView.footer.p2pInfo=Bitcoin network peers: {0} / Bisq network peers: {1} mainView.footer.daoFullNode=DAO full node mainView.bootstrapState.connectionToTorNetwork=(1/4) Connecting to Tor network... diff --git a/desktop/src/main/java/bisq/desktop/main/MainView.java b/desktop/src/main/java/bisq/desktop/main/MainView.java index 2af3ad2db8e..321235521dc 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainView.java +++ b/desktop/src/main/java/bisq/desktop/main/MainView.java @@ -51,7 +51,6 @@ import bisq.common.BisqException; import bisq.common.Timer; import bisq.common.UserThread; -import bisq.common.app.Version; import bisq.common.util.Tuple2; import bisq.common.util.Utilities; @@ -115,7 +114,6 @@ public class MainView extends InitializableView implements DaoStateMonitoringService.Listener { // If after 30 sec we have not got connected we show "open network settings" button private final static int SHOW_TOR_SETTINGS_DELAY_SEC = 90; - private Label versionLabel; @Setter private Runnable onApplicationStartedHandler; @@ -687,6 +685,8 @@ private AnchorPane createFooter() { Label btcInfoLabel = new AutoTooltipLabel(); btcInfoLabel.setId("footer-pane"); btcInfoLabel.textProperty().bind(model.getBtcInfo()); + setLeftAnchor(btcInfoLabel, 10d); + setBottomAnchor(btcInfoLabel, 7d); ProgressBar blockchainSyncIndicator = new JFXProgressBar(-1); blockchainSyncIndicator.setPrefWidth(80); @@ -715,34 +715,32 @@ private AnchorPane createFooter() { } }); - HBox blockchainSyncBox = new HBox(); - blockchainSyncBox.setSpacing(10); - blockchainSyncBox.setAlignment(Pos.CENTER); - blockchainSyncBox.getChildren().addAll(btcInfoLabel, blockchainSyncIndicator); - setLeftAnchor(blockchainSyncBox, 10d); - setBottomAnchor(blockchainSyncBox, 7d); - // version - versionLabel = new AutoTooltipLabel(); + Label versionLabel = new AutoTooltipLabel(); versionLabel.setId("footer-pane"); versionLabel.setTextAlignment(TextAlignment.CENTER); versionLabel.setAlignment(Pos.BASELINE_CENTER); - versionLabel.setText("v" + Version.VERSION); + versionLabel.textProperty().bind(model.getCombinedFooterInfo()); root.widthProperty().addListener((ov, oldValue, newValue) -> versionLabel.setLayoutX(((double) newValue - versionLabel.getWidth()) / 2)); - setBottomAnchor(versionLabel, 7d); model.getNewVersionAvailableProperty().addListener((observable, oldValue, newValue) -> { versionLabel.getStyleClass().removeAll("version-new", "version"); if (newValue) { versionLabel.getStyleClass().add("version-new"); versionLabel.setOnMouseClicked(e -> model.onOpenDownloadWindow()); - versionLabel.setText("v" + Version.VERSION + " " + Res.get("mainView.version.update")); } else { versionLabel.getStyleClass().add("version"); versionLabel.setOnMouseClicked(null); - versionLabel.setText("v" + Version.VERSION); } }); + HBox versionBox = new HBox(); + versionBox.setSpacing(10); + versionBox.setAlignment(Pos.CENTER); + versionBox.setAlignment(Pos.BASELINE_CENTER); + versionBox.getChildren().addAll(versionLabel, blockchainSyncIndicator); + setLeftAnchor(versionBox, 10d); + setRightAnchor(versionBox, 10d); + setBottomAnchor(versionBox, 7d); // P2P Network Label p2PNetworkLabel = new AutoTooltipLabel(); @@ -779,7 +777,7 @@ private AnchorPane createFooter() { setRightAnchor(vBox, 33d); setBottomAnchor(vBox, 5d); - return new AnchorPane(separator, blockchainSyncBox, versionLabel, vBox, p2PNetworkIcon) {{ + return new AnchorPane(separator, btcInfoLabel, versionBox, vBox, p2PNetworkIcon) {{ setId("footer-pane"); setMinHeight(30); setMaxHeight(30); diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index d892c1322c5..c2815370c53 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -67,6 +67,7 @@ import bisq.common.Timer; import bisq.common.UserThread; import bisq.common.app.DevEnv; +import bisq.common.app.Version; import bisq.common.config.Config; import bisq.common.file.CorruptedStorageFileHandler; @@ -133,6 +134,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { private final BooleanProperty showAppScreen = new SimpleBooleanProperty(); private final DoubleProperty combinedSyncProgress = new SimpleDoubleProperty(-1); private final BooleanProperty isSplashScreenRemoved = new SimpleBooleanProperty(); + private final StringProperty footerVersionInfo = new SimpleStringProperty(); private Timer checkNumberOfBtcPeersTimer; private Timer checkNumberOfP2pNetworkPeersTimer; @SuppressWarnings("FieldCanBeLocal") @@ -414,6 +416,15 @@ private void setupHandlers() { daoPresentation.getBsqSyncProgress().addListener((observable, oldValue, newValue) -> updateBtcSyncProgress()); bisqSetup.setFilterWarningHandler(warning -> new Popup().warning(warning).show()); + + this.footerVersionInfo.setValue("v" + Version.VERSION); + this.getNewVersionAvailableProperty().addListener((observable, oldValue, newValue) -> { + if (newValue) { + this.footerVersionInfo.setValue("v" + Version.VERSION + " " + Res.get("mainView.version.update")); + } else { + this.footerVersionInfo.setValue("v" + Version.VERSION); + } + }); } private void showRevolutAccountUpdateWindow(List revolutAccountList) { @@ -596,7 +607,13 @@ StringProperty getLockedBalance() { // Wallet StringProperty getBtcInfo() { final StringProperty combinedInfo = new SimpleStringProperty(); - combinedInfo.bind(Bindings.concat(bisqSetup.getBtcInfo(), " ", daoPresentation.getBsqInfo())); + combinedInfo.bind(bisqSetup.getBtcInfo()); + return combinedInfo; + } + + StringProperty getCombinedFooterInfo() { + final StringProperty combinedInfo = new SimpleStringProperty(); + combinedInfo.bind(Bindings.concat(this.footerVersionInfo, " ", daoPresentation.getBsqInfo())); return combinedInfo; }