mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-13 08:55:31 -04:00
remove dependency on local BTC node
Co-authored-by: premek <1145361+premek@users.noreply.github.com>
This commit is contained in:
parent
1b78be689a
commit
9059974725
13 changed files with 143 additions and 161 deletions
|
@ -17,28 +17,28 @@
|
|||
|
||||
package bisq.desktop.main.settings.network;
|
||||
|
||||
import org.bitcoinj.core.Peer;
|
||||
import monero.daemon.model.MoneroDaemonConnection;
|
||||
|
||||
public class BitcoinNetworkListItem {
|
||||
private final Peer peer;
|
||||
public class MoneroNetworkListItem {
|
||||
private final MoneroDaemonConnection peerConnection;
|
||||
|
||||
public BitcoinNetworkListItem(Peer peer) {
|
||||
this.peer = peer;
|
||||
public MoneroNetworkListItem(MoneroDaemonConnection peerConnection) {
|
||||
this.peerConnection = peerConnection;
|
||||
}
|
||||
|
||||
public String getOnionAddress() {
|
||||
return peer.getAddress().toString();
|
||||
return peerConnection.getPeer().getHost() + ":" + peerConnection.getPeer().getPort();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return String.valueOf(peer.getPeerVersionMessage().clientVersion);
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getSubVersion() {
|
||||
return peer.getPeerVersionMessage().subVer;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getHeight() {
|
||||
return String.valueOf(peer.getBestHeight());
|
||||
return String.valueOf(peerConnection.getHeight());
|
||||
}
|
||||
}
|
|
@ -46,24 +46,24 @@
|
|||
<TitledGroupBg fx:id="btcHeader" GridPane.rowSpan="5"/>
|
||||
<VBox GridPane.rowIndex="0" GridPane.hgrow="ALWAYS" GridPane.vgrow="SOMETIMES">
|
||||
<AutoTooltipLabel fx:id="bitcoinPeersLabel" styleClass="small-text"/>
|
||||
<TableView fx:id="bitcoinPeersTableView">
|
||||
<TableView fx:id="moneroPeersTableView">
|
||||
<columns>
|
||||
<TableColumn fx:id="bitcoinPeerAddressColumn" minWidth="220">
|
||||
<TableColumn fx:id="moneroPeerAddressColumn" minWidth="220">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="onionAddress"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="bitcoinPeerVersionColumn" minWidth="80" maxWidth="90">
|
||||
<TableColumn fx:id="moneroPeerVersionColumn" minWidth="80" maxWidth="90">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="version"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="bitcoinPeerSubVersionColumn" minWidth="180" maxWidth="180">
|
||||
<TableColumn fx:id="moneroPeerSubVersionColumn" minWidth="180" maxWidth="180">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="subVersion"/>
|
||||
</cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="bitcoinPeerHeightColumn" minWidth="80" maxWidth="80">
|
||||
<TableColumn fx:id="moneroPeerHeightColumn" minWidth="80" maxWidth="80">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="height"/>
|
||||
</cellValueFactory>
|
||||
|
|
|
@ -45,8 +45,6 @@ import bisq.network.p2p.network.Statistic;
|
|||
import bisq.common.ClockWatcher;
|
||||
import bisq.common.UserThread;
|
||||
|
||||
import org.bitcoinj.core.PeerGroup;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -73,11 +71,14 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
||||
import monero.daemon.model.MoneroDaemonConnection;
|
||||
|
||||
@FxmlView
|
||||
public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
|
@ -98,13 +99,13 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
@FXML
|
||||
TableView<P2pNetworkListItem> p2pPeersTableView;
|
||||
@FXML
|
||||
TableView<BitcoinNetworkListItem> bitcoinPeersTableView;
|
||||
TableView<MoneroNetworkListItem> moneroPeersTableView;
|
||||
@FXML
|
||||
TableColumn<P2pNetworkListItem, String> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
||||
roundTripTimeColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
||||
@FXML
|
||||
TableColumn<BitcoinNetworkListItem, String> bitcoinPeerAddressColumn, bitcoinPeerVersionColumn,
|
||||
bitcoinPeerSubVersionColumn, bitcoinPeerHeightColumn;
|
||||
TableColumn<MoneroNetworkListItem, String> moneroPeerAddressColumn, moneroPeerVersionColumn,
|
||||
moneroPeerSubVersionColumn, moneroPeerHeightColumn;
|
||||
@FXML
|
||||
Label reSyncSPVChainLabel;
|
||||
@FXML
|
||||
|
@ -122,13 +123,12 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
private final ObservableList<P2pNetworkListItem> p2pNetworkListItems = FXCollections.observableArrayList();
|
||||
private final SortedList<P2pNetworkListItem> p2pSortedList = new SortedList<>(p2pNetworkListItems);
|
||||
|
||||
private final ObservableList<BitcoinNetworkListItem> bitcoinNetworkListItems = FXCollections.observableArrayList();
|
||||
private final SortedList<BitcoinNetworkListItem> bitcoinSortedList = new SortedList<>(bitcoinNetworkListItems);
|
||||
private final ObservableList<MoneroNetworkListItem> moneroNetworkListItems = FXCollections.observableArrayList();
|
||||
private final SortedList<MoneroNetworkListItem> moneroSortedList = new SortedList<>(moneroNetworkListItems);
|
||||
|
||||
private Subscription numP2PPeersSubscription;
|
||||
private Subscription bitcoinPeersSubscription;
|
||||
private Subscription bitcoinBlockHeightSubscription;
|
||||
private Subscription bitcoinBlocksDownloadedSubscription;
|
||||
private Subscription moneroPeersSubscription;
|
||||
private Subscription moneroBlockHeightSubscription;
|
||||
private Subscription nodeAddressSubscription;
|
||||
private ChangeListener<Boolean> btcNodesInputTextFieldFocusListener;
|
||||
private ToggleGroup bitcoinPeersToggleGroup;
|
||||
|
@ -156,6 +156,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
this.clockWatcher = clockWatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
btcHeader.setText(Res.get("settings.net.btcHeader"));
|
||||
p2pHeader.setText(Res.get("settings.net.p2pHeader"));
|
||||
|
@ -164,11 +165,11 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
bitcoinPeersLabel.setText(Res.get("settings.net.bitcoinPeersLabel"));
|
||||
useTorForBtcJCheckBox.setText(Res.get("settings.net.useTorForBtcJLabel"));
|
||||
bitcoinNodesLabel.setText(Res.get("settings.net.bitcoinNodesLabel"));
|
||||
bitcoinPeerAddressColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.onionAddressColumn")));
|
||||
bitcoinPeerAddressColumn.getStyleClass().add("first-column");
|
||||
bitcoinPeerVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.versionColumn")));
|
||||
bitcoinPeerSubVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.subVersionColumn")));
|
||||
bitcoinPeerHeightColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.heightColumn")));
|
||||
moneroPeerAddressColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.onionAddressColumn")));
|
||||
moneroPeerAddressColumn.getStyleClass().add("first-column");
|
||||
moneroPeerVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.versionColumn")));
|
||||
moneroPeerSubVersionColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.subVersionColumn")));
|
||||
moneroPeerHeightColumn.setGraphic(new AutoTooltipLabel(Res.get("settings.net.heightColumn")));
|
||||
localhostBtcNodeInfoLabel.setText(Res.get("settings.net.localhostBtcNodeInfo"));
|
||||
useProvidedNodesRadio.setText(Res.get("settings.net.useProvidedNodesRadio"));
|
||||
useCustomNodesRadio.setText(Res.get("settings.net.useCustomNodesRadio"));
|
||||
|
@ -196,12 +197,12 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
GridPane.setMargin(p2PPeersLabel, new Insets(4, 0, 0, 0));
|
||||
GridPane.setValignment(p2PPeersLabel, VPos.TOP);
|
||||
|
||||
bitcoinPeersTableView.setMinHeight(180);
|
||||
bitcoinPeersTableView.setPrefHeight(180);
|
||||
bitcoinPeersTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
bitcoinPeersTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
bitcoinPeersTableView.getSortOrder().add(bitcoinPeerAddressColumn);
|
||||
bitcoinPeerAddressColumn.setSortType(TableColumn.SortType.ASCENDING);
|
||||
moneroPeersTableView.setMinHeight(180);
|
||||
moneroPeersTableView.setPrefHeight(180);
|
||||
moneroPeersTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
moneroPeersTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
moneroPeersTableView.getSortOrder().add(moneroPeerAddressColumn);
|
||||
moneroPeerAddressColumn.setSortType(TableColumn.SortType.ASCENDING);
|
||||
|
||||
|
||||
p2pPeersTableView.setMinHeight(180);
|
||||
|
@ -290,14 +291,11 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));
|
||||
|
||||
bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(),
|
||||
connectedPeers -> updateBitcoinPeersTable());
|
||||
moneroPeersSubscription = EasyBind.subscribe(walletsSetup.peerConnectionsProperty(),
|
||||
this::updateMoneroPeersTable);
|
||||
|
||||
bitcoinBlocksDownloadedSubscription = EasyBind.subscribe(walletsSetup.blocksDownloadedFromPeerProperty(),
|
||||
peer -> updateBitcoinPeersTable());
|
||||
|
||||
bitcoinBlockHeightSubscription = EasyBind.subscribe(walletsSetup.chainHeightProperty(),
|
||||
chainHeight -> updateBitcoinPeersTable());
|
||||
moneroBlockHeightSubscription = EasyBind.subscribe(walletsSetup.chainHeightProperty(),
|
||||
this::updateChainHeightTextField);
|
||||
|
||||
nodeAddressSubscription = EasyBind.subscribe(p2PService.getNetworkNode().nodeAddressProperty(),
|
||||
nodeAddress -> onionAddress.setText(nodeAddress == null ?
|
||||
|
@ -317,8 +315,8 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
Statistic.numTotalReceivedMessagesPerSecProperty().get()),
|
||||
Statistic.numTotalReceivedMessagesPerSecProperty()));
|
||||
|
||||
bitcoinSortedList.comparatorProperty().bind(bitcoinPeersTableView.comparatorProperty());
|
||||
bitcoinPeersTableView.setItems(bitcoinSortedList);
|
||||
moneroSortedList.comparatorProperty().bind(moneroPeersTableView.comparatorProperty());
|
||||
moneroPeersTableView.setItems(moneroSortedList);
|
||||
|
||||
p2pSortedList.comparatorProperty().bind(p2pPeersTableView.comparatorProperty());
|
||||
p2pPeersTableView.setItems(p2pSortedList);
|
||||
|
@ -340,14 +338,11 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
if (nodeAddressSubscription != null)
|
||||
nodeAddressSubscription.unsubscribe();
|
||||
|
||||
if (bitcoinPeersSubscription != null)
|
||||
bitcoinPeersSubscription.unsubscribe();
|
||||
if (moneroPeersSubscription != null)
|
||||
moneroPeersSubscription.unsubscribe();
|
||||
|
||||
if (bitcoinBlockHeightSubscription != null)
|
||||
bitcoinBlockHeightSubscription.unsubscribe();
|
||||
|
||||
if (bitcoinBlocksDownloadedSubscription != null)
|
||||
bitcoinBlocksDownloadedSubscription.unsubscribe();
|
||||
if (moneroBlockHeightSubscription != null)
|
||||
moneroBlockHeightSubscription.unsubscribe();
|
||||
|
||||
if (numP2PPeersSubscription != null)
|
||||
numP2PPeersSubscription.unsubscribe();
|
||||
|
@ -355,7 +350,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
sentDataTextField.textProperty().unbind();
|
||||
receivedDataTextField.textProperty().unbind();
|
||||
|
||||
bitcoinSortedList.comparatorProperty().unbind();
|
||||
moneroSortedList.comparatorProperty().unbind();
|
||||
p2pSortedList.comparatorProperty().unbind();
|
||||
p2pPeersTableView.getItems().forEach(P2pNetworkListItem::cleanup);
|
||||
btcNodesInputTextField.focusedProperty().removeListener(btcNodesInputTextFieldFocusListener);
|
||||
|
@ -485,14 +480,17 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
|||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void updateBitcoinPeersTable() {
|
||||
bitcoinNetworkListItems.clear();
|
||||
bitcoinNetworkListItems.setAll(walletsSetup.getPeerGroup().getConnectedPeers().stream()
|
||||
.map(BitcoinNetworkListItem::new)
|
||||
private void updateMoneroPeersTable(List<MoneroDaemonConnection> peerConnections) {
|
||||
moneroNetworkListItems.clear();
|
||||
moneroNetworkListItems.setAll(peerConnections.stream()
|
||||
.map(MoneroNetworkListItem::new)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void updateChainHeightTextField(Number chainHeight) {
|
||||
chainHeightTextField.textProperty().setValue(Res.get("settings.net.chainHeight",
|
||||
walletsSetup.chainHeightProperty().get(),
|
||||
PeerGroup.getMostCommonChainHeight(walletsSetup.connectedPeersProperty().get())));
|
||||
null,
|
||||
chainHeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ public class GUIUtil {
|
|||
}
|
||||
|
||||
public static boolean canCreateOrTakeOfferOrShowPopup(User user, Navigation navigation) {
|
||||
|
||||
|
||||
// TODO (woodser): use refund agents to dispute arbitration?
|
||||
if (!user.hasAcceptedRefundAgents()) {
|
||||
log.warn("There are no refund agents available"); // TODO (woodser): refund agents changing from [4444] to [] causing this error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue