mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-26 20:30:55 +01:00
Revert to using provided BTC nodes if custom nodes are invalid
If the user entered an invalid hostname for a custom BTC node, such as a V3 onion address, after restarting Bisq they would be presented with an error due to the node being unreachable and unable to continue nor correct the config. So now a warning message will be shown in this situation informing the user of an invalid config and once they restart their client they will connect to the provided BTC nodes. Fixes #3137
This commit is contained in:
parent
9e33ca9e43
commit
61d20268f2
7 changed files with 74 additions and 6 deletions
|
@ -95,6 +95,7 @@ public class BisqHeadlessApp implements HeadlessApp {
|
|||
bisqSetup.setWrongOSArchitectureHandler(msg -> log.error("onWrongOSArchitectureHandler. msg={}", msg));
|
||||
bisqSetup.setVoteResultExceptionHandler(voteResultException -> log.warn("voteResultException={}", voteResultException.toString()));
|
||||
bisqSetup.setRejectedTxErrorMessageHandler(errorMessage -> log.warn("setRejectedTxErrorMessageHandler. errorMessage={}", errorMessage));
|
||||
bisqSetup.setShowPopupIfInvalidBtcConfigHandler(() -> log.error("onShowPopupIfInvalidBtcConfigHandler"));
|
||||
|
||||
//TODO move to bisqSetup
|
||||
corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> log.warn("getCorruptedDatabaseFiles. files={}", files));
|
||||
|
|
|
@ -222,6 +222,9 @@ public class BisqSetup {
|
|||
@Setter
|
||||
@Nullable
|
||||
private Consumer<PrivateNotificationPayload> displayPrivateNotificationHandler;
|
||||
@Setter
|
||||
@Nullable
|
||||
private Runnable showPopupIfInvalidBtcConfigHandler;
|
||||
|
||||
@Getter
|
||||
final BooleanProperty newVersionAvailableProperty = new SimpleBooleanProperty(false);
|
||||
|
@ -545,9 +548,9 @@ public class BisqSetup {
|
|||
};
|
||||
|
||||
Timer startupTimeout = UserThread.runAfter(() -> {
|
||||
if (p2PNetworkSetup.p2pNetworkFailed.get()) {
|
||||
// Skip this timeout action if the p2p network setup failed
|
||||
// since a p2p network error prompt will be shown containing the error message
|
||||
if (p2PNetworkSetup.p2pNetworkFailed.get() || walletsSetup.walletsSetupFailed.get()) {
|
||||
// Skip this timeout action if the p2p network or wallet setup failed
|
||||
// since an error prompt will be shown containing the error message
|
||||
return;
|
||||
}
|
||||
log.warn("startupTimeout called");
|
||||
|
@ -614,6 +617,7 @@ public class BisqSetup {
|
|||
walletAppSetup.init(chainFileLockedExceptionHandler,
|
||||
spvFileCorruptedHandler,
|
||||
showFirstPopupIfResyncSPVRequestedHandler,
|
||||
showPopupIfInvalidBtcConfigHandler,
|
||||
walletPasswordHandler,
|
||||
() -> {
|
||||
if (allBasicServicesInitialized) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.app;
|
||||
|
||||
import bisq.core.btc.exceptions.InvalidHostException;
|
||||
import bisq.core.btc.exceptions.RejectedTxException;
|
||||
import bisq.core.btc.setup.WalletsSetup;
|
||||
import bisq.core.btc.wallet.WalletsManager;
|
||||
|
@ -92,6 +93,7 @@ public class WalletAppSetup {
|
|||
void init(@Nullable Consumer<String> chainFileLockedExceptionHandler,
|
||||
@Nullable Consumer<String> spvFileCorruptedHandler,
|
||||
@Nullable Runnable showFirstPopupIfResyncSPVRequestedHandler,
|
||||
@Nullable Runnable showPopupIfInvalidBtcConfigHandler,
|
||||
Runnable walletPasswordHandler,
|
||||
Runnable downloadCompleteHandler,
|
||||
Runnable walletInitializedHandler) {
|
||||
|
@ -169,7 +171,13 @@ public class WalletAppSetup {
|
|||
}
|
||||
}
|
||||
},
|
||||
walletServiceException::set);
|
||||
exception -> {
|
||||
if (exception instanceof InvalidHostException && showPopupIfInvalidBtcConfigHandler != null) {
|
||||
showPopupIfInvalidBtcConfigHandler.run();
|
||||
} else {
|
||||
walletServiceException.set(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getBtcNetworkAsString() {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.btc.exceptions;
|
||||
|
||||
public class InvalidHostException extends IllegalArgumentException {
|
||||
|
||||
public InvalidHostException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ package bisq.core.btc.setup;
|
|||
|
||||
import bisq.core.app.BisqEnvironment;
|
||||
import bisq.core.btc.BtcOptionKeys;
|
||||
import bisq.core.btc.exceptions.InvalidHostException;
|
||||
import bisq.core.btc.exceptions.RejectedTxException;
|
||||
import bisq.core.btc.model.AddressEntry;
|
||||
import bisq.core.btc.model.AddressEntryList;
|
||||
|
@ -91,6 +92,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -107,6 +109,9 @@ public class WalletsSetup {
|
|||
// We reduce defaultConnections from 12 (PeerGroup.DEFAULT_CONNECTIONS) to 9 nodes
|
||||
public static final int DEFAULT_CONNECTIONS = 9;
|
||||
|
||||
@Getter
|
||||
public final BooleanProperty walletsSetupFailed = new SimpleBooleanProperty();
|
||||
|
||||
private static final long STARTUP_TIMEOUT = 180;
|
||||
private static final String BSQ_WALLET_FILE_NAME = "bisq_BSQ.wallet";
|
||||
private static final String SPV_CHAIN_FILE_NAME = "bisq.spvchain";
|
||||
|
@ -263,13 +268,27 @@ public class WalletsSetup {
|
|||
} else if (regTestHost == RegTestHost.REMOTE_HOST) {
|
||||
configPeerNodesForRegTestServer();
|
||||
} else {
|
||||
configPeerNodes(socks5Proxy);
|
||||
try {
|
||||
configPeerNodes(socks5Proxy);
|
||||
} catch (IllegalArgumentException e) {
|
||||
timeoutTimer.stop();
|
||||
walletsSetupFailed.set(true);
|
||||
exceptionHandler.handleException(new InvalidHostException(e.getMessage()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (bisqEnvironment.isBitcoinLocalhostNodeRunning()) {
|
||||
walletConfig.setMinBroadcastConnections(1);
|
||||
walletConfig.setPeerNodesForLocalHost();
|
||||
} else {
|
||||
configPeerNodes(socks5Proxy);
|
||||
try {
|
||||
configPeerNodes(socks5Proxy);
|
||||
} catch (IllegalArgumentException e) {
|
||||
timeoutTimer.stop();
|
||||
walletsSetupFailed.set(true);
|
||||
exceptionHandler.handleException(new InvalidHostException(e.getMessage()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
walletConfig.setDownloadListener(downloadListener)
|
||||
|
|
|
@ -1090,6 +1090,7 @@ settings.net.warn.useCustomNodes.B2XWarning=Please be sure that your Bitcoin nod
|
|||
Users who connect to nodes that violate consensus rules are responsible for any resulting damage. \
|
||||
Any resulting disputes will be decided in favor of the other peer. No technical support will be given \
|
||||
to users who ignore this warning and protection mechanisms!
|
||||
settings.net.warn.invalidBtcConfig=Connection to the Bitcoin network failed because your configuration is invalid.\n\nYour configuration has been reset to use the provided Bitcoin nodes instead. You will need to restart the application.
|
||||
settings.net.localhostBtcNodeInfo=(Background information: If you are running a local Bitcoin node (localhost) you can connect exclusively to it.)
|
||||
settings.net.p2PPeersLabel=Connected peers
|
||||
settings.net.onionAddressColumn=Onion address
|
||||
|
|
|
@ -368,6 +368,8 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
|
|||
|
||||
bisqSetup.setRejectedTxErrorMessageHandler(msg -> new Popup().width(850).warning(msg).show());
|
||||
|
||||
bisqSetup.setShowPopupIfInvalidBtcConfigHandler(this::showPopupIfInvalidBtcConfig);
|
||||
|
||||
corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> new Popup()
|
||||
.warning(Res.get("popup.warning.incompatibleDB", files.toString(),
|
||||
bisqEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY)))
|
||||
|
@ -474,6 +476,14 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
|
|||
.show();
|
||||
}
|
||||
|
||||
private void showPopupIfInvalidBtcConfig() {
|
||||
preferences.setBitcoinNodesOptionOrdinal(0);
|
||||
new Popup().warning(Res.get("settings.net.warn.invalidBtcConfig"))
|
||||
.hideCloseButton()
|
||||
.useShutDownButton()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void setupDevDummyPaymentAccounts() {
|
||||
if (user.getPaymentAccounts() != null && user.getPaymentAccounts().isEmpty()) {
|
||||
AliPayAccount aliPayAccount = new AliPayAccount();
|
||||
|
|
Loading…
Add table
Reference in a new issue