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()); } } }
private void Add(INetworkSet networkSet, NetworkType networkType, NBXplorerNetwork nbXplorerNetwork, KeyPath baseKeyPath, string bolt11InvoicePrefix) { var n = new NRustLightningNetwork(networkSet, networkType, nbXplorerNetwork, baseKeyPath, bolt11InvoicePrefix); _Networks.Add(networkSet.CryptoCode.ToLowerInvariant(), n); _invoicePrefixToNetwork.Add(bolt11InvoicePrefix, n); }
internal NRustLightningNetwork(INetworkSet networkSet, NetworkType networkType, NBXplorerNetwork nbXplorerNetwork, KeyPath baseKeyPath, string bolt11InvoicePrefix) { NbXplorerNetwork = nbXplorerNetwork; BaseKeyPath = baseKeyPath; BOLT11InvoicePrefix = bolt11InvoicePrefix; NBitcoinNetwork = networkSet.GetNetwork(networkType); CryptoCode = networkSet.CryptoCode.ToLowerInvariant(); }
public NBXplorerNetwork(INetworkSet networkSet, NetworkType networkType, DerivationStrategyFactory derivationStrategyFactory = null) { NBitcoinNetwork = networkSet.GetNetwork(networkType); CryptoCode = networkSet.CryptoCode; DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(networkType); DerivationStrategyFactory = derivationStrategyFactory; }
internal NBXplorerNetwork(INetworkSet networkSet, ChainName networkType) { NBitcoinNetwork = networkSet.GetNetwork(networkType); CryptoCode = networkSet.CryptoCode; DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(networkType); }
public NBXplorerNetwork(INetworkSet networkSet, NBitcoin.NetworkType networkType) { NBitcoinNetwork = networkSet.GetNetwork(networkType); CryptoCode = networkSet.CryptoCode; DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(networkType); }
public TumblerConfiguration LoadArgs(INetworkSet networkSet, String[] args) { ConfigurationFile = args.Where(a => a.StartsWith("-conf=", StringComparison.Ordinal)).Select(a => a.Substring("-conf=".Length).Replace("\"", "")).FirstOrDefault(); DataDir = args.Where(a => a.StartsWith("-datadir=", StringComparison.Ordinal)).Select(a => a.Substring("-datadir=".Length).Replace("\"", "")).FirstOrDefault(); if (DataDir != null && ConfigurationFile != null) { var isRelativePath = Path.GetFullPath(ConfigurationFile).Length > ConfigurationFile.Length; if (isRelativePath) { ConfigurationFile = Path.Combine(DataDir, ConfigurationFile); } } Network = args.Contains("-testnet", StringComparer.OrdinalIgnoreCase) ? networkSet.Testnet : args.Contains("-regtest", StringComparer.OrdinalIgnoreCase) ? networkSet.Regtest : networkSet.Mainnet; if (ConfigurationFile != null) { AssetConfigFileExists(); var configTemp = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); Network = configTemp.GetOrDefault <bool>("testnet", false) ? networkSet.Testnet : configTemp.GetOrDefault <bool>("regtest", false) ? networkSet.Regtest : networkSet.Mainnet; } if (DataDir == null) { DataDir = DefaultDataDirectory.GetDefaultDirectory("NTumbleBitServer", Network); } if (ConfigurationFile == null) { ConfigurationFile = GetDefaultConfigurationFile(Network); } Logs.Configuration.LogInformation("Network: " + Network); Logs.Configuration.LogInformation("Data directory set to " + DataDir); Logs.Configuration.LogInformation("Configuration file set to " + ConfigurationFile); if (!Directory.Exists(DataDir)) { throw new ConfigurationException("Data directory does not exists"); } var consoleConfig = new TextFileConfiguration(args); var config = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); consoleConfig.MergeInto(config, true); if (config.Contains("help")) { Console.WriteLine("Details on the wiki page : https://github.com/NTumbleBit/NTumbleBit/wiki/Server-Config"); OpenBrowser("https://github.com/NTumbleBit/NTumbleBit/wiki/Server-Config"); Environment.Exit(0); } var standardCycles = new StandardCycles(Network); var cycleName = config.GetOrDefault <string>("cycle", standardCycles.Debug ? "shorty2x" : "kotori"); Logs.Configuration.LogInformation($"Using cycle {cycleName}"); var standardCycle = standardCycles.GetStandardCycle(cycleName); if (standardCycle == null) { throw new ConfigException($"Invalid cycle name, choose among {String.Join(",", standardCycles.ToEnumerable().Select(c => c.FriendlyName).ToArray())}"); } ClassicTumblerParameters.CycleGenerator = standardCycle.Generator; ClassicTumblerParameters.Denomination = standardCycle.Denomination; var torEnabled = config.GetOrDefault <bool>("tor.enabled", true); if (torEnabled) { TorSettings = TorConnectionSettings.ParseConnectionSettings("tor", config); } Cooperative = config.GetOrDefault <bool>("cooperative", true); var defaultPort = config.GetOrDefault <int>("port", 37123); OnlyMonitor = config.GetOrDefault <bool>("onlymonitor", false); Listen = new IPEndPoint(IPAddress.Parse("127.0.0.1"), defaultPort); RPC = RPCArgs.Parse(config, Network); //0.1% fee by default var defaultFee = Money.Satoshis((decimal)ClassicTumblerParameters.Denomination.Satoshi * 0.001m); ClassicTumblerParameters.Fee = config.GetOrDefault <Money>("tumbler.fee", defaultFee); TorPath = config.GetOrDefault <string>("torpath", "tor"); return(this); }
public NetworkBuilder SetNetworkSet(INetworkSet networkSet) { _NetworkSet = networkSet; return(this); }
internal LiquidNBXplorerNetwork(INetworkSet networkSet, ChainName networkType) : base(networkSet, networkType) { }
public void Run(string[] args) { INetworkSet networkSet = AltNetworkSets.Bitcoin; var argsConf = new TextFileConfiguration(args); var debug = argsConf.GetOrDefault <bool>("debug", false); var redeemEscrows = argsConf.GetOrDefault <bool>("redeemescrows", false);; ConsoleLoggerProcessor loggerProcessor = new ConsoleLoggerProcessor(); Logs.Configure(new FuncLoggerFactory(i => new CustomerConsoleLogger(i, Logs.SupportDebug(debug), null, loggerProcessor))); using (var interactive = new Interactive()) { try { var config = new TumblerClientConfiguration(); config.LoadArgs(networkSet, args); var runtime = TumblerClientRuntime.FromConfiguration(config, new TextWriterClientInteraction(Console.Out, Console.In)); interactive.Runtime = new ClientInteractiveRuntime(runtime); if (redeemEscrows) { RedeemEscrows(runtime).GetAwaiter().GetResult(); } 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 TumblerClientConfiguration LoadArgs(INetworkSet networkSet, String[] args) { ConfigurationFile = args.Where(a => a.StartsWith("-conf=", StringComparison.Ordinal)).Select(a => a.Substring("-conf=".Length).Replace("\"", "")).FirstOrDefault(); DataDir = args.Where(a => a.StartsWith("-datadir=", StringComparison.Ordinal)).Select(a => a.Substring("-datadir=".Length).Replace("\"", "")).FirstOrDefault(); if (DataDir != null && ConfigurationFile != null) { var isRelativePath = Path.GetFullPath(ConfigurationFile).Length > ConfigurationFile.Length; if (isRelativePath) { ConfigurationFile = Path.Combine(DataDir, ConfigurationFile); } } Network = args.Contains("-testnet", StringComparer.OrdinalIgnoreCase) ? networkSet.Testnet : args.Contains("-regtest", StringComparer.OrdinalIgnoreCase) ? networkSet.Regtest : networkSet.Mainnet; if (ConfigurationFile != null) { AssetConfigFileExists(); var configTemp = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); Network = configTemp.GetOrDefault <bool>("testnet", false) ? networkSet.Testnet : configTemp.GetOrDefault <bool>("regtest", false) ? networkSet.Regtest : networkSet.Mainnet; } if (DataDir == null) { DataDir = DefaultDataDirectory.GetDefaultDirectory("NTumbleBit", Network); } if (ConfigurationFile == null) { ConfigurationFile = GetDefaultConfigurationFile(DataDir, Network); } Logs.Configuration.LogInformation("Network: " + Network); Logs.Configuration.LogInformation("Data directory set to " + DataDir); Logs.Configuration.LogInformation("Configuration file set to " + ConfigurationFile); if (!Directory.Exists(DataDir)) { throw new ConfigurationException("Data directory does not exists"); } var consoleConfig = new TextFileConfiguration(args); var config = TextFileConfiguration.Parse(File.ReadAllText(ConfigurationFile)); consoleConfig.MergeInto(config, true); config.AddAlias("server", "tumbler.server"); OnlyMonitor = config.GetOrDefault <bool>("onlymonitor", false); Cooperative = config.GetOrDefault <bool>("cooperative", true); TumblerServer = config.GetOrDefault("tumbler.server", null as TumblerUrlBuilder); TorPath = config.GetOrDefault <string>("torpath", "tor"); RPCArgs = RPCArgs.Parse(config, Network); if (!OnlyMonitor && TumblerServer == null) { throw new ConfigException("tumbler.server not configured"); } try { var key = config.GetOrDefault("outputwallet.extpubkey", null as string); if (key != null) { OutputWallet.RootKey = new BitcoinExtPubKey(key, Network); } } catch { throw new ConfigException("outputwallet.extpubkey is not configured correctly"); } OutputWallet.KeyPath = new KeyPath("0"); string keyPathString = config.GetOrDefault("outputwallet.keypath", null as string); if (keyPathString != null) { try { OutputWallet.KeyPath = new KeyPath(keyPathString); } catch { throw new ConfigException("outputwallet.keypath is not configured correctly"); } } if (OutputWallet.KeyPath.ToString().Contains("'")) { throw new ConfigException("outputwallet.keypath should not contain any hardened derivation"); } if (OutputWallet.RootKey != null && OutputWallet.RootKey.Network != Network) { throw new ConfigException("outputwallet.extpubkey is pointing an incorrect network"); } OutputWallet.RPCArgs = RPCArgs.Parse(config, Network, "outputwallet"); AliceConnectionSettings = ConnectionSettingsBase.ParseConnectionSettings("alice", config); BobConnectionSettings = ConnectionSettingsBase.ParseConnectionSettings("bob", config); AllowInsecure = config.GetOrDefault <bool>("allowinsecure", IsTest(Network)); return(this); }
public LiquidNBXplorerNetwork(INetworkSet networkSet, NetworkType networkType, DerivationStrategyFactory derivationStrategyFactory = null) : base(networkSet, networkType, derivationStrategyFactory) { }