Move baseCurrency methods form BaseCurrencyNetwork to BisqEnvironment

This commit is contained in:
Manfred Karrer 2017-06-14 14:46:56 +02:00
parent b334065af0
commit 275ea6846b
38 changed files with 192 additions and 179 deletions

View File

@ -22,4 +22,5 @@ public class DevEnv {
public static final boolean DAO_ACTIVATED = true;
public static final boolean DAO_PHASE2_ACTIVATED = false;
}

View File

@ -32,8 +32,7 @@ public abstract class AppSetup {
protected final TradeStatisticsManager tradeStatisticsManager;
@Inject
public AppSetup(BisqEnvironment bisqEnvironment,
EncryptionService encryptionService,
public AppSetup(EncryptionService encryptionService,
KeyRing keyRing,
TradeStatisticsManager tradeStatisticsManager) {
// we need to reference it so the seed node stores tradeStatistics
@ -41,7 +40,7 @@ public abstract class AppSetup {
this.keyRing = keyRing;
this.tradeStatisticsManager = tradeStatisticsManager;
Version.setBaseCryptoNetworkId(bisqEnvironment.getBaseCurrencyNetwork().ordinal());
Version.setBaseCryptoNetworkId(BisqEnvironment.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
}

View File

@ -39,13 +39,11 @@ public class AppSetupWithP2P extends AppSetup {
protected BooleanProperty p2pNetWorkReady;
@Inject
public AppSetupWithP2P(BisqEnvironment bisqEnvironment,
EncryptionService encryptionService,
public AppSetupWithP2P(EncryptionService encryptionService,
KeyRing keyRing,
P2PService p2PService,
TradeStatisticsManager tradeStatisticsManager) {
super(bisqEnvironment,
encryptionService,
super(encryptionService,
keyRing,
tradeStatisticsManager);
this.p2PService = p2PService;

View File

@ -31,14 +31,12 @@ public class AppSetupWithP2PAndDAO extends AppSetupWithP2P {
private final BsqBlockchainManager bsqBlockchainManager;
@Inject
public AppSetupWithP2PAndDAO(BisqEnvironment bisqEnvironment,
EncryptionService encryptionService,
public AppSetupWithP2PAndDAO(EncryptionService encryptionService,
KeyRing keyRing,
P2PService p2PService,
TradeStatisticsManager tradeStatisticsManager,
BsqBlockchainManager bsqBlockchainManager) {
super(bisqEnvironment,
encryptionService,
super(encryptionService,
keyRing,
p2PService,
tradeStatisticsManager);

View File

@ -19,6 +19,7 @@ package io.bisq.core.app;
import ch.qos.logback.classic.Level;
import io.bisq.common.CommonOptionKeys;
import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.storage.Storage;
@ -30,6 +31,7 @@ import io.bisq.core.dao.DaoOptionKeys;
import io.bisq.core.exceptions.BisqException;
import io.bisq.network.NetworkOptionKeys;
import joptsimple.OptionSet;
import org.bitcoinj.core.NetworkParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.*;
@ -73,7 +75,7 @@ public class BisqEnvironment extends StandardEnvironment {
private final String appDataDir;
private final String btcNetworkDir;
private final String logLevel, providers;
private BaseCurrencyNetwork baseCurrencyNetwork;
private static BaseCurrencyNetwork baseCurrencyNetwork;
private final String btcNodes, seedNodes, ignoreDevMsg, useTorForBtc, rpcUser, rpcPassword,
rpcPort, rpcBlockNotificationPort, dumpBlockchainData, fullDaoNode,
myAddress, banList, dumpStatistics, maxMemory, socks5ProxyBtcAddress,
@ -167,8 +169,8 @@ public class BisqEnvironment extends StandardEnvironment {
propertySources.addFirst(commandLineProperties);
try {
propertySources.addLast(getAppDirProperties());
baseCurrencyNetwork = BaseCurrencyNetwork.valueOf(getProperty(BtcOptionKeys.BASE_CRYPTO_NETWORK,
BaseCurrencyNetwork.BASE_CURRENCY_NETWORK.name()).toUpperCase());
baseCurrencyNetwork = BaseCurrencyNetwork.valueOf(getProperty(BtcOptionKeys.BASE_CURRENCY_NETWORK,
BaseCurrencyNetwork.getDefaultBaseCurrencyNetwork().name()).toUpperCase());
btcNetworkDir = Paths.get(appDataDir, baseCurrencyNetwork.name().toLowerCase()).toString();
File btcNetworkDirFile = new File(btcNetworkDir);
if (!btcNetworkDirFile.exists())
@ -182,11 +184,21 @@ public class BisqEnvironment extends StandardEnvironment {
}
}
public BaseCurrencyNetwork getBaseCurrencyNetwork() {
public static boolean isBaseCurrencySupportingBsq() {
return DevEnv.DAO_ACTIVATED && getBaseCurrencyNetwork().getCurrencyCode().equals("LTC");
}
public static NetworkParameters getParameters() {
return getBaseCurrencyNetwork().getParameters();
}
public static BaseCurrencyNetwork getBaseCurrencyNetwork() {
return baseCurrencyNetwork;
}
public void saveBaseCryptoNetwork(BaseCurrencyNetwork baseCurrencyNetwork) {
BisqEnvironment.baseCurrencyNetwork = baseCurrencyNetwork;
try {
Resource resource = getAppDirPropertiesResource();
File file = resource.getFile();
@ -199,15 +211,19 @@ public class BisqEnvironment extends StandardEnvironment {
log.warn("propertiesObject not instance of Properties");
}
}
properties.setProperty(BtcOptionKeys.BASE_CRYPTO_NETWORK, baseCurrencyNetwork.name());
properties.setProperty(BtcOptionKeys.BASE_CURRENCY_NETWORK, baseCurrencyNetwork.name());
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
properties.store(fileOutputStream, null);
} catch (IOException e1) {
log.error(e1.getMessage());
log.error(e1.toString());
e1.printStackTrace();
throw new RuntimeException(e1);
}
} catch (Exception e2) {
log.error(e2.toString());
e2.printStackTrace();
throw new RuntimeException(e2);
}
}

View File

@ -134,8 +134,8 @@ public abstract class BisqExecutable {
.withRequiredArg();
//BtcOptionKeys
parser.accepts(BtcOptionKeys.BASE_CRYPTO_NETWORK,
description("Base crypto network", BaseCurrencyNetwork.BASE_CURRENCY_NETWORK.name()))
parser.accepts(BtcOptionKeys.BASE_CURRENCY_NETWORK,
description("Base currency network", BaseCurrencyNetwork.getDefaultBaseCurrencyNetwork().name()))
.withRequiredArg()
.ofType(String.class);
//.withValuesConvertedBy(new EnumValueConverter(String.class));

View File

@ -21,6 +21,7 @@ import com.google.protobuf.ByteString;
import io.bisq.common.proto.ProtoUtil;
import io.bisq.common.proto.persistable.PersistablePayload;
import io.bisq.common.util.Utilities;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.generated.protobuffer.PB;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@ -169,7 +170,7 @@ public final class AddressEntry implements PersistablePayload {
@Nullable
public Address getAddress() {
if (address == null && keyPair != null)
address = keyPair.toAddress(BaseCurrencyNetwork.getParams());
address = keyPair.toAddress(BisqEnvironment.getParameters());
return address;
}

View File

@ -37,18 +37,8 @@ public enum BaseCurrencyNetwork {
DOGE_TESTNET(DogecoinTestNet3Params.get(), "DOGE", "TESTNET", "Dogecoin"),
DOGE_REGTEST(DogecoinRegTestParams.get(), "DOGE", "REGTEST", "Dogecoin");
public static BaseCurrencyNetwork BASE_CURRENCY_NETWORK = LTC_MAINNET;
public static BaseCurrencyNetwork getBaseCurrencyNetwork() {
return BASE_CURRENCY_NETWORK;
}
public static void setBaseCurrencyNetwork(BaseCurrencyNetwork baseCurrencyNetwork) {
BASE_CURRENCY_NETWORK = baseCurrencyNetwork;
}
public static NetworkParameters getParams() {
return BASE_CURRENCY_NETWORK.getParameters();
public static BaseCurrencyNetwork getDefaultBaseCurrencyNetwork() {
return LTC_MAINNET;
}
@Getter

View File

@ -4,7 +4,7 @@ public class BtcOptionKeys {
public static final String BTC_NODES = "btcNodes";
public static final String USE_TOR_FOR_BTC = "useTorForBtc";
public static final String SOCKS5_DISCOVER_MODE = "socks5DiscoverMode";
public static final String BASE_CRYPTO_NETWORK = "baseCurrencyNetwork";
public static final String BASE_CURRENCY_NETWORK = "baseCurrencyNetwork";
public static final String WALLET_DIR = "walletDir";
public static final String REG_TEST_HOST = "bitcoinRegtestHost";
}

View File

@ -17,6 +17,7 @@
package io.bisq.core.btc;
import io.bisq.core.app.BisqEnvironment;
import org.bitcoinj.core.Coin;
public class Restrictions {
@ -34,7 +35,7 @@ public class Restrictions {
public static Coin getMinNonDustOutput() {
if (minNonDustOutput == null)
minNonDustOutput = BaseCurrencyNetwork.getBaseCurrencyNetwork().getParameters().getMinNonDustOutput();
minNonDustOutput = BisqEnvironment.getBaseCurrencyNetwork().getParameters().getMinNonDustOutput();
return minNonDustOutput;
}

View File

@ -29,8 +29,8 @@ import org.spongycastle.crypto.params.KeyParameter;
import java.security.SecureRandom;
class BsqDeterministicKeyChain extends DeterministicKeyChain {
private static final Logger log = LoggerFactory.getLogger(BsqDeterministicKeyChain.class);
class BisqDeterministicKeyChain extends DeterministicKeyChain {
private static final Logger log = LoggerFactory.getLogger(BisqDeterministicKeyChain.class);
// See https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// https://github.com/satoshilabs/slips/blob/master/slip-0044.md
@ -40,33 +40,33 @@ class BsqDeterministicKeyChain extends DeterministicKeyChain {
new ChildNumber(142, true),
ChildNumber.ZERO_HARDENED);
public BsqDeterministicKeyChain(SecureRandom random) {
public BisqDeterministicKeyChain(SecureRandom random) {
super(random);
}
public BsqDeterministicKeyChain(DeterministicKey accountKey, boolean isFollowingKey) {
public BisqDeterministicKeyChain(DeterministicKey accountKey, boolean isFollowingKey) {
super(accountKey, isFollowingKey);
}
public BsqDeterministicKeyChain(DeterministicSeed seed, KeyCrypter crypter) {
public BisqDeterministicKeyChain(DeterministicSeed seed, KeyCrypter crypter) {
super(seed, crypter);
}
public BsqDeterministicKeyChain(DeterministicSeed seed) {
public BisqDeterministicKeyChain(DeterministicSeed seed) {
super(seed);
}
@Override
public DeterministicKeyChain toEncrypted(KeyCrypter keyCrypter, KeyParameter aesKey) {
return new BsqDeterministicKeyChain(keyCrypter, aesKey, this);
return new BisqDeterministicKeyChain(keyCrypter, aesKey, this);
}
protected DeterministicKeyChain makeKeyChainFromSeed(DeterministicSeed seed) {
return new BsqDeterministicKeyChain(seed);
return new BisqDeterministicKeyChain(seed);
}
protected BsqDeterministicKeyChain(KeyCrypter crypter, KeyParameter aesKey, DeterministicKeyChain chain) {
protected BisqDeterministicKeyChain(KeyCrypter crypter, KeyParameter aesKey, DeterministicKeyChain chain) {
super(crypter, aesKey, chain);
}

View File

@ -33,16 +33,16 @@ class BisqKeyChainFactory implements KeyChainFactory {
@Override
public DeterministicKeyChain makeKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicSeed seed, KeyCrypter crypter, boolean isMarried) {
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(seed, crypter) : new BsqDeterministicKeyChain(seed, crypter);
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(seed, crypter) : new BisqDeterministicKeyChain(seed, crypter);
}
@Override
public DeterministicKeyChain makeWatchingKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicKey accountKey,
boolean isFollowingKey, boolean isMarried) throws UnreadableWalletException {
ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : BsqDeterministicKeyChain.BIP44_BSQ_ACCOUNT_PATH;
ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : BisqDeterministicKeyChain.BIP44_BSQ_ACCOUNT_PATH;
if (!accountKey.getPath().equals(accountPath))
throw new UnreadableWalletException("Expecting account key but found key with path: " +
HDUtils.formatPath(accountKey.getPath()));
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new BsqDeterministicKeyChain(accountKey, isFollowingKey);
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new BisqDeterministicKeyChain(accountKey, isFollowingKey);
}
}

View File

@ -43,7 +43,7 @@ class BisqKeyChainGroup extends KeyChainGroup {
@Override
public void createAndActivateNewHDChain() {
DeterministicKeyChain chain = useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(new SecureRandom()) : new BsqDeterministicKeyChain(new SecureRandom());
DeterministicKeyChain chain = useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(new SecureRandom()) : new BisqDeterministicKeyChain(new SecureRandom());
addAndActivateHDChain(chain);
}
}

View File

@ -19,6 +19,7 @@ package io.bisq.core.btc.wallet;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.Restrictions;
import io.bisq.core.btc.exceptions.TransactionVerificationException;
import io.bisq.core.btc.exceptions.WalletException;
@ -76,56 +77,59 @@ public class BsqWalletService extends WalletService {
this.bsqCoinSelector = bsqCoinSelector;
this.bsqChainState = bsqChainState;
walletsSetup.addSetupCompletedHandler(() -> {
wallet = walletsSetup.getBsqWallet();
wallet.setCoinSelector(bsqCoinSelector);
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
walletsSetup.addSetupCompletedHandler(() -> {
wallet = walletsSetup.getBsqWallet();
if (wallet != null) {
wallet.setCoinSelector(bsqCoinSelector);
wallet.addEventListener(walletEventListener);
wallet.addEventListener(walletEventListener);
//noinspection deprecation
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
//TODO do we need updateWalletBsqTransactions(); here?
}
//noinspection deprecation
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
//TODO do we need updateWalletBsqTransactions(); here?
@Override
public void onCoinsSent(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
//TODO do we need updateWalletBsqTransactions(); here?
}
@Override
public void onReorganize(Wallet wallet) {
log.warn("onReorganize ");
updateBsqWalletTransactions();
}
@Override
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) {
}
@Override
public void onKeysAdded(List<ECKey> keys) {
updateBsqWalletTransactions();
}
@Override
public void onScriptsChanged(Wallet wallet, List<Script> scripts, boolean isAddingScripts) {
updateBsqWalletTransactions();
}
@Override
public void onWalletChanged(Wallet wallet) {
updateBsqWalletTransactions();
}
});
}
@Override
public void onCoinsSent(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
//TODO do we need updateWalletBsqTransactions(); here?
}
@Override
public void onReorganize(Wallet wallet) {
log.warn("onReorganize ");
updateBsqWalletTransactions();
}
@Override
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) {
}
@Override
public void onKeysAdded(List<ECKey> keys) {
updateBsqWalletTransactions();
}
@Override
public void onScriptsChanged(Wallet wallet, List<Script> scripts, boolean isAddingScripts) {
updateBsqWalletTransactions();
}
@Override
public void onWalletChanged(Wallet wallet) {
updateBsqWalletTransactions();
}
});
});
bsqBlockchainManager.addBsqChainStateListener(() -> {
updateBsqWalletTransactions();
updateBsqBalance();
});
bsqBlockchainManager.addBsqChainStateListener(() -> {
updateBsqWalletTransactions();
updateBsqBalance();
});
}
}

View File

@ -23,8 +23,8 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.bisq.common.app.Log;
import io.bisq.common.locale.Res;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.AddressEntry;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.btc.data.InputsAndChangeOutput;
import io.bisq.core.btc.data.PreparedDepositTxAndMakerInputs;
import io.bisq.core.btc.data.RawTransactionInput;
@ -113,7 +113,7 @@ public class TradeWalletService {
@Inject
public TradeWalletService(WalletsSetup walletsSetup) {
this.walletsSetup = walletsSetup;
this.params = BaseCurrencyNetwork.getParams();
this.params = BisqEnvironment.getParameters();
walletsSetup.addSetupCompletedHandler(() -> {
walletConfig = walletsSetup.getWalletConfig();
wallet = walletsSetup.getBtcWallet();

View File

@ -22,7 +22,9 @@ import com.google.common.util.concurrent.AbstractIdleService;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.ProxySocketFactory;
import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.core.*;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.core.listeners.PeerDataEventListener;
@ -37,8 +39,6 @@ import org.bitcoinj.store.BlockStoreException;
import org.bitcoinj.store.SPVBlockStore;
import org.bitcoinj.wallet.*;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.*;
@ -50,14 +50,12 @@ import java.nio.channels.FileLock;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Preconditions.*;
// Derived from WalletAppKit
// Does the basic wiring
@Slf4j
public class WalletConfig extends AbstractIdleService {
private static final Logger log = LoggerFactory.getLogger(WalletConfig.class);
///////////////////////////////////////////////////////////////////////////////////////////
// WalletFactory
@ -84,8 +82,10 @@ public class WalletConfig extends AbstractIdleService {
private final BisqWalletFactory walletFactory;
private volatile Wallet vBtcWallet;
@Nullable
private volatile Wallet vBsqWallet;
private volatile File vBtcWalletFile;
@Nullable
private volatile File vBsqWalletFile;
@Nullable
private DeterministicSeed seed;
@ -131,19 +131,25 @@ public class WalletConfig extends AbstractIdleService {
// We have already the chain here so we can use this to distinguish.
//TODO refactor, make it more explicit
List<DeterministicKeyChain> deterministicKeyChains = keyChainGroup.getDeterministicKeyChains();
if (!deterministicKeyChains.isEmpty() && deterministicKeyChains.get(0) instanceof BsqDeterministicKeyChain)
if (!deterministicKeyChains.isEmpty() && deterministicKeyChains.get(0) instanceof BisqDeterministicKeyChain) {
checkArgument(BisqEnvironment.isBaseCurrencySupportingBsq(), "BisqEnvironment.isBaseCurrencySupportingBsq() is false but we get get " +
"called BisqWalletFactory.create with BisqDeterministicKeyChain");
return new BsqWallet(params, keyChainGroup);
else
} else {
return new Wallet(params, keyChainGroup);
}
}
@Override
public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup, boolean isBsqWallet) {
// This is called at first startup when we create the wallet
if (isBsqWallet)
if (isBsqWallet) {
checkArgument(BisqEnvironment.isBaseCurrencySupportingBsq(), "BisqEnvironment.isBaseCurrencySupportingBsq() is false but we get get " +
"called BisqWalletFactory.create with isBsqWallet=true");
return new BsqWallet(params, keyChainGroup);
else
} else {
return new Wallet(params, keyChainGroup);
}
}
};
@ -364,13 +370,16 @@ public class WalletConfig extends AbstractIdleService {
vBtcWallet.allowSpendingUnconfirmedTransactions();
// BSQ walelt
vBsqWalletFile = new File(directory, bsqWalletFileName);
if (seed != null)
keyChainGroup = new BisqKeyChainGroup(params, new BsqDeterministicKeyChain(seed), false);
keyChainGroup = new BisqKeyChainGroup(params, new BisqDeterministicKeyChain(seed), false);
else
keyChainGroup = new BisqKeyChainGroup(params, new BsqDeterministicKeyChain(vBtcWallet.getKeyChainSeed()), false);
vBsqWallet = createOrLoadWallet(vBsqWalletFile, shouldReplayWallet, keyChainGroup, true, seed);
keyChainGroup = new BisqKeyChainGroup(params, new BisqDeterministicKeyChain(vBtcWallet.getKeyChainSeed()), false);
// BSQ wallet
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
vBsqWalletFile = new File(directory, bsqWalletFileName);
vBsqWallet = createOrLoadWallet(vBsqWalletFile, shouldReplayWallet, keyChainGroup, true, seed);
}
// Initiate Bitcoin network objects (block store, blockchain and peer group)
vStore = provideBlockStore(chainFile);
@ -422,9 +431,13 @@ public class WalletConfig extends AbstractIdleService {
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
}
vChain.addWallet(vBtcWallet);
vChain.addWallet(vBsqWallet);
vPeerGroup.addWallet(vBtcWallet);
vPeerGroup.addWallet(vBsqWallet);
if (vBsqWallet != null) {
vChain.addWallet(vBsqWallet);
vPeerGroup.addWallet(vBsqWallet);
}
onSetupCompleted();
if (blockingStartup) {
@ -539,7 +552,8 @@ public class WalletConfig extends AbstractIdleService {
Context.propagate(context);
vPeerGroup.stop();
vBtcWallet.saveToFile(vBtcWalletFile);
vBsqWallet.saveToFile(vBsqWalletFile);
if (vBsqWallet != null && vBsqWalletFile != null)
vBsqWallet.saveToFile(vBsqWalletFile);
vStore.close();
vPeerGroup = null;
@ -571,6 +585,7 @@ public class WalletConfig extends AbstractIdleService {
return vBtcWallet;
}
@Nullable
public Wallet getBsqWallet() {
checkState(state() == State.STARTING || state() == State.RUNNING, "Cannot call until startup is complete");
return vBsqWallet;

View File

@ -21,7 +21,7 @@ import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.exceptions.TransactionVerificationException;
import io.bisq.core.btc.exceptions.WalletException;
import io.bisq.core.btc.listeners.AddressConfidenceListener;
@ -579,13 +579,13 @@ public abstract class WalletService {
@Nullable
public static Address getAddressFromOutput(TransactionOutput output) {
return isOutputScriptConvertibleToAddress(output) ?
output.getScriptPubKey().getToAddress(BaseCurrencyNetwork.getParams()) : null;
output.getScriptPubKey().getToAddress(BisqEnvironment.getParameters()) : null;
}
@Nullable
public static String getAddressStringFromOutput(TransactionOutput output) {
return isOutputScriptConvertibleToAddress(output) ?
output.getScriptPubKey().getToAddress(BaseCurrencyNetwork.getParams()).toString() : null;
output.getScriptPubKey().getToAddress(BisqEnvironment.getParameters()).toString() : null;
}

View File

@ -28,6 +28,7 @@ import io.bisq.common.app.Log;
import io.bisq.common.handlers.ExceptionHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.common.storage.FileUtil;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.*;
import io.bisq.core.user.Preferences;
import io.bisq.network.DnsLookupTor;
@ -107,8 +108,8 @@ public class WalletsSetup {
this.socks5DiscoverMode = evaluateMode(socks5DiscoverModeString);
btcWalletFileName = "bisq_" + BaseCurrencyNetwork.getBaseCurrencyNetwork().getCurrencyCode() + ".wallet";
params = BaseCurrencyNetwork.getParams();
btcWalletFileName = "bisq_" + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode() + ".wallet";
params = BisqEnvironment.getParameters();
walletDir = new File(appDir, "wallet");
PeerGroup.setIgnoreHttpSeeds(true);
}
@ -387,6 +388,7 @@ public class WalletsSetup {
return walletConfig.getBtcWallet();
}
@Nullable
public Wallet getBsqWallet() {
return walletConfig.getBsqWallet();
}

View File

@ -18,18 +18,14 @@
package io.bisq.core.dao;
import com.google.inject.Inject;
import io.bisq.common.app.DevEnv;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.provider.squ.BsqUtxoFeedService;
import io.bisq.core.dao.blockchain.BsqBlockchainManager;
import io.bisq.core.dao.compensation.CompensationRequestManager;
import io.bisq.core.dao.vote.VotingManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DaoManager {
private static final Logger log = LoggerFactory.getLogger(DaoManager.class);
private final BsqBlockchainManager bsqBlockchainManager;
private final DaoPeriodService daoPeriodService;
private final BsqUtxoFeedService bsqUtxoFeedService;
@ -52,10 +48,11 @@ public class DaoManager {
this.bsqUtxoFeedService = bsqUtxoFeedService;
this.voteManager = voteManager;
this.compensationRequestManager = compensationRequestManager;
}
public void onAllServicesInitialized(ErrorMessageHandler errorMessageHandler) {
if (DevEnv.DAO_ACTIVATED) {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
daoPeriodService.onAllServicesInitialized();
bsqUtxoFeedService.onAllServicesInitialized();
voteManager.onAllServicesInitialized();

View File

@ -18,8 +18,8 @@
package io.bisq.core.dao.blockchain;
import com.google.inject.Inject;
import io.bisq.common.app.DevEnv;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.dao.DaoOptionKeys;
import lombok.extern.slf4j.Slf4j;
@ -43,7 +43,7 @@ public class BsqBlockchainManager {
}
public void addBsqChainStateListener(BsqChainStateListener bsqChainStateListener) {
if (DevEnv.DAO_ACTIVATED)
if (BisqEnvironment.isBaseCurrencySupportingBsq())
bsqNode.addBsqChainStateListener(bsqChainStateListener);
}
@ -52,7 +52,7 @@ public class BsqBlockchainManager {
}
public void removeBsqChainStateListener(BsqChainStateListener bsqChainStateListener) {
if (DevEnv.DAO_ACTIVATED)
if (BisqEnvironment.isBaseCurrencySupportingBsq())
bsqNode.removeBsqChainStateListener(bsqChainStateListener);
}
}

View File

@ -26,7 +26,7 @@ import io.bisq.common.storage.Storage;
import io.bisq.common.util.FunctionalReadWriteLock;
import io.bisq.common.util.Tuple2;
import io.bisq.common.util.Utilities;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.dao.DaoOptionKeys;
import io.bisq.core.dao.blockchain.exceptions.BlockNotConnectingException;
import io.bisq.core.dao.blockchain.vo.*;
@ -148,7 +148,7 @@ public class BsqChainState implements PersistableEnvelope, Serializable {
storage = new Storage<>(storageDir, persistenceProtoResolver);
switch (BaseCurrencyNetwork.getBaseCurrencyNetwork()) {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case BTC_MAINNET:
genesisTxId = BTC_GENESIS_TX_ID;
genesisBlockHeight = BTC_GENESIS_BLOCK_HEIGHT;

View File

@ -19,10 +19,10 @@ package io.bisq.core.dao.compensation;
import com.google.common.util.concurrent.FutureCallback;
import com.google.inject.Inject;
import io.bisq.common.app.DevEnv;
import io.bisq.common.proto.persistable.PersistableList;
import io.bisq.common.proto.persistable.PersistedDataHost;
import io.bisq.common.storage.Storage;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.wallet.BsqWalletService;
import io.bisq.core.btc.wallet.BtcWalletService;
import io.bisq.core.dao.DaoPeriodService;
@ -82,7 +82,7 @@ public class CompensationRequestManager implements PersistedDataHost {
observableList = FXCollections.observableArrayList(model.getList());
if (DevEnv.DAO_ACTIVATED) {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
@ -108,7 +108,7 @@ public class CompensationRequestManager implements PersistedDataHost {
@Override
public void readPersisted() {
if (DevEnv.DAO_ACTIVATED) {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
PersistableList<CompensationRequest> persisted = compensationRequestsStorage.initAndGetPersistedWithFileName("CompensationRequests");
if (persisted != null)
model.setPersistedCompensationRequest(persisted.getList());

View File

@ -19,13 +19,13 @@ package io.bisq.core.dao.vote;
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Version;
import io.bisq.common.proto.ProtoUtil;
import io.bisq.common.proto.persistable.PersistableList;
import io.bisq.common.proto.persistable.PersistedDataHost;
import io.bisq.common.storage.Storage;
import io.bisq.common.util.Utilities;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.wallet.BsqWalletService;
import io.bisq.core.btc.wallet.BtcWalletService;
import io.bisq.core.dao.DaoPeriodService;
@ -93,7 +93,7 @@ public class VotingManager implements PersistedDataHost {
@Override
public void readPersisted() {
if (DevEnv.DAO_ACTIVATED) {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
PersistableList<VoteItemsList> persisted = voteItemCollectionsStorage.initAndGetPersistedWithFileName("VoteItemCollections");
if (persisted != null)
voteItemsLists.addAll(persisted.getList());

View File

@ -24,7 +24,7 @@ import com.google.inject.Inject;
import io.bisq.common.UserThread;
import io.bisq.common.handlers.FaultHandler;
import io.bisq.common.util.Tuple2;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.provider.ProvidersRepository;
import io.bisq.network.http.HttpClient;
import org.bitcoinj.core.Coin;
@ -77,7 +77,7 @@ public class FeeService {
@Inject
public FeeService(HttpClient httpClient, ProvidersRepository providersRepository) {
baseCurrencyCode = BaseCurrencyNetwork.getBaseCurrencyNetwork().getCurrencyCode();
baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
feeProvider = new FeeProvider(httpClient, providersRepository.getBaseUrl());
switch (baseCurrencyCode) {

View File

@ -25,7 +25,7 @@ import io.bisq.common.app.Log;
import io.bisq.common.handlers.FaultHandler;
import io.bisq.common.locale.TradeCurrency;
import io.bisq.common.util.Tuple2;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.provider.ProvidersRepository;
import io.bisq.core.user.Preferences;
import io.bisq.network.http.HttpClient;
@ -80,7 +80,7 @@ public class PriceFeedService {
this.providersRepository = providersRepository;
this.preferences = preferences;
this.priceProvider = new PriceProvider(httpClient, providersRepository.getBaseUrl());
baseCurrencyCode = BaseCurrencyNetwork.getBaseCurrencyNetwork().getCurrencyCode();
baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
}

View File

@ -137,7 +137,7 @@ public final class Preferences implements PersistedDataHost {
setFiatCurrencies(CurrencyUtil.getMainFiatCurrencies());
setCryptoCurrencies(CurrencyUtil.getMainCryptoCurrencies());
final BaseCurrencyNetwork baseCurrencyNetwork = BaseCurrencyNetwork.getBaseCurrencyNetwork();
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
switch (baseCurrencyNetwork.getCurrencyCode()) {
case "BTC":
setBlockChainExplorerMainNet(BTC_MAIN_NET_EXPLORERS.get(0));
@ -283,7 +283,7 @@ public final class Preferences implements PersistedDataHost {
}
public void setBlockChainExplorer(BlockChainExplorer blockChainExplorer) {
if (BaseCurrencyNetwork.getBaseCurrencyNetwork().isMainnet())
if (BisqEnvironment.getBaseCurrencyNetwork().isMainnet())
setBlockChainExplorerMainNet(blockChainExplorer);
else
setBlockChainExplorerTestNet(blockChainExplorer);
@ -482,14 +482,14 @@ public final class Preferences implements PersistedDataHost {
}
public BlockChainExplorer getBlockChainExplorer() {
if (BaseCurrencyNetwork.getBaseCurrencyNetwork().isMainnet())
if (BisqEnvironment.getBaseCurrencyNetwork().isMainnet())
return prefPayload.getBlockChainExplorerMainNet();
else
return prefPayload.getBlockChainExplorerTestNet();
}
public ArrayList<BlockChainExplorer> getBlockChainExplorers() {
final BaseCurrencyNetwork baseCurrencyNetwork = BaseCurrencyNetwork.getBaseCurrencyNetwork();
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
switch (baseCurrencyNetwork) {
case BTC_MAINNET:
return BTC_MAIN_NET_EXPLORERS;
@ -519,7 +519,7 @@ public final class Preferences implements PersistedDataHost {
// We override the useTorForBitcoinJ and set to false if we have bitcoinNodes set
// Atm we don't support onion addresses there
// This check includes localhost, so we also override useTorForBitcoinJ
if (prefPayload.getBitcoinNodes() != null && !prefPayload.getBitcoinNodes().isEmpty() || BaseCurrencyNetwork.getBaseCurrencyNetwork().isRegtest())
if (prefPayload.getBitcoinNodes() != null && !prefPayload.getBitcoinNodes().isEmpty() || BisqEnvironment.getBaseCurrencyNetwork().isRegtest())
return false;
else
return prefPayload.isUseTorForBitcoinJ();

View File

@ -165,8 +165,7 @@ public class BisqApp extends Application {
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = bisqEnvironment.getBaseCurrencyNetwork();
BaseCurrencyNetwork.setBaseCurrencyNetwork(baseCurrencyNetwork);
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
Res.setBaseCurrencyCode(baseCurrencyNetwork.getCurrencyCode());
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
@ -214,7 +213,7 @@ public class BisqApp extends Application {
}
});
Version.setBaseCryptoNetworkId(injector.getInstance(BisqEnvironment.class).getBaseCurrencyNetwork().ordinal());
Version.setBaseCryptoNetworkId(BisqEnvironment.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
if (Utilities.isLinux())

View File

@ -22,6 +22,7 @@ import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Version;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Tuple2;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.exceptions.BisqException;
import io.bisq.gui.Navigation;
import io.bisq.gui.common.view.*;
@ -139,7 +140,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
Pane portfolioButtonHolder = new Pane(portfolioButton);
Pane disputesButtonHolder = new Pane(disputesButton);
if (!DevEnv.DAO_ACTIVATED) {
if (!BisqEnvironment.isBaseCurrencySupportingBsq()) {
daoButton.setVisible(false);
daoButton.setManaged(false);
}

View File

@ -41,7 +41,6 @@ import io.bisq.core.arbitration.ArbitratorManager;
import io.bisq.core.arbitration.Dispute;
import io.bisq.core.arbitration.DisputeManager;
import io.bisq.core.btc.AddressEntry;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.btc.listeners.BalanceListener;
import io.bisq.core.btc.wallet.BtcWalletService;
import io.bisq.core.btc.wallet.WalletsManager;
@ -226,7 +225,7 @@ public class MainViewModel implements ViewModel {
this.bisqEnvironment = bisqEnvironment;
this.formatter = formatter;
btcNetworkAsString = Res.get(BaseCurrencyNetwork.getBaseCurrencyNetwork().name()) +
btcNetworkAsString = Res.get(BisqEnvironment.getBaseCurrencyNetwork().name()) +
(preferences.getUseTorForBitcoinJ() ? (" " + Res.get("mainView.footer.usingTor")) : "");
TxIdTextField.setPreferences(preferences);
@ -263,7 +262,6 @@ public class MainViewModel implements ViewModel {
String key = "showSelectBaseCurrencyWindowAtFistStartup";
if (preferences.showAgain(key)) {
new SelectBaseCurrencyWindow()
.baseCurrencyNetwork(BaseCurrencyNetwork.getBaseCurrencyNetwork())
.onSelect(baseCurrencyNetwork -> {
bisqEnvironment.saveBaseCryptoNetwork(baseCurrencyNetwork);
preferences.dontShowAgain(key, true);
@ -275,9 +273,9 @@ public class MainViewModel implements ViewModel {
.hideCloseButton()
.show();
})
.actionButtonText(Res.get("selectBaseCurrencyWindow.default", BaseCurrencyNetwork.getBaseCurrencyNetwork().getCurrencyName()))
.actionButtonText(Res.get("selectBaseCurrencyWindow.default", BisqEnvironment.getBaseCurrencyNetwork().getCurrencyName()))
.onAction(() -> {
bisqEnvironment.saveBaseCryptoNetwork(BaseCurrencyNetwork.getBaseCurrencyNetwork());
bisqEnvironment.saveBaseCryptoNetwork(BisqEnvironment.getBaseCurrencyNetwork());
preferences.dontShowAgain(key, true);
startBasicServices();
})

View File

@ -20,8 +20,8 @@ package io.bisq.gui.main.dao.wallet.tx;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bisq.common.UserThread;
import io.bisq.common.app.DevEnv;
import io.bisq.common.locale.Res;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.wallet.BsqBalanceListener;
import io.bisq.core.btc.wallet.BsqWalletService;
import io.bisq.core.btc.wallet.BtcWalletService;
@ -123,7 +123,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
chainSyncIndicator = new ProgressBar();
chainSyncIndicator.setPrefWidth(120);
if (DevEnv.DAO_ACTIVATED)
if (BisqEnvironment.isBaseCurrencySupportingBsq())
chainSyncIndicator.setProgress(-1);
else
chainSyncIndicator.setProgress(0);

View File

@ -20,6 +20,7 @@ package io.bisq.gui.main.overlays.windows;
import io.bisq.common.app.DevEnv;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Tuple2;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.gui.main.overlays.Overlay;
import javafx.collections.FXCollections;
@ -43,7 +44,6 @@ public class SelectBaseCurrencyWindow extends Overlay<SelectBaseCurrencyWindow>
private ComboBox<BaseCurrencyNetwork> comboBox;
private Optional<Consumer<BaseCurrencyNetwork>> selectHandlerOptional;
private BaseCurrencyNetwork baseCurrencyNetwork;
///////////////////////////////////////////////////////////////////////////////////////////
@ -74,18 +74,13 @@ public class SelectBaseCurrencyWindow extends Overlay<SelectBaseCurrencyWindow>
return this;
}
public SelectBaseCurrencyWindow baseCurrencyNetwork(BaseCurrencyNetwork baseCurrencyNetwork) {
this.baseCurrencyNetwork = baseCurrencyNetwork;
return this;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Protected
///////////////////////////////////////////////////////////////////////////////////////////
private void addContent() {
Label label = addMultilineLabel(gridPane, ++rowIndex, Res.get("selectBaseCurrencyWindow.msg", baseCurrencyNetwork.getCurrencyName()), 10);
Label label = addMultilineLabel(gridPane, ++rowIndex, Res.get("selectBaseCurrencyWindow.msg", BisqEnvironment.getBaseCurrencyNetwork().getCurrencyName()), 10);
GridPane.setMargin(label, new Insets(0, 0, 10, 0));
Tuple2<Label, ComboBox> tuple = addLabelComboBox(gridPane, ++rowIndex, Res.get("selectBaseCurrencyWindow.select"));

View File

@ -147,7 +147,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
.collect(Collectors.toList());
selectCurrencyNetworkComboBox.setItems(FXCollections.observableArrayList(baseCurrencyNetworks));
selectCurrencyNetworkComboBox.getSelectionModel().select(BaseCurrencyNetwork.getBaseCurrencyNetwork());
selectCurrencyNetworkComboBox.getSelectionModel().select(BisqEnvironment.getBaseCurrencyNetwork());
selectCurrencyNetworkComboBox.setOnAction(e -> onSelectNetwork());
selectCurrencyNetworkComboBox.setConverter(new StringConverter<BaseCurrencyNetwork>() {
@Override
@ -276,7 +276,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
}
private void onSelectNetwork() {
if (selectCurrencyNetworkComboBox.getSelectionModel().getSelectedItem() != BaseCurrencyNetwork.getBaseCurrencyNetwork())
if (selectCurrencyNetworkComboBox.getSelectionModel().getSelectedItem() != BisqEnvironment.getBaseCurrencyNetwork())
selectNetwork();
}
@ -288,7 +288,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
})
.actionButtonText(Res.get("shared.shutDown"))
.closeButtonText(Res.get("shared.cancel"))
.onClose(() -> selectCurrencyNetworkComboBox.getSelectionModel().select(BaseCurrencyNetwork.getBaseCurrencyNetwork()))
.onClose(() -> selectCurrencyNetworkComboBox.getSelectionModel().select(BisqEnvironment.getBaseCurrencyNetwork()))
.show();
}

View File

@ -18,7 +18,7 @@
package io.bisq.gui.util;
import io.bisq.common.app.DevEnv;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.utils.MonetaryFormat;
@ -37,7 +37,7 @@ public class BsqFormatter extends BSFormatter {
private BsqFormatter() {
super();
final String baseCurrencyCode = BaseCurrencyNetwork.getBaseCurrencyNetwork().getCurrencyCode();
final String baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
switch (baseCurrencyCode) {
case "BTC":
coinFormat = new MonetaryFormat().shift(5).code(5, "BSQ").minDecimals(3);
@ -72,7 +72,7 @@ public class BsqFormatter extends BSFormatter {
encoded = encoded.substring(prefix.length(), encoded.length());
try {
return Address.fromBase58(BaseCurrencyNetwork.getParams(), encoded);
return Address.fromBase58(BisqEnvironment.getParameters(), encoded);
} catch (AddressFormatException e) {
log.error(e.toString());
e.printStackTrace();

View File

@ -31,7 +31,7 @@ import io.bisq.common.proto.persistable.PersistableList;
import io.bisq.common.proto.persistable.PersistenceProtoResolver;
import io.bisq.common.storage.Storage;
import io.bisq.common.util.Utilities;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.core.payment.PaymentAccount;
import io.bisq.core.user.DontShowAgainLookup;
import io.bisq.core.user.Preferences;
@ -391,7 +391,7 @@ public class GUIUtil {
public static String getBitcoinURI(String address, Coin amount, String label) {
return address != null ?
BitcoinURI.convertToBitcoinURI(Address.fromBase58(BaseCurrencyNetwork.getParams(),
BitcoinURI.convertToBitcoinURI(Address.fromBase58(BisqEnvironment.getParameters(),
address), amount, label, null) :
"";
}

View File

@ -19,7 +19,7 @@ package io.bisq.gui.util.validation;
import io.bisq.common.locale.Res;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.gui.util.validation.altcoins.ByteballAddressValidator;
import io.bisq.gui.util.validation.altcoins.NxtReedSolomonValidator;
import io.bisq.gui.util.validation.altcoins.OctocoinAddressValidator;
@ -68,7 +68,7 @@ public final class AltCoinAddressValidator extends InputValidator {
switch (currencyCode) {
case "BTC":
try {
switch (BaseCurrencyNetwork.getBaseCurrencyNetwork()) {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case BTC_MAINNET:
Address.fromBase58(MainNetParams.get(), input);
break;
@ -85,7 +85,7 @@ public final class AltCoinAddressValidator extends InputValidator {
}
case "LTC":
try {
switch (BaseCurrencyNetwork.getBaseCurrencyNetwork()) {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case LTC_MAINNET:
Address.fromBase58(LitecoinMainNetParams.get(), input);
break;
@ -102,7 +102,7 @@ public final class AltCoinAddressValidator extends InputValidator {
}
case "DOGE":
try {
switch (BaseCurrencyNetwork.getBaseCurrencyNetwork()) {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case DOGE_MAINNET:
Address.fromBase58(DogecoinMainNetParams.get(), input);
break;

View File

@ -18,7 +18,7 @@
package io.bisq.gui.util.validation;
import io.bisq.common.locale.Res;
import io.bisq.core.btc.BaseCurrencyNetwork;
import io.bisq.core.app.BisqEnvironment;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
@ -42,7 +42,7 @@ public final class BtcAddressValidator extends InputValidator {
private ValidationResult validateBtcAddress(String input) {
try {
Address.fromBase58(BaseCurrencyNetwork.getParams(), input);
Address.fromBase58(BisqEnvironment.getParameters(), input);
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, Res.get("validation.btc.invalidFormat"));

View File

@ -75,8 +75,7 @@ public class SeedNode {
}
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = bisqEnvironment.getBaseCurrencyNetwork();
BaseCurrencyNetwork.setBaseCurrencyNetwork(baseCurrencyNetwork);
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
Res.setBaseCurrencyCode(baseCurrencyNetwork.getCurrencyCode());
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());

View File

@ -83,8 +83,7 @@ public class Statistics {
}
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = bisqEnvironment.getBaseCurrencyNetwork();
BaseCurrencyNetwork.setBaseCurrencyNetwork(baseCurrencyNetwork);
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
Res.setBaseCurrencyCode(baseCurrencyNetwork.getCurrencyCode());
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
@ -93,7 +92,7 @@ public class Statistics {
statisticsModule = new StatisticsModule(bisqEnvironment);
injector = Guice.createInjector(statisticsModule);
Version.setBaseCryptoNetworkId(injector.getInstance(BisqEnvironment.class).getBaseCurrencyNetwork().ordinal());
Version.setBaseCryptoNetworkId(BisqEnvironment.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
p2pService = injector.getInstance(P2PService.class);
p2pService.start(new BootstrapListener() {