public SignalRSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(SignalRSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; string host = config.GetOrDefault("signalruri", DefaultSignalRHost, this.logger); var uri = new Uri(host); // Find out which port should be used for the API. int port = config.GetOrDefault("signalrport", nodeSettings.Network.DefaultSignalRPort, this.logger); // If no port is set in the API URI. if (uri.IsDefaultPort) { this.SignalRUri = new Uri($"{host}:{port}"); this.SignalPort = port; } else { this.SignalRUri = uri; this.SignalPort = uri.Port; } }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public StoreSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(StoreSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.AmountOfBlocksToKeep = config.GetOrDefault <int>("prune", 0, this.logger); this.PruningEnabled = this.AmountOfBlocksToKeep != 0; if (this.PruningEnabled && this.AmountOfBlocksToKeep < this.GetMinPruningAmount()) { throw new ConfigurationException($"The minimum amount of blocks to keep can't be less than {this.GetMinPruningAmount()}."); } // For now we reuse the same value as ConsensusSetting, when store moves to core this can be updated. this.MaxCacheSize = config.GetOrDefault("maxblkstoremem", 5, this.logger); this.TxIndex = config.GetOrDefault <bool>("txindex", false, this.logger); this.ReIndex = config.GetOrDefault <bool>("reindex", false, this.logger); this.AddressIndex = config.GetOrDefault <bool>("addressindex", false, this.logger); if (this.PruningEnabled && this.TxIndex) { throw new ConfigurationException("Prune mode is incompatible with -txindex"); } }
private static ClientDestinationWallet GetDestinationWallet(TextFileConfiguration config, Network network, DBreezeRepository dbreeze) { BitcoinExtPubKey pubKey = null; KeyPath keypath = new KeyPath("0"); try { pubKey = new BitcoinExtPubKey(config.GetOrDefault("outputwallet.extpubkey", null as string), network); } catch { throw new ConfigException("outputwallet.extpubkey is not configured correctly"); } string keyPathString = config.GetOrDefault("outputwallet.keypath", null as string); if (keyPathString != null) { try { keypath = new KeyPath(keyPathString); } catch { throw new ConfigException("outputwallet.keypath is not configured correctly"); } } var destinationWallet = new ClientDestinationWallet("", pubKey, keypath, dbreeze); return(destinationWallet); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public MinerSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(MinerSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.Mine = config.GetOrDefault <bool>("mine", false, this.logger); if (this.Mine) { this.MineAddress = config.GetOrDefault <string>("mineaddress", null, this.logger); } this.Stake = config.GetOrDefault <bool>("stake", false, this.logger); if (this.Stake) { this.WalletName = config.GetOrDefault <string>("walletname", null, this.logger); this.WalletPassword = config.GetOrDefault <string>("walletpassword", null); // No logging! } uint blockMaxSize = (uint)config.GetOrDefault <int>("blockmaxsize", (int)nodeSettings.Network.Consensus.Options.MaxBlockSerializedSize, this.logger); uint blockMaxWeight = (uint)config.GetOrDefault <int>("blockmaxweight", (int)nodeSettings.Network.Consensus.Options.MaxBlockWeight, this.logger); this.BlockDefinitionOptions = new BlockDefinitionOptions(blockMaxWeight, blockMaxSize).RestrictForNetwork(nodeSettings.Network); this.EnableCoinStakeSplitting = config.GetOrDefault("enablecoinstakesplitting", true, this.logger); this.MinimumSplitCoinValue = config.GetOrDefault("minimumsplitcoinvalue", MinimumSplitCoinValueDefaultValue, this.logger); this.MinimumStakingCoinValue = config.GetOrDefault("minimumstakingcoinvalue", MinimumStakingCoinValueDefaultValue, this.logger); this.MinimumStakingCoinValue = this.MinimumStakingCoinValue == 0 ? 1 : this.MinimumStakingCoinValue; }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public StoreSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(StoreSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.AmountOfBlocksToKeep = config.GetOrDefault <int>("prune", 0, this.logger); this.PruningEnabled = this.AmountOfBlocksToKeep != 0; if (this.PruningEnabled && this.AmountOfBlocksToKeep < this.GetMinPruningAmount()) { throw new ConfigurationException($"The minimum amount of blocks to keep can't be less than {this.GetMinPruningAmount()}."); } this.TxIndex = config.GetOrDefault <bool>("txindex", false, this.logger); this.ReIndex = config.GetOrDefault <bool>("reindex", false, this.logger); this.MaxCacheBlocksCount = nodeSettings.ConfigReader.GetOrDefault("maxCacheBlocksCount", DefaultMaxCacheBlocksCount, this.logger); if (this.PruningEnabled && this.TxIndex) { throw new ConfigurationException("Prune mode is incompatible with -txindex"); } }
public PoAMinerSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.BootstrappingMode = config.GetOrDefault <bool>("bootstrap", false); this.MineAddress = config.GetOrDefault <string>("mineaddress", null); }
public CounterChainSettings(NodeSettings nodeSettings, Network counterChainNetwork) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration configReader = nodeSettings.ConfigReader; this.CounterChainApiHost = configReader.GetOrDefault(CounterChainApiHostParam, "localhost"); this.CounterChainApiPort = configReader.GetOrDefault(CounterChainApiPortParam, counterChainNetwork.DefaultAPIPort); this.CounterChainNetwork = counterChainNetwork; }
public static TorConnectionSettings ParseConnectionSettings(string prefix, TextFileConfiguration config) { TorConnectionSettings settings = new TorConnectionSettings(); settings.Server = config.GetOrDefault <IPEndPoint>(prefix + ".server", new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9051)); settings.Password = config.GetOrDefault <string>(prefix + ".password", null); settings.CookieFile = config.GetOrDefault <string>(prefix + ".cookiefile", null); settings.VirtualPort = config.GetOrDefault <int>(prefix + ".virtualport", 80); return(settings); }
public void Initialize(TextFileConfiguration configReader) { this.ConfigReader = configReader; this.BotToken = configReader.GetOrDefault <string>("token", "NDc2ODU5MDc1MzM1MDI4NzM4.DkztLQ.lWroAup2WOK8VZAyhGjG_E33ENY"); this.EnableMigrations = configReader.GetOrDefault <bool>("enableMigrations", true); this.ConnectionString = configReader.GetOrDefault <string>("connectionString", @"Data Source=(LocalDb)\testDb;Initial Catalog=testBotDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); }
public FederatedPegSettings(NodeSettings nodeSettings, IFederatedPegOptions federatedPegOptions = null) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration configReader = nodeSettings.ConfigReader; this.IsMainChain = configReader.GetOrDefault("mainchain", false); if (!this.IsMainChain && !configReader.GetOrDefault("sidechain", false)) { throw new ConfigurationException("Either -mainchain or -sidechain must be specified"); } string redeemScriptRaw = configReader.GetOrDefault <string>(RedeemScriptParam, null); Console.WriteLine(redeemScriptRaw); if (redeemScriptRaw == null) { throw new ConfigurationException($"could not find {RedeemScriptParam} configuration parameter"); } this.MultiSigRedeemScript = new Script(redeemScriptRaw); this.MultiSigAddress = this.MultiSigRedeemScript.Hash.GetAddress(nodeSettings.Network); PayToMultiSigTemplateParameters payToMultisigScriptParams = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(this.MultiSigRedeemScript); this.MultiSigM = payToMultisigScriptParams.SignatureCount; this.MultiSigN = payToMultisigScriptParams.PubKeys.Length; this.FederationPublicKeys = payToMultisigScriptParams.PubKeys; this.PublicKey = configReader.GetOrDefault <string>(PublicKeyParam, null); if (this.FederationPublicKeys.All(p => p != new PubKey(this.PublicKey))) { throw new ConfigurationException("Please make sure the public key passed as parameter was used to generate the multisig redeem script."); } // Federation IPs - These are required to receive and sign withdrawal transactions. string federationIpsRaw = configReader.GetOrDefault <string>(FederationIpsParam, null); if (federationIpsRaw == null) { throw new ConfigurationException("Federation IPs must be specified."); } IEnumerable <IPEndPoint> endPoints = federationIpsRaw.Split(',').Select(a => a.ToIPEndPoint(nodeSettings.Network.DefaultPort)); this.FederationNodeIpEndPoints = new HashSet <IPEndPoint>(endPoints, new IPEndPointComparer()); this.FederationNodeIpAddresses = new HashSet <IPAddress>(endPoints.Select(x => x.Address), new IPAddressComparer()); // These values are only configurable for tests at the moment. Fed members on live networks shouldn't play with them. this.CounterChainDepositStartBlock = configReader.GetOrDefault(CounterChainDepositBlock, this.IsMainChain ? 1 : StratisMainDepositStartBlock); this.FasterDepositThresholdAmount = Money.Coins(configReader.GetOrDefault(FasterDepositThresholdAmountParam, 100)); this.FasterDepositMinimumConfirmations = configReader.GetOrDefault(FasterDepositMinimumConfirmationsParam, 10); this.MinimumDepositConfirmations = configReader.GetOrDefault(MinimumDepositConfirmationsParam, (int)nodeSettings.Network.Consensus.MaxReorgLength + 1); this.WalletSyncFromHeight = configReader.GetOrDefault(WalletSyncFromHeightParam, federatedPegOptions?.WalletSyncFromHeight ?? 0); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public ApiSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(ApiSettings).FullName); this.logger.LogTrace("({0}:'{1}')", nameof(nodeSettings), nodeSettings.Network.Name); TextFileConfiguration config = nodeSettings.ConfigReader; this.UseHttps = config.GetOrDefault("usehttps", false); this.HttpsCertificateFilePath = config.GetOrDefault("certificatefilepath", (string)null); if (this.UseHttps && string.IsNullOrWhiteSpace(this.HttpsCertificateFilePath)) { throw new ConfigurationException("The path to a certificate needs to be provided when using https. Please use the argument 'certificatefilepath' to provide it."); } var defaultApiHost = this.UseHttps ? DefaultApiHost.Replace(@"http://", @"https://") : DefaultApiHost; string apiHost = config.GetOrDefault("apiuri", defaultApiHost, this.logger); var apiUri = new Uri(apiHost); // Find out which port should be used for the API. int apiPort = config.GetOrDefault("apiport", GetDefaultPort(nodeSettings.Network), this.logger); // If no port is set in the API URI. if (apiUri.IsDefaultPort) { this.ApiUri = new Uri($"{apiHost}:{apiPort}"); this.ApiPort = apiPort; } // If a port is set in the -apiuri, it takes precedence over the default port or the port passed in -apiport. else { this.ApiUri = apiUri; this.ApiPort = apiUri.Port; } // Set the keepalive interval (set in seconds). int keepAlive = config.GetOrDefault("keepalive", 0, this.logger); if (keepAlive > 0) { this.KeepaliveTimer = new Timer { AutoReset = false, Interval = keepAlive * 1000 }; } this.logger.LogTrace("(-)"); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public DiagnosticSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(this.GetType().FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.PeersStatisticsCollectorEnabled = config.GetOrDefault("diagpeerstats", DefaultPeersStatisticsCollectorEnabled, this.logger); this.MaxPeerLoggedEvents = config.GetOrDefault("diagpeerstatsmaxlog", DefaultMaxPeerLoggedEvents, this.logger); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public WalletSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(WalletSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.SaveTransactionHex = config.GetOrDefault <bool>("savetrxhex", false, this.logger); this.UnusedAddressesBuffer = config.GetOrDefault <int>("walletaddressbuffer", 20, this.logger); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public ConsensusSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(ConsensusSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.UseCheckpoints = config.GetOrDefault <bool>("checkpoints", true, this.logger); this.BlockAssumedValid = config.GetOrDefault <uint256>("assumevalid", nodeSettings.Network.Consensus.DefaultAssumeValid, this.logger); this.MaxTipAge = config.GetOrDefault("maxtipage", nodeSettings.Network.MaxTipAge, this.logger); }
/// <summary> /// Loads the storage related settings from the application configuration. /// </summary> /// <param name="config">Application configuration.</param> public void Load(TextFileConfiguration config) { this.Prune = config.GetOrDefault("prune", 0) != 0; this.TxIndex = config.GetOrDefault("txindex", 0) != 0; if (this.Prune && this.TxIndex) { throw new ConfigurationException("Prune mode is incompatible with -txindex"); } this.ReIndex = config.GetOrDefault("reindex", 0) != 0; // TODO: --reindex }
public void Initialize(TextFileConfiguration configReader) { this.ConfigReader = configReader; this.BotToken = configReader.GetOrDefault <string>("token", "BOTTOKENKEYHERE"); this.EnableMigrations = configReader.GetOrDefault <bool>("enableMigrations", true); this.ConnectionString = configReader.GetOrDefault <string>("connectionString", @"Data Source=127.0.0.1;Initial Catalog=TipBot;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); this.Ticker = configReader.GetOrDefault <string>("ticker", "STRAT"); this.NetworkFee = configReader.GetOrDefault <decimal>("networkFee", 0.01m); }
/// <summary> /// Loads the logging settings from the application configuration. /// </summary> /// <param name="config">Application configuration.</param> public void Load(TextFileConfiguration config) { this.DebugArgs = config.GetOrDefault("debug", string.Empty).Split(',').Where(s => !string.IsNullOrEmpty(s)).ToList(); // Get the minimum log level. The default is either Information or Debug depending on the DebugArgs. this.LogLevel = this.DebugArgs.Any() ? NLog.LogLevel.Debug : NLog.LogLevel.Info; string logLevelArg = config.GetOrDefault("loglevel", string.Empty); if (!string.IsNullOrEmpty(logLevelArg)) { this.LogLevel = NLog.LogLevel.FromString(logLevelArg); } }
/// <summary> /// Loads the API related settings from the application configuration. /// </summary> /// <param name="nodeSettings">Application configuration.</param> public void Load(NodeSettings nodeSettings) { TextFileConfiguration config = nodeSettings.ConfigReader; var apiHost = config.GetOrDefault("apiuri", DefaultApiHost); Uri apiUri = new Uri(apiHost); // Find out which port should be used for the API. int port; if (nodeSettings.Network.IsBitcoin()) { port = nodeSettings.Network.IsTest() ? TestBitcoinApiPort : DefaultBitcoinApiPort; } else { port = nodeSettings.Network.IsTest() ? TestStratisApiPort : DefaultStratisApiPort; } var apiPort = config.GetOrDefault("apiport", port); // If no port is set in the API URI. if (apiUri.IsDefaultPort) { this.ApiUri = new Uri($"{apiHost}:{apiPort}"); this.ApiPort = apiPort; } // If a port is set in the -apiuri, it takes precedence over the default port or the port passed in -apiport. else { this.ApiUri = apiUri; this.ApiPort = apiUri.Port; } // Set the keepalive interval (set in seconds). var keepAlive = config.GetOrDefault("keepalive", 0); if (keepAlive > 0) { this.KeepaliveTimer = new Timer { AutoReset = false, Interval = keepAlive * 1000 }; } this.callback?.Invoke(this); }
public StoreSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.Prune = config.GetOrDefault <bool>("prune", false); this.TxIndex = config.GetOrDefault <bool>("txindex", false); this.ReIndex = config.GetOrDefault <bool>("reindex", false); this.MaxCacheBlocksCount = nodeSettings.ConfigReader.GetOrDefault("maxCacheBlocksCount", DefaultMaxCacheBlocksCount); if (this.Prune && this.TxIndex) { throw new ConfigurationException("Prune mode is incompatible with -txindex"); } }
/// <summary> /// Writes and reads the information file. Use this to verify database schema. /// </summary> /// <param name="nodeSettings"></param> /// <returns></returns> public NodeInfo CreateOrReadNodeInfo() { var nodeInfo = new NodeInfo(); // Write the schema version, if not already exists. var infoPath = System.IO.Path.Combine(this.nodeSettings.DataDir, FILENAME); if (!File.Exists(infoPath)) { // For clients earlier than this version, the database already existed so we'll // write that it is currently version 100. var infoBuilder = new System.Text.StringBuilder(); // If the chain exists from before, but we did not have .info file, the database is old version. if (System.IO.Directory.Exists(this.nodeSettings.DataFolder.ChainPath)) { infoBuilder.AppendLine("dbversion=100"); nodeInfo.DatabaseVersion = 100; } else { infoBuilder.AppendLine("dbversion=" + DATABASE_VERSION); nodeInfo.DatabaseVersion = DATABASE_VERSION; } File.WriteAllText(infoPath, infoBuilder.ToString()); } else { var fileConfig = new TextFileConfiguration(File.ReadAllText(infoPath)); nodeInfo.DatabaseVersion = fileConfig.GetOrDefault <int>("dbversion", DATABASE_VERSION); } return(nodeInfo); }
private static int GetQuorumFromArguments() { int quorum = ConfigReader.GetOrDefault("quorum", 0); if (quorum == 0) { throw new ArgumentException("Please specify a quorum."); } if (quorum < 0) { throw new ArgumentException("Please specify a positive number for the quorum."); } return(quorum); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public X1MinerSettings(NodeSettings nodeSettings) : base(nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(X1MinerSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; if (this.Mine) { this.MineThreadCount = config.GetOrDefault("minethreads", 1, this.logger); this.UseOpenCL = config.GetOrDefault("useopencl", false, this.logger); this.OpenCLDevice = config.GetOrDefault("opencldevice", string.Empty, this.logger); this.OpenCLWorksizeSplit = config.GetOrDefault("openclworksizesplit", 10, this.logger); } }
public void Run(string[] args) { INetworkSet networkSet = AltNetworkSets.Bitcoin; var argsConf = new TextFileConfiguration(args); var debug = argsConf.GetOrDefault <bool>("debug", false); ConsoleLoggerProcessor loggerProcessor = new ConsoleLoggerProcessor(); Logs.Configure(new FuncLoggerFactory(i => new CustomerConsoleLogger(i, Logs.SupportDebug(debug), null, loggerProcessor))); using (var interactive = new Interactive()) { var config = new TumblerConfiguration(); config.LoadArgs(networkSet, args); try { var runtime = TumblerRuntime.FromConfiguration(config, new TextWriterClientInteraction(Console.Out, Console.In)); interactive.Runtime = new ServerInteractiveRuntime(runtime); StoppableWebHost host = null; if (!config.OnlyMonitor) { host = new StoppableWebHost(() => new WebHostBuilder() .UseAppConfiguration(runtime) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup <Startup>() .Build()); } var job = new BroadcasterJob(interactive.Runtime.Services); job.Start(); interactive.Services.Add(job); var tor = new TorRegisterJob(config, runtime); tor.Start(); interactive.Services.Add(tor); if (!config.OnlyMonitor) { host.Start(); interactive.Services.Add(host); } interactive.StartInteractive(); } catch (ConfigException ex) { if (!string.IsNullOrEmpty(ex.Message)) { Logs.Configuration.LogError(ex.Message); } } catch (InterruptedConsoleException) { } catch (Exception exception) { Logs.Tumbler.LogError("Exception thrown while running the server"); Logs.Tumbler.LogError(exception.ToString()); } } }
public void Initialize(TextFileConfiguration configReader) { this.BotToken = configReader.GetOrDefault <string>("token", "discordtoken"); // To run stratis daemon that supports RPC use "dotnet exec ...\netcoreapp2.1\Stratis.StratisD.dll -rpcuser=user -rpcpassword=4815162342 -rpcport=23521 -server=1" this.DaemonUrl = configReader.GetOrDefault <string>("daemonUrl", "http://127.0.0.1:23521/"); this.RpcUsername = configReader.GetOrDefault <string>("rpcUsername", "user"); this.RpcPassword = configReader.GetOrDefault <string>("rpcPassword", "4815162342"); this.WalletPassword = configReader.GetOrDefault <string>("walletPassword", "4815162342"); this.RpcRequestTimeoutInSeconds = configReader.GetOrDefault <short>("rpcTimeout", 20); this.ConfigReader = configReader; this.WalletName = configReader.GetOrDefault <string>("WalletName", "string"); this.FullNodeApiUrl = configReader.GetOrDefault <string>("fullNodeApiUrl", "http://127.0.0.1/api/"); this.FullNodeApiPort = configReader.GetOrDefault <int>("fullNodeApiPort", 38220); this.FullNodeApiEnabled = configReader.GetOrDefault <bool>("fullNodeApiEnabled", true); }
public WalletSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.SaveTransactionHex = config.GetOrDefault <bool>("savetrxhex", false); }
/// <summary> /// Load the consensus settings from the config settings. /// </summary> /// <returns>These consensus config settings.</returns> private ConsensusSettings LoadFromConfig() { TextFileConfiguration config = this.nodeSettings.ConfigReader; this.UseCheckpoints = config.GetOrDefault <bool>("checkpoints", true); this.BlockAssumedValid = config.GetOrDefault <uint256>("assumevalid", this.nodeSettings.Network.Consensus.DefaultAssumeValid); if (this.BlockAssumedValid == 0) // 0 means validate all blocks { this.BlockAssumedValid = null; } this.logger.LogDebug("Checkpoints are {0}.", this.UseCheckpoints ? "enabled" : "disabled"); this.logger.LogDebug("Assume valid block is '{0}'.", this.BlockAssumedValid == null ? "disabled" : this.BlockAssumedValid.ToString()); return(this); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public MinerSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(MinerSettings).FullName); this.logger.LogTrace("({0}:'{1}')", nameof(nodeSettings), nodeSettings.Network.Name); TextFileConfiguration config = nodeSettings.ConfigReader; this.Mine = config.GetOrDefault <bool>("mine", false, this.logger); if (this.Mine) { this.MineAddress = config.GetOrDefault <string>("mineaddress", null, this.logger); } this.Stake = config.GetOrDefault <bool>("stake", false, this.logger); if (this.Stake) { this.WalletName = config.GetOrDefault <string>("walletname", null, this.logger); this.WalletPassword = config.GetOrDefault <string>("walletpassword", null); // No logging! } uint blockMaxSize = (uint)config.GetOrDefault <int>("blockmaxsize", (int)nodeSettings.Network.Consensus.Options.MaxBlockSerializedSize, this.logger); uint blockMaxWeight = (uint)config.GetOrDefault <int>("blockmaxweight", (int)nodeSettings.Network.Consensus.Options.MaxBlockWeight, this.logger); this.BlockDefinitionOptions = new BlockDefinitionOptions(blockMaxWeight, blockMaxSize).RestrictForNetwork(nodeSettings.Network); this.logger.LogTrace("(-)"); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public WalletSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(WalletSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.SaveTransactionHex = config.GetOrDefault <bool>("savetrxhex", false, this.logger); this.UnusedAddressesBuffer = config.GetOrDefault <int>("walletaddressbuffer", 20, this.logger); this.DefaultWalletName = config.GetOrDefault <string>("defaultwalletname", null, this.logger); if (!string.IsNullOrEmpty(this.DefaultWalletName)) { this.DefaultWalletPassword = config.GetOrDefault <string>("defaultwalletpassword", "default", null); // No logging! this.UnlockDefaultWallet = config.GetOrDefault <bool>("unlockdefaultwallet", false, this.logger); } }
public void Initialize(TextFileConfiguration configReader) { this.ConfigReader = configReader; this.BotToken = configReader.GetOrDefault <string>("token", "$TOKEN"); this.Ticker = System.Environment.GetEnvironmentVariable("ticker"); this.BotOptionalPrefix = System.Environment.GetEnvironmentVariable("botprefix"); this.SupportUsername = System.Environment.GetEnvironmentVariable("supportUsername"); this.SupportDiscriminator = System.Environment.GetEnvironmentVariable("supportDiscriminator"); this.EnableMigrations = configReader.GetOrDefault <bool>("enableMigrations", true); this.ConnectionString = configReader.GetOrDefault <string>("connectionString", @"Data Source=localhost;Initial Catalog=testBotDb;user id=sa;password=password;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); }
/// <summary> /// Loads the logging settings from the application configuration. /// </summary> /// <param name="config">Application configuration.</param> /// <remarks>TODO: Currently only takes -debug arg.</remarks> public void Load(TextFileConfiguration config) { this.DebugArgs = config.GetOrDefault("debug", string.Empty).Split(',').Where(s => !string.IsNullOrEmpty(s)).ToList(); // Get the minimum log level. The default is Information. LogLevel minLogLevel = LogLevel.Information; string logLevelArg = config.GetOrDefault("loglevel", string.Empty); if (!string.IsNullOrEmpty(logLevelArg)) { if (!Enum.TryParse(logLevelArg, true, out minLogLevel)) { minLogLevel = LogLevel.Information; } } this.LogLevel = minLogLevel; }