public void Start() { Directory.CreateDirectory(this.runner.DataFolder); var config = new NodeConfigParameters(); config.Add("regtest", "1"); config.Add("rest", "1"); config.Add("server", "1"); config.Add("txindex", "1"); if (!CookieAuth) { config.Add("rpcuser", creds.UserName); config.Add("rpcpassword", creds.Password); } config.Add("port", this.ports[0].ToString()); config.Add("rpcport", this.ports[1].ToString()); config.Add("apiport", this.ports[2].ToString()); config.Add("printtoconsole", "1"); config.Add("keypool", "10"); config.Add("agentprefix", "node" + this.ports[0].ToString()); config.Import(this.ConfigParameters); File.WriteAllText(this.Config, config.ToString()); lock (this.lockObject) { this.runner.Start(); this.State = CoreNodeState.Starting; } if (this.runner is BitcoinCoreRunner) { StartBitcoinCoreRunner(); } else { StartStratisRunner(); } this.State = CoreNodeState.Running; }
private void CreateConfigFile(NodeConfigParameters configParameters = null) { Directory.CreateDirectory(this.runner.DataFolder); configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("regtest", "1"); configParameters.SetDefaultValueIfUndefined("rest", "1"); configParameters.SetDefaultValueIfUndefined("server", "1"); configParameters.SetDefaultValueIfUndefined("txindex", "1"); if (!this.CookieAuth) { configParameters.SetDefaultValueIfUndefined("rpcuser", this.creds.UserName); configParameters.SetDefaultValueIfUndefined("rpcpassword", this.creds.Password); } configParameters.SetDefaultValueIfUndefined("printtoconsole", "1"); configParameters.SetDefaultValueIfUndefined("keypool", "10"); configParameters.SetDefaultValueIfUndefined("agentprefix", "node" + this.ProtocolPort); configParameters.Import(this.ConfigParameters); File.WriteAllText(this.Config, configParameters.ToString()); }
private void CreateConfigFile(NodeConfigParameters configParameters = null) { Directory.CreateDirectory(this.runner.DataFolder); configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("regtest", "1"); configParameters.SetDefaultValueIfUndefined("rest", "1"); configParameters.SetDefaultValueIfUndefined("server", "1"); configParameters.SetDefaultValueIfUndefined("txindex", "1"); if (!this.CookieAuth) { configParameters.SetDefaultValueIfUndefined("rpcuser", this.creds.UserName); configParameters.SetDefaultValueIfUndefined("rpcpassword", this.creds.Password); } // The debug log is disabled in stratisX when printtoconsole is enabled. // While further integration tests are being developed it makes sense // to always have the debug logs available, as there is minimal other // insight into the stratisd process while it is running. if (this.runner is StratisXRunner) { configParameters.SetDefaultValueIfUndefined("printtoconsole", "0"); configParameters.SetDefaultValueIfUndefined("debug", "1"); } else { configParameters.SetDefaultValueIfUndefined("printtoconsole", "1"); } configParameters.SetDefaultValueIfUndefined("keypool", "10"); configParameters.SetDefaultValueIfUndefined("agentprefix", "node" + this.ProtocolPort); configParameters.Import(this.ConfigParameters); File.WriteAllText(this.Config, configParameters.ToString()); }
private void CreateConfigFile(NodeConfigParameters configParameters = null) { Directory.CreateDirectory(this.runner.DataFolder); configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("regtest", "1"); configParameters.SetDefaultValueIfUndefined("rest", "1"); configParameters.SetDefaultValueIfUndefined("server", "1"); configParameters.SetDefaultValueIfUndefined("txindex", "1"); if (this.runner is BitcoinCoreRunner) { // TODO: Migrate to using `generatetoaddress` RPC for newer Core versions configParameters.SetDefaultValueIfUndefined("deprecatedrpc", "generate"); } if (!this.CookieAuth) { configParameters.SetDefaultValueIfUndefined("rpcuser", this.creds.UserName); configParameters.SetDefaultValueIfUndefined("rpcpassword", this.creds.Password); } configParameters.SetDefaultValueIfUndefined("printtoconsole", "1"); configParameters.SetDefaultValueIfUndefined("keypool", "10"); configParameters.SetDefaultValueIfUndefined("agentprefix", "node" + this.ProtocolPort); configParameters.Import(this.ConfigParameters); // Need special handling for config files used by newer versions of Bitcoin Core. // These have specialised sections for [regtest], [test] and [main] in which certain options // only have an effect when they appear in their respective section. var builder = new StringBuilder(); // Scan for network setting. These need to be at the top of the config file. bool testnet = configParameters.Any(a => a.Key.Equals("testnet") && a.Value.Equals("1")); bool regtest = configParameters.Any(a => a.Key.Equals("regtest") && a.Value.Equals("1")); bool mainnet = !testnet && !regtest; if (testnet) { builder.AppendLine("testnet=1"); if (this.runner.UseNewConfigStyle) { builder.AppendLine("[test]"); } } if (regtest) { builder.AppendLine("regtest=1"); if (this.runner.UseNewConfigStyle) { builder.AppendLine("[regtest]"); } } if (mainnet) { // Mainnet is implied by the absence of both testnet and regtest. But it should still get its own config section. if (this.runner.UseNewConfigStyle) { builder.AppendLine("[main]"); } } foreach (KeyValuePair <string, string> kv in configParameters) { if (kv.Key.Equals("testnet") || kv.Key.Equals("regtest")) { continue; } builder.AppendLine(kv.Key + "=" + kv.Value); } File.WriteAllText(this.Config, builder.ToString()); }