/// <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"); } }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> /// <param name="network">The network managment.</param> public xServerSettings(NodeSettings nodeSettings, Network network) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); Guard.NotNull(network, nameof(network)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(xServerSettings).FullName); this.network = network; TextFileConfiguration config = nodeSettings.ConfigReader; this.addxServerNodeLock = new object(); lock (this.addxServerNodeLock) { this.addxServerNode = new List <NetworkXServer>(); } try { foreach (NetworkXServer addNode in config.GetAll("addxservernode", this.logger).Select(c => c.ToIPXServerEndPoint(4242, 0))) { this.AddAddNode(addNode); } } catch (FormatException) { throw new ConfigurationException("Invalid 'addxservernode' parameter."); } AddSeedNodes(); }
private static void HandleSwitchGenerateMultiSigAddressesCommand(string[] args) { ConfigReader = new TextFileConfiguration(args); ConfirmArguments(ConfigReader, "network", "quorum", "fedpubkeys"); int quorum = GetQuorumFromArguments(); string[] federatedPublicKeys = GetFederatedPublicKeysFromArguments(); if (quorum > federatedPublicKeys.Length) { throw new ArgumentException("Quorum has to be smaller than the number of members within the federation."); } if (quorum < federatedPublicKeys.Length / 2) { throw new ArgumentException("Quorum has to be greater than half of the members within the federation."); } (Network mainChain, Network sideChain) = GetMainAndSideChainNetworksFromArguments(); Console.WriteLine($"Creating multisig addresses for {mainChain.Name} and {sideChain.Name}."); Console.WriteLine(new MultisigAddressCreator().CreateMultisigAddresses(mainChain, sideChain, federatedPublicKeys.Select(f => new PubKey(f)).ToArray(), quorum)); }
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; } }
private static void HandleSwitchGenerateFundsRecoveryTransaction(string[] args) { ConfigReader = new TextFileConfiguration(args); // datadir = Directory of old federation. ConfirmArguments(ConfigReader, "network", "datadir", "fedpubkeys", "quorum", "password", "txtime"); Script newRedeemScript = GetRedeemScriptFromArguments(); string password = GetPasswordFromArguments(); string dataDirPath = GetDataDirFromArguments(); (Network mainChain, Network sideChain) = GetMainAndSideChainNetworksFromArguments(); DateTime txTime = GetTransactionTimeFromArguments(); Console.WriteLine($"Creating funds recovery transaction for {sideChain.Name}."); FundsRecoveryTransactionModel sideChainInfo = (new RecoveryTransactionCreator()).CreateFundsRecoveryTransaction(true, sideChain, mainChain, dataDirPath, newRedeemScript, password, txTime); sideChainInfo.DisplayInfo(); Console.WriteLine($"Creating funds recovery transaction for {mainChain.Name}."); FundsRecoveryTransactionModel mainChainInfo = (new RecoveryTransactionCreator()).CreateFundsRecoveryTransaction(false, mainChain, sideChain, dataDirPath, newRedeemScript, password, txTime); mainChainInfo.DisplayInfo(); }
/// <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 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; }
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> /// 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); }
/// <summary> /// Loads the DNS related settings from the application configuration. /// </summary> /// <param name="nodeSettings">Application configuration.</param> /// <param name="dnsSettings">Existing DnsSettings object to add loaded values to.</param> public DnsSettings Load(NodeSettings nodeSettings) { ILogger logger = nodeSettings.LoggerFactory.CreateLogger(typeof(DnsSettings).FullName); logger.LogTrace("()"); TextFileConfiguration config = nodeSettings.ConfigReader; this.DnsListenPort = config.GetOrDefault<int>("dnslistenport", DefaultDnsListenPort); logger.LogDebug("DNS Seed Service listen port is {0}, if running as DNS Seed.", this.DnsListenPort); this.DnsFullNode = config.GetOrDefault<bool>("dnsfullnode", false); if (this.DnsFullNode) logger.LogDebug("DNS Seed Service is set to run as a full node, if running as DNS Seed.", this.DnsListenPort); this.DnsPeerBlacklistThresholdInSeconds = config.GetOrDefault("dnspeerblacklistthresholdinseconds", DefaultDnsPeerBlacklistThresholdInSeconds); logger.LogDebug("DnsPeerBlacklistThresholdInSeconds set to {0}.", this.DnsPeerBlacklistThresholdInSeconds); this.DnsHostName = config.GetOrDefault<string>("dnshostname", null); logger.LogDebug("DNS Seed Service host name set to {0}.", this.DnsHostName); this.DnsNameServer = config.GetOrDefault<string>("dnsnameserver", null); logger.LogDebug("DNS Seed Service nameserver set to {0}.", this.DnsNameServer); this.DnsMailBox = config.GetOrDefault<string>("dnsmailbox", null); logger.LogDebug("DNS Seed Service mailbox set to {0}.", this.DnsMailBox); this.callback?.Invoke(this); logger.LogTrace("(-)"); return this; }
/// <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"); } }
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 PoAMinerSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.BootstrappingMode = config.GetOrDefault <bool>("bootstrap", false); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="serverSettings">The node configuration.</param> public NetworkSettings(ServerSettings serverSettings) { Guard.NotNull(serverSettings, nameof(serverSettings)); logger = serverSettings.LoggerFactory.CreateLogger(typeof(NetworkSettings).FullName); TextFileConfiguration config = serverSettings.ConfigReader; }
public WalletSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.SaveTransactionHex = config.GetOrDefault <bool>("savetrxhex", false); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public Unity3dApiSettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(Unity3dApiSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; this.EnableUnityAPI = config.GetOrDefault("unityapi_enable", false); if (!this.EnableUnityAPI) { this.logger.LogDebug("Unity API disabled."); return; } this.UseHttps = config.GetOrDefault("unityapi_usehttps", false); this.HttpsCertificateFilePath = config.GetOrDefault("unityapi_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("unityapi_apiuri", defaultApiHost, this.logger); var apiUri = new Uri(apiHost); // Find out which port should be used for the API. int apiPort = config.GetOrDefault("unityapi_apiport", DefaultAPIPort, 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("unityapi_keepalive", 0, this.logger); if (keepAlive > 0) { this.KeepaliveTimer = new Timer { AutoReset = false, Interval = keepAlive * 1000 }; } }
public PoASettings(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.BootstrappingMode = config.GetOrDefault("bootstrap", false); this.MineAddress = config.GetOrDefault <string>("mineaddress", null); }
/// <summary> /// Loads the wallet settings from the application configuration. /// </summary> /// <param name="nodeSettings">Application configuration.</param> public void Load(NodeSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); TextFileConfiguration config = nodeSettings.ConfigReader; this.SaveTransactionHex = config.GetOrDefault <bool>("savetrxhex", false); this.callback?.Invoke(this); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="nodeSettings">The node configuration.</param> public ApiSettings(ServerSettings nodeSettings) { Guard.NotNull(nodeSettings, nameof(nodeSettings)); logger = nodeSettings.LoggerFactory.CreateLogger(typeof(ApiSettings).FullName); TextFileConfiguration config = nodeSettings.ConfigReader; UseHttps = config.GetOrDefault("usehttps", false); HttpsCertificateFilePath = config.GetOrDefault("certificatefilepath", (string)null); if (UseHttps && string.IsNullOrWhiteSpace(HttpsCertificateFilePath)) { throw new ConfigurationException( "The path to a certificate needs to be provided when using https. Please use the argument 'certificatefilepath' to provide it."); } string defaultApiHost = UseHttps ? DefaultApiHost.Replace(@"http://", @"https://") : DefaultApiHost; string apiHost = config.GetOrDefault("apiuri", defaultApiHost, logger); Uri apiUri = new Uri(apiHost); // Find out which port should be used for the API. int apiPort = config.GetOrDefault("apiport", GetDefaultPort(nodeSettings.ServerNode), logger); // If no port is set in the API URI. if (apiUri.IsDefaultPort) { ApiUri = new Uri($"{apiHost}:{apiPort}"); ApiPort = apiPort; } // If a port is set in the -apiuri, it takes precedence over the default port or the port passed in -apiport. else { ApiUri = apiUri; ApiPort = apiUri.Port; } // Set the keepalive interval (set in seconds). int keepAlive = config.GetOrDefault("keepalive", 0, logger); if (keepAlive > 0) { KeepaliveTimer = new Timer { AutoReset = false, Interval = keepAlive * 1000 } } ; // Enable the swagger UI. EnableSwagger = config.GetOrDefault("enableswagger", false); }
/// <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 port = nodeSettings.Network.IsBitcoin() ? 37220 : 37221; this.ApiUri = config.GetOrDefault("apiuri", new Uri($"http://localhost:{port}")); this.callback?.Invoke(this); }
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 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); }
/// <summary> /// Initializes an instance of the object from the node configuration. /// </summary> /// <param name="serverSettings">The node configuration.</param> public NetworkSettings(ServerSettings serverSettings) { Guard.NotNull(serverSettings, nameof(serverSettings)); logger = serverSettings.LoggerFactory.CreateLogger(typeof(NetworkSettings).FullName); TextFileConfiguration config = serverSettings.ConfigReader; BypassTierCheck = config.GetOrDefault("bypasstiercheck", false, logger); }
public void FailsToGetAllKeysWithArrayArgsAssignmentWithSpaces() { // Arrange var textFileConfiguration = new TextFileConfiguration(new[] { "test = testValue1", "-test = testValue2" }); // Act string[] result = textFileConfiguration.GetAll("test"); // Assert Assert.Empty(result); }
public void GetAllWithArrayArgs() { // Arrange var textFileConfiguration = new TextFileConfiguration(new[] { "test" }); // Act string[] result = textFileConfiguration.GetAll("test"); // Assert Assert.Equal("1", result[0]); }
public void Run(string[] args) { 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), false, loggerProcessor))); using (var interactive = new Interactive()) { try { var config = new TumblerClientConfiguration(); config.LoadArgs(args); var runtime = TumblerClientRuntime.FromConfiguration(config, new TextWriterClientInteraction(Console.Out, Console.In)); interactive.Runtime = new ClientInteractiveRuntime(runtime); var broadcaster = runtime.CreateBroadcasterJob(); broadcaster.Start(); interactive.Services.Add(broadcaster); //interactive.Services.Add(new CheckIpService(runtime)); //interactive.Services.Last().Start(); if (!config.OnlyMonitor) { var stateMachine = runtime.CreateStateMachineJob(); stateMachine.Start(); interactive.Services.Add(stateMachine); } interactive.StartInteractive(); } catch (ClientInteractionException ex) { if (!string.IsNullOrEmpty(ex.Message)) { Logs.Configuration.LogError(ex.Message); } } catch (ConfigException ex) { if (!string.IsNullOrEmpty(ex.Message)) { Logs.Configuration.LogError(ex.Message); } } catch (InterruptedConsoleException) { } catch (Exception ex) { Logs.Configuration.LogError(ex.Message); Logs.Configuration.LogDebug(ex.StackTrace); } } }
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); }
public void GetMimeValueWithFileString() { // Arrange var textFileConfiguration = new TextFileConfiguration("azurekey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); // Act string[] result = textFileConfiguration.GetAll("azurekey"); // Assert Assert.Single(result); Assert.Equal("Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", result[0]); }
private static void HandleSwitchGenerateMultiSigAddressesCommand(string[] args) { ConfigReader = new TextFileConfiguration(args); ConfirmArguments(ConfigReader, "network"); (_, Network sideChain, Network targetMainChain) = GetMainAndSideChainNetworksFromArguments(); Console.WriteLine($"Creating multisig addresses for {targetMainChain.Name} and {sideChain.Name}."); Console.WriteLine(new MultisigAddressCreator().CreateMultisigAddresses(targetMainChain, sideChain)); }