Beispiel #1
0
        private bool getRpc()
        {
            if (rpc != null)
            {
                return(true);
            }

            string rpchost = "127.0.0.1";
            string rpcport = "8332";
            string rpcuser = null;
            string rpcpass = null;

            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\bitcoin\bitcoin.conf"))
            {
                string[] confLines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\bitcoin\bitcoin.conf");
                foreach (string confLine in confLines)
                {
                    if (confLine.Contains("rpcport="))
                    {
                        rpcport = confLine.Replace("rpcport=", "").Trim();
                    }
                    if (confLine.Contains("rpcuser="******"rpcuser="******"").Trim();
                    }
                    if (confLine.Contains("rpcpassword="******"rpcpassword="******"").Trim();
                    }
                }
            }

            if (string.IsNullOrEmpty(rpcuser) || string.IsNullOrEmpty(rpcpass))
            {
                BitcoindDialog dialog = new BitcoindDialog();
                DialogResult   dres   = dialog.ShowDialog();
                if (dres == DialogResult.Cancel)
                {
                    return(false);
                }
                rpchost = dialog.txtHost.Text;
                rpcport = dialog.txtPort.Text;
                rpcuser = dialog.txtUser.Text;
                rpcpass = dialog.txtPass.Text;
            }

            rpc = new BitcoinRPC(rpchost, rpcport, rpcuser, rpcpass);
            return(true);
        }
        public async Task WaitRouteTo(ActorTester destination)
        {
            var info = await destination.RPC.GetInfoAsync();

            int blockToMine = 6;

            while (true)
            {
                var route = await RPC.GetRouteAsync(info.Id, LightMoney.Satoshis(100), 0.0);

                if (route != null)
                {
                    break;
                }
                await Task.Delay(1000);

                BitcoinRPC.Generate(blockToMine);
                blockToMine = 1;
            }
            Console.WriteLine($"// Route from {this.P2PHost} to {destination.P2PHost} can now be used");
        }