Merge pull request #4676 from jmacxx/show_tx_fee

Show current tx fee rate on main screen
This commit is contained in:
Christoph Atteneder 2020-10-24 11:40:34 +02:00 committed by GitHub
commit 55c663ad47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 37 deletions

View file

@ -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 @@ import javax.annotation.Nullable;
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 @@ public class P2PNetworkSetup {
BooleanProperty hiddenServicePublished = new SimpleBooleanProperty();
BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty();
p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), hiddenServicePublished, initialP2PNetworkDataReceived,
(state, warning, numPeers, hiddenService, dataReceived) -> {
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;

View file

@ -22,6 +22,7 @@ import bisq.core.btc.exceptions.RejectedTxException;
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;
@ -81,17 +83,17 @@ public class WalletAppSetup {
@Getter
private final ObjectProperty<RejectedTxException> rejectedTxException = new SimpleObjectProperty<>();
@Getter
private int numBtcPeers = 0;
@Getter
private final BooleanProperty useTorForBTC = new SimpleBooleanProperty();
@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());
@ -109,36 +111,33 @@ public class WalletAppSetup {
ObjectProperty<Throwable> walletServiceException = new SimpleObjectProperty<>();
btcInfoBinding = EasyBind.combine(walletsSetup.downloadPercentageProperty(),
walletsSetup.numPeersProperty(),
feeService.feeUpdateCounterProperty(),
walletServiceException,
(downloadPercentage, numPeers, 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());
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());
@ -164,8 +163,6 @@ public class WalletAppSetup {
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();

View file

@ -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...

View file

@ -51,7 +51,6 @@ import bisq.core.provider.price.MarketPrice;
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<StackPane, MainViewModel>
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 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
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 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
}
});
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 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
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);

View file

@ -67,6 +67,7 @@ import bisq.network.p2p.P2PService;
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 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
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<RevolutAccount> revolutAccountList) {
@ -596,7 +607,13 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
// 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;
}