/// <summary>A helper method to create a node instance with a non-standard set of features enabled. The node can be PoW or PoS, as long as the appropriate features are provided.</summary> /// <param name="callback">A callback accepting an instance of <see cref="IFullNodeBuilder"/> that constructs a node with a custom feature set.</param> /// <param name="network">The network the node will be running on.</param> /// <param name="protocolVersion">Use <see cref="ProtocolVersion.PROTOCOL_VERSION"/> for BTC PoW-like networks and <see cref="ProtocolVersion.ALT_PROTOCOL_VERSION"/> for Stratis PoS-like networks.</param> /// <param name="agent">A user agent string to distinguish different node versions from each other.</param> /// <param name="configParameters">Use this to pass in any custom configuration parameters used to set up the CoreNode</param> public CoreNode CreateCustomNode(Action <IFullNodeBuilder> callback, Network network, ProtocolVersion protocolVersion = ProtocolVersion.PROTOCOL_VERSION, string agent = "Custom", NodeConfigParameters configParameters = null, ProtocolVersion minProtocolVersion = ProtocolVersion.PROTOCOL_VERSION) { configParameters = configParameters ?? new NodeConfigParameters(); configParameters.SetDefaultValueIfUndefined("conf", "custom.conf"); string configFileName = configParameters["conf"]; configParameters.SetDefaultValueIfUndefined("datadir", this.GetNextDataFolderName(agent)); string dataDir = configParameters["datadir"]; configParameters.ToList().ForEach(p => this.ConfigParameters[p.Key] = p.Value); return(CreateNode(new CustomNodeRunner(dataDir, callback, network, protocolVersion, configParameters, agent, minProtocolVersion), configFileName)); }
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()); }