add option ot disable block explorer

This commit is contained in:
Craig Raw 2023-02-28 13:59:45 +02:00
parent dfe1f16495
commit f22f76464a
5 changed files with 14 additions and 4 deletions

View file

@ -812,6 +812,10 @@ public class AppServices {
}
public static void openBlockExplorer(String txid) {
if(Config.get().isBlockExplorerDisabled()) {
return;
}
Server blockExplorer = Config.get().getBlockExplorer() == null ? BlockExplorer.MEMPOOL_SPACE.getServer() : Config.get().getBlockExplorer();
String url = blockExplorer.getUrl();
if(url.contains("{0}")) {

View file

@ -151,6 +151,10 @@ public class Config {
flush();
}
public boolean isBlockExplorerDisabled() {
return BlockExplorer.NONE.getServer().equals(blockExplorer);
}
public Server getBlockExplorer() {
return blockExplorer;
}

View file

@ -4,7 +4,8 @@ import com.sparrowwallet.sparrow.io.Server;
public enum BlockExplorer {
MEMPOOL_SPACE("https://mempool.space"),
BLOCKSTREAM_INFO("https://blockstream.info");
BLOCKSTREAM_INFO("https://blockstream.info"),
NONE("http://none");
private final Server server;

View file

@ -91,8 +91,8 @@ public class GeneralPreferencesController extends PreferencesDetailController {
blockExplorers.setConverter(new StringConverter<>() {
@Override
public String toString(Server server) {
if(server == null) {
return "None Available";
if(server == null || server == BlockExplorer.NONE.getServer()) {
return "None";
}
if(server == CUSTOM_BLOCK_EXPLORER) {

View file

@ -16,6 +16,7 @@ import com.sparrowwallet.sparrow.control.*;
import com.sparrowwallet.sparrow.event.*;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
import com.sparrowwallet.sparrow.io.Config;
import com.sparrowwallet.sparrow.io.Device;
import com.sparrowwallet.sparrow.net.ElectrumServer;
import com.sparrowwallet.sparrow.io.Storage;
@ -818,7 +819,7 @@ public class HeadersController extends TransactionFormController implements Init
size.getStyleClass().remove(UNFINALIZED_TXID_CLASS);
virtualSize.getStyleClass().remove(UNFINALIZED_TXID_CLASS);
feeRate.getStyleClass().remove(UNFINALIZED_TXID_CLASS);
openBlockExplorer.setDisable(false);
openBlockExplorer.setDisable(Config.get().isBlockExplorerDisabled());
}
}