コード例 #1
0
        public async Task StartAsync()
        {
            NodeConfigParameters 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", ports[0].ToString());
            config.Add("rpcport", ports[1].ToString());
            config.Add("printtoconsole", "1");
            config.Add("keypool", "10");
            config.Add("whitebind", "127.0.0.1:" + ports[0].ToString());
            config.Import(ConfigParameters);
            File.WriteAllText(_Config, config.ToString());
            await Run();
        }
コード例 #2
0
        public async Task StartAsync()
        {
            NodeConfigParameters config    = new NodeConfigParameters();
            StringBuilder        configStr = new StringBuilder();

            configStr.AppendLine("regtest=1");
            if (NodeImplementation.UseSectionInConfigFile)
            {
                configStr.AppendLine("[regtest]");
            }
            config.Add("rest", "1");
            config.Add("server", "1");
            config.Add("txindex", "1");
            if (!CookieAuth)
            {
                config.Add("rpcuser", creds.UserName);
                config.Add("rpcpassword", creds.Password);
            }
            if (!WhiteBind)
            {
                config.Add("port", ports[0].ToString());
            }
            else
            {
                config.Add("whitebind", "127.0.0.1:" + ports[0].ToString());
            }
            config.Add("rpcport", ports[1].ToString());
            config.Add("printtoconsole", "1");
            config.Add("keypool", "10");
            config.Import(ConfigParameters, true);
            configStr.AppendLine(config.ToString());
            if (NodeImplementation.AdditionalRegtestConfig != null)
            {
                configStr.AppendLine(NodeImplementation.AdditionalRegtestConfig);
            }
            File.WriteAllText(_Config, configStr.ToString());
            await Run();
        }
コード例 #3
0
        public async Task StartAsync()
        {
            NodeConfigParameters config = new NodeConfigParameters();

            config.Add("regtest", "1");
            config.Add("rest", "1");
            config.Add("server", "1");
            config.Add("txindex", "1");
            config.Add("rpcuser", creds.UserName);
            config.Add("rpcpassword", creds.Password);
            config.Add("port", ports[0].ToString());
            config.Add("rpcport", ports[1].ToString());
            config.Add("printtoconsole", "1");
            config.Add("keypool", "10");
            config.Add("whitebind", "127.0.0.1:" + ports[0].ToString());
            config.Import(ConfigParameters);
            File.WriteAllText(_Config, config.ToString());
            lock (l)
            {
                _Process = Process.Start(new FileInfo(this._Builder.BitcoinD).FullName, "-conf=bitcoin.conf" + " -datadir=" + dataDir + " -debug=net");
                _State   = CoreNodeState.Starting;
            }
            while (true)
            {
                try
                {
                    await CreateRPCClient().GetBlockHashAsync(0).ConfigureAwait(false);

                    _State = CoreNodeState.Running;
                    break;
                }
                catch { }
                if (_Process == null || _Process.HasExited)
                {
                    break;
                }
            }
        }
コード例 #4
0
ファイル: NodeBuilder.cs プロジェクト: xmess7/NBitcoin
        public async Task StartAsync()
        {
            NodeConfigParameters config    = new NodeConfigParameters();
            StringBuilder        configStr = new StringBuilder();

            if (String.IsNullOrEmpty(NodeImplementation.Chain))
            {
                configStr.AppendLine("regtest=1");
            }
            else
            {
                configStr.AppendLine($"chain={NodeImplementation.Chain}");
            }
            if (NodeImplementation.UseSectionInConfigFile)
            {
                if (String.IsNullOrEmpty(NodeImplementation.Chain))
                {
                    configStr.AppendLine("[regtest]");
                }
                else
                {
                    configStr.AppendLine($"[{NodeImplementation.Chain}]");
                }
            }
            if (NodeImplementation.CreateWallet)
            {
                config.Add("wallet", "wallet.dat");
            }

            config.Add("rest", "1");
            config.Add("server", "1");
            config.Add("txindex", "1");
            config.Add("peerbloomfilters", "1");
            // Somehow got problems on windows with it time to time...
            //config.Add("blockfilterindex", "1");
            if (!CookieAuth)
            {
                config.Add("rpcuser", creds.UserName);
                config.Add("rpcpassword", creds.Password);
            }
            if (!WhiteBind)
            {
                config.Add("port", ports[0].ToString());
            }
            else
            {
                config.Add("whitebind", "127.0.0.1:" + ports[0].ToString());
            }
            config.Add("rpcport", ports[1].ToString());
            config.Add("printtoconsole", _Builder.ShowNodeConsole ? "1" : "0");
            config.Add("keypool", "10");
            config.Add("fallbackfee", "0.0002");             // https://github.com/bitcoin/bitcoin/pull/16524
            config.Import(ConfigParameters, true);
            configStr.AppendLine(config.ToString());
            if (NodeImplementation.AdditionalRegtestConfig != null)
            {
                configStr.AppendLine(NodeImplementation.AdditionalRegtestConfig);
            }
            File.WriteAllText(_Config, configStr.ToString());

            await Run();
        }