public static void Main(string[] args) { ILoggerFactory loggerFactory = new LoggerFactory() .AddConsole(LogLevel.Trace, false); Logs.Configure(loggerFactory); if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; NodeSettings nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); // NOTES: running BTC and STRAT side by side is not possible yet as the flags for serialization are static var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .Build(); // TODO: bring the logic out of IWebHost.Run() node.Start(); Console.WriteLine("Press any key to stop"); Console.ReadLine(); node.Dispose(); }
public static void Main(string[] args) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { // NOTE: Add this if .AddRPC is added below // RPCSettings.PrintHelp(Network.StratisMain); return; } var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); // NOTES: running BTC and STRAT side by side is not possible yet as the flags for serialization are static var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .UseWallet() .AddPowPosMining() .Build(); Task.Delay(TimeSpan.FromMinutes(1)).ContinueWith(t => { //TryStartPowMiner(args, node); //TryStartPosMiner(args, node); }); node.Run(); }
public static void Main(string[] args) { ILoggerFactory loggerFactory = Logs.GetLoggerFactory(args); Logs.Configure(loggerFactory); if (NodeSettings.PrintHelp(args, Network.Main)) { return; } NodeSettings nodeSettings = NodeSettings.FromArguments(args); if (!Checks.VerifyAccess(nodeSettings)) { return; } var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseConsensus() .UseBlockStore() .UseMempool() .AddMining(args.Any(a => a.Contains("mine"))) .AddRPC() .Build(); // TODO: bring the logic out of IWebHost.Run() node.Start(); Console.WriteLine("Press any key to stop"); Console.ReadLine(); node.Dispose(); }
public static void Main(string[] args) { Logs.Configure(Logs.GetLoggerFactory(args)); if (NodeSettings.PrintHelp(args, Network.Main)) { return; } NodeSettings nodeSettings = NodeSettings.FromArguments(args); if (!Checks.VerifyAccess(nodeSettings)) { return; } var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseConsensus() .UseBlockStore() .UseMempool() .AddMining() .AddRPC() .Build(); // start the miner (this is temporary a miner should be started using RPC. Task.Delay(TimeSpan.FromMinutes(1)).ContinueWith((t) => { TryStartMiner(args, node); }); node.Run(); }
public static void Main(string[] args) { ILoggerFactory loggerFactory = new LoggerFactory() .AddConsole(LogLevel.Trace, false); Logs.Configure(loggerFactory); if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } NodeSettings nodeSettings = NodeSettings.FromArguments(args, Network.StratisMain, ProtocolVersion.ALT_PROTOCOL_VERSION); // NOTES // - for now only download the stratis chain form peers // - adding consensus requires bigger changes // - running the nodes side by side is not possible yet as the flags for serialization are static var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .Build(); // TODO: bring the logic out of IWebHost.Run() node.Start(); Console.WriteLine("Press any key to stop"); Console.ReadLine(); node.Dispose(); }
public static async Task MainAsync(string[] args) { try { // Get the API uri. var apiUri = args.GetValueOf("apiuri"); var isTestNet = args.Contains("-testnet"); var isStratis = args.Contains("stratis"); var agent = "Breeze"; NodeSettings nodeSettings; if (isStratis) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } Network network = isTestNet ? Network.StratisTest : Network.StratisMain; if (isTestNet) { args = args.Append("-addnode=51.141.28.47").ToArray(); // TODO: fix this temp hack } nodeSettings = new NodeSettings("stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION, agent).LoadArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri); } else { nodeSettings = new NodeSettings(agent: agent).LoadArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri); } IFullNodeBuilder fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); IFullNode node = fullNodeBuilder.Build(); // Start Full Node - this will also start the API. await node.RunAsync(); } catch (Exception ex) { Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.Message); } }
static void Main(string[] args) { string[] args2 = { "-testnet", "-ctb", //"ctb://7obtcd7mkosmxeuh.onion?h=03c632023c4a8587845ad918b8e5f53f7bf18319", "ctb://wljlc26vwmc65lk6.onion?h=0f802acf528ca7a0742c3074ba7daa35bdae98c9", "-origin", "xxxx", "-destination", "yyyy" }; FuncLoggerFactory loggerFactory = new FuncLoggerFactory(i => new CustomerConsoleLogger(i, (a, b) => true, false)); Logs.Configure(loggerFactory); ArgsReader argsReader = new ArgsReader(args2); if (!argsReader.VerifyArgs()) { return; } //we don't want to be anywhere near MainNet if (NodeSettings.PrintHelp(args, Network.Main)) { return; } Uri tumblerUri = new Uri(argsReader.UriString); //Start the engines! NodeSettings nodeSettings = NodeSettings.FromArguments(args2); FullNode fullNode = StartupFullNode(nodeSettings, tumblerUri); fullNode.Run(); // Not needed at all, invoke tumbler connection via the API //ITumbleBitManager tumbleBitManager = new TumbleBitManager(loggerFactory, fullNode.WalletManager, null, fullNode.Chain, Network.TestNet, fullNode.Signals); //use the tumblebitManager with a wait //tumbleBitManager.ConnectToTumblerAsync(tumblerUri).GetAwaiter().GetResult(); //we don't want to do this as it will lock up the console... //tumbleBitManager.TumbleAsync(argsReader.OriginWalletName, argsReader.DestinationWalletName).GetAwaiter().GetResult(); }
/// <summary> /// The expected sequence of arguments is [network-name] [rpc-command] [rpc-params]. /// </summary> static void Main(string[] args) { if (NodeSettings.PrintHelp(args, Network.Main)) { // TODO: add more outputs // Proposal: use reflection to find all settings classes and print out help. RpcSettings.PrintHelp(Network.Main); return; } // hack until static flags are removed string blockchain = "bitcoin"; if (args.Any(a => a.Contains("stratis"))) { blockchain = "stratis"; var s = Network.StratisMain; var st = Network.StratisTest; } // The first argument is the network name var network = Network.GetNetwork(args.First()); NodeSettings nodeSettings = NodeSettings.FromArguments(args, blockchain, network); var rpcSettings = new RpcSettings(); rpcSettings.Load(nodeSettings); // Find the binding to 127.0.0.1 or the first available. The logic in RPC settings ensures there will be at least 1. System.Net.IPEndPoint nodeEndPoint = rpcSettings.Bind.FirstOrDefault(b => b.Address.ToString() == "127.0.0.1") ?? rpcSettings.Bind[0]; // Initilize the RPC client with the configured or passed userid, password and endpoint RPCClient rpc = new RPCClient($"{rpcSettings.RpcUser}:{rpcSettings.RpcPassword}", new Uri($"http://{nodeEndPoint}")); try { // Execute the RPC command RPCResponse response = rpc.SendCommand(args.ElementAt(1), args.Skip(2).ToArray()); // Return the result as a string to the console Console.WriteLine(response.ResultString); } catch (Exception err) { // Report any errors to the console Console.WriteLine(err.ToString()); } }
public static void Main(string[] args) { TraceSource ts = new TraceSource("NBitcoin"); SourceSwitch sourceSwitch = new SourceSwitch("SourceSwitch", "Verbose"); ts.Switch = sourceSwitch; ts.Listeners.Add(new ConsoleTraceListener()); Console.WriteLine(ts.Listeners.Count); ts.TraceInformation("hello"); var n = Network.Main; var loggerFactory = new LoggerFactory() .AddConsole(LogLevel.Debug, false); Logs.Configure(loggerFactory); var network = InitLLCoin(); if (NodeSettings.PrintHelp(args, network)) { return; } //var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); // NOTES: running BTC and STRAT side by side is not possible yet as the flags for serialization are static var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .AddPowPosMining() .Build(); Task.Delay(TimeSpan.FromMinutes(1)).ContinueWith(t => { //TryStartPowMiner(args, node); //TryStartPosMiner(args, node); }); node.Run(); }
public static async Task Main(string[] args) { IFullNodeBuilder fullNodeBuilder = null; // Get the API uri. var apiUri = args.GetValueOf("apiuri"); var isTestNet = args.Contains("-testnet"); var isStratis = args.Contains("stratis"); var agent = "Breeze"; NodeSettings nodeSettings; if (isStratis) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } var network = isTestNet ? Network.StratisTest : Network.StratisMain; if (isTestNet) { args = args.Append("-addnode=51.141.28.47").ToArray(); // TODO: fix this temp hack } nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION, agent); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri); } else { nodeSettings = NodeSettings.FromArguments(args, agent: agent); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri); } fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); IFullNode node = fullNodeBuilder.Build(); // Start Full Node - this will also start the API. await node.RunAsync(); }
public static void Main(string[] args) { Network network = args.Contains("-testnet") ? Network.StratisTest : Network.StratisMain; if (NodeSettings.PrintHelp(args, network)) { AzureIndexerSettings.PrintHelp(network); return; } NodeSettings nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); // NOTES: running BTC and STRAT side by side is not possible yet as the flags for serialization are static var node = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseAzureIndexer() .Build(); node.Run(); }
/// <inheritdoc /> public IFullNode Build() { if (this.fullNodeBuilt) { throw new InvalidOperationException("full node already built"); } this.fullNodeBuilt = true; this.Services = this.BuildServices(); // Print command-line help if (this.NodeSettings?.PrintHelpAndExit ?? false) { NodeSettings.PrintHelp(this.Network); foreach (IFeatureRegistration featureRegistration in this.Features.FeatureRegistrations) { MethodInfo printHelp = featureRegistration.FeatureType.GetMethod("PrintHelp", BindingFlags.Public | BindingFlags.Static); printHelp?.Invoke(null, new object[] { this.NodeSettings.Network }); } // Signal node not built return(null); } // Create configuration file if required this.NodeSettings?.CreateDefaultConfigurationFile(this.Features.FeatureRegistrations); ServiceProvider fullNodeServiceProvider = this.Services.BuildServiceProvider(); this.ConfigureServices(fullNodeServiceProvider); // Obtain the nodeSettings from the service (it's set used FullNodeBuilder.UseNodeSettings) var nodeSettings = fullNodeServiceProvider.GetService <NodeSettings>(); if (nodeSettings == null) { throw new NodeBuilderException("NodeSettings not specified"); } var network = fullNodeServiceProvider.GetService <Network>(); if (network == null) { throw new NodeBuilderException("Network not specified"); } var fullNode = fullNodeServiceProvider.GetService <FullNode>(); if (fullNode == null) { throw new InvalidOperationException("Fullnode not registered with provider"); } fullNode.Initialize(new FullNodeServiceProvider( fullNodeServiceProvider, this.Features.FeatureRegistrations.Select(s => s.FeatureType).ToList())); return(fullNode); }
public static void Main(string[] args) { IFullNodeBuilder fullNodeBuilder = null; // configure logging Logs.Configure(Logs.GetLoggerFactory(args)); // get the api uri var apiUri = args.GetValueOf("apiuri"); if (args.Contains("stratis")) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; if (args.Contains("-testnet")) { args = args.Append("-addnode=13.64.76.48").ToArray(); // TODO: fix this temp hack } var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .UseWallet() .AddPowPosMining() .UseApi(); } } else { NodeSettings nodeSettings = NodeSettings.FromArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseConsensus() .UseBlockStore() .UseMempool() .UseWallet() .UseApi(); } } // TODO: Add this when TB is enabled //// add the tumbler's settings //var tumblerAddress = args.SingleOrDefault(arg => arg.StartsWith("-tumbler-uri=")); //if (!string.IsNullOrEmpty(tumblerAddress)) //{ // tumblerAddress = tumblerAddress.Replace("-tumbler-uri=", string.Empty); // fullNodeBuilder.UseTumbleBit(new Uri(tumblerAddress)); // fullNodeBuilder.UseWatchOnlyWallet(); //} var node = fullNodeBuilder.Build(); //start Full Node - this will also start the API node.Run(); }
public static void Main(string[] args) { IFullNodeBuilder fullNodeBuilder = null; // configure logging Logs.Configure(Logs.GetLoggerFactory(args)); if (args.Contains("stratis")) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .UseWallet() .AddPowPosMining() .UseApi(); } } else { NodeSettings nodeSettings = NodeSettings.FromArguments(args); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseConsensus() .UseBlockStore() .UseMempool() .UseWallet() .UseApi(); } } // add the tumbler's settings var tumblerAddress = args.SingleOrDefault(arg => arg.StartsWith("-tumbler-uri=")); if (!string.IsNullOrEmpty(tumblerAddress)) { tumblerAddress = tumblerAddress.Replace("-tumbler-uri=", string.Empty); fullNodeBuilder.UseTumbleBit(new Uri(tumblerAddress)); } var node = fullNodeBuilder.Build(); //start Full Node - this will also start the API node.Run(); }
public static void Main(string[] args) { IFullNodeBuilder fullNodeBuilder = null; // get the api uri var apiUri = args.GetValueOf("apiuri"); if (args.Contains("stratis")) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; if (args.Contains("-testnet")) { args = args.Append("-addnode=13.64.76.48").ToArray(); // TODO: fix this temp hack } var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseStratisConsensus() .UseBlockStore() .UseMempool() .UseWallet() .AddPowPosMining() .UseApi(); } } else { NodeSettings nodeSettings = NodeSettings.FromArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri); if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseConsensus() .UseBlockStore() .UseMempool() .UseWallet() .UseApi(); } } var node = fullNodeBuilder.Build(); //start Full Node - this will also start the API node.Run(); }
/// <summary> /// Prints command-line help. /// </summary> /// <param name="network">The network to extract values from.</param> public static void PrintHelp(Network network) { NodeSettings.PrintHelp(network); }
public static async Task MainAsync(string[] args) { try { // Get the API uri. var apiUri = args.GetValueOf("apiuri"); var isTestNet = args.Contains("-testnet"); var isStratis = args.Contains("stratis"); var agent = "Breeze"; // This setting is not in NodeSettings yet, so get it directly from the args ConfigurationOptionWrapper <string> registrationStoreDirectory = new ConfigurationOptionWrapper <string>("RegistrationStoreDirectory", args.GetValueOf("-storedir")); NodeSettings nodeSettings; if (isStratis) { if (NodeSettings.PrintHelp(args, Network.StratisMain)) { return; } Network network = isTestNet ? Network.StratisTest : Network.StratisMain; if (isTestNet) { args = args.Append("-addnode=51.141.28.47").ToArray(); // TODO: fix this temp hack } nodeSettings = new NodeSettings("stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION, agent).LoadArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri); } else { nodeSettings = new NodeSettings(agent: agent).LoadArguments(args); nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri); } IFullNodeBuilder fullNodeBuilder = null; if (args.Contains("light")) { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseLightWallet() .UseWatchOnlyWallet() .UseBlockNotification() .UseTransactionNotification() .UseApi(); } else { fullNodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings); if (args.Contains("stratis")) { fullNodeBuilder.UseStratisConsensus(); } else { fullNodeBuilder.UseConsensus(); } fullNodeBuilder.UseBlockStore() .UseMempool() .UseBlockNotification() .UseTransactionNotification() .UseWallet() .UseWatchOnlyWallet() .AddMining() .AddRPC() .UseApi(); } if (args.Contains("registration")) { //fullNodeBuilder.UseInterNodeCommunication(); fullNodeBuilder.UseRegistration(); } // Need this to happen for both TB and non-TB daemon Logs.Configure(new FuncLoggerFactory(i => new DualLogger(i, (a, b) => true, false))); // Start NTumbleBit logging to the console SetupTumbleBitConsoleLogs(nodeSettings); // Add logging to NLog //SetupTumbleBitNLogs(nodeSettings); // Currently TumbleBit is bitcoin only if (args.Contains("-tumblebit")) { // We no longer pass the URI in via the command line, the registration feature selects a random one fullNodeBuilder.UseTumbleBit(registrationStoreDirectory); } IFullNode node = fullNodeBuilder.Build(); // Start Full Node - this will also start the API. await node.RunAsync(); } catch (Exception ex) { Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.Message); } }