public static NodeBuilder Create([CallerMemberNameAttribute] string caller = null, string version = "0.13.1")
        {
            version = version ?? "0.13.1";
            var bitcoinDownload = new NodeDownloadData()
            {
                Version = version,
                Linux   = new NodeOSDownloadData()
                {
                    Archive      = "bitcoin-{0}-x86_64-linux-gnu.tar.gz",
                    DownloadLink = "https://bitcoin.org/bin/bitcoin-core-{0}/bitcoin-{0}-x86_64-linux-gnu.tar.gz",
                    Executable   = "bitcoin-{0}/bin/bitcoind"
                },
                Mac = new NodeOSDownloadData()
                {
                    Archive      = "bitcoin-{0}-osx64.tar.gz",
                    DownloadLink = "https://bitcoin.org/bin/bitcoin-core-{0}/bitcoin-{0}-osx64.tar.gz",
                    Executable   = "bitcoin-{0}/bin/bitcoind"
                },
                Windows = new NodeOSDownloadData()
                {
                    Executable   = "bitcoin-{0}/bin/bitcoind.exe",
                    DownloadLink = "https://bitcoin.org/bin/bitcoin-core-{0}/bitcoin-{0}-win32.zip",
                    Archive      = "bitcoin-{0}-win32.zip"
                }
            };

            return(Create(bitcoinDownload, caller));
        }
示例#2
0
        public static NodeBuilder Create(NodeDownloadData nodeDownloadData, [CallerMemberName] string caller = null)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            var builder = NodeBuilder.Create(NodeDownloadData.MonetaryUnit.v2_1_6, Altcoins.MonetaryUnit.Instance.Regtest, caller);

            return(builder);
        }
示例#3
0
        public static NodeBuilder Create(NodeDownloadData nodeDownloadData, [CallerMemberName] string caller = null)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            var builder = NodeBuilder.Create(nodeDownloadData, Altcoins.AltNetworkSets.Bitcoin.Regtest, caller);

            return(builder);
        }
        public static NodeBuilder Create(NodeDownloadData downloadData, [CallerMemberNameAttribute] string caller = null)
        {
            var isFilePath = downloadData.Version.Length >= 2 && downloadData.Version[1] == ':';
            var path       = isFilePath ? downloadData.Version : EnsureDownloaded(downloadData);

            if (!Directory.Exists(caller))
            {
                Directory.CreateDirectory(caller);
            }
            return(new NodeBuilder(caller, path));
        }
示例#5
0
        public static string EnsureDownloaded(NodeDownloadData downloadData)
        {
            if (!Directory.Exists("TestData"))
            {
                Directory.CreateDirectory("TestData");
            }

            var osDownloadData = downloadData.GetCurrentOSDownloadData();

            if (osDownloadData == null)
            {
                throw new Exception("This platform does not support tests involving this crypto currency, DownloadData for this OS are unavailable");
            }
            var bitcoind = Path.Combine("TestData", String.Format(osDownloadData.Executable, downloadData.Version));
            var zip      = Path.Combine("TestData", String.Format(osDownloadData.Archive, downloadData.Version));

            if (File.Exists(bitcoind))
            {
                return(bitcoind);
            }

            string     url    = String.Format(osDownloadData.DownloadLink, downloadData.Version);
            HttpClient client = new HttpClient();

            client.Timeout = TimeSpan.FromMinutes(10.0);
            var data = client.GetByteArrayAsync(url).GetAwaiter().GetResult();

            CheckHash(osDownloadData, data);
            File.WriteAllBytes(zip, data);

            var extractDirectory = "TestData";

            if (osDownloadData.CreateFolder != null)
            {
                if (!Directory.Exists(osDownloadData.CreateFolder))
                {
                    Directory.CreateDirectory(osDownloadData.CreateFolder);
                }
                extractDirectory = Path.Combine(extractDirectory, string.Format(osDownloadData.CreateFolder, downloadData.Version));
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                ZipFile.ExtractToDirectory(zip, extractDirectory);
            }
            else
            {
                Process.Start("tar", "-zxvf " + zip + " -C " + extractDirectory).WaitForExit();
            }
            File.Delete(zip);
            return(bitcoind);
        }
示例#6
0
        private static string EnsureDownloaded(NodeDownloadData downloadData)
        {
            if (!Directory.Exists("TestData"))
            {
                Directory.CreateDirectory("TestData");
            }

            string zip;
            string bitcoind;

            var osDownloadData = downloadData.GetCurrentOSDownloadData();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                bitcoind = "TestData/" + String.Format(osDownloadData.Executable, downloadData.Version);
                if (File.Exists(bitcoind))
                {
                    return(bitcoind);
                }
                zip = "TestData/" + String.Format(osDownloadData.Archive, downloadData.Version);
                string     url    = String.Format(osDownloadData.DownloadLink, downloadData.Version);
                HttpClient client = new HttpClient();
                client.Timeout = TimeSpan.FromMinutes(10.0);
                var data = client.GetByteArrayAsync(url).GetAwaiter().GetResult();
                CheckHash(osDownloadData, data);
                File.WriteAllBytes(zip, data);
                ZipFile.ExtractToDirectory(zip, new FileInfo(zip).Directory.FullName);
            }
            else
            {
                bitcoind = "TestData/" + String.Format(osDownloadData.Executable, downloadData.Version);
                if (File.Exists(bitcoind))
                {
                    return(bitcoind);
                }

                zip = "TestData/" + String.Format(osDownloadData.Archive, downloadData.Version);

                string     url    = String.Format(osDownloadData.DownloadLink, downloadData.Version);
                HttpClient client = new HttpClient();
                client.Timeout = TimeSpan.FromMinutes(10.0);
                var data = client.GetByteArrayAsync(url).GetAwaiter().GetResult();
                CheckHash(osDownloadData, data);
                File.WriteAllBytes(zip, data);
                Process.Start("tar", "-zxvf " + zip + " -C TestData").WaitForExit();
            }
            File.Delete(zip);
            return(bitcoind);
        }
示例#7
0
        public static NodeBuilder Create(NodeDownloadData downloadData, Network network = null, [CallerMemberNameAttribute] string caller = null)
        {
            network = network ?? Network.RegTest;
            var isFilePath = downloadData.Version.Length >= 2 && downloadData.Version[1] == ':';
            var path       = isFilePath ? downloadData.Version : EnsureDownloaded(downloadData);

            if (!Directory.Exists(caller))
            {
                Directory.CreateDirectory(caller);
            }
            return(new NodeBuilder(caller, path)
            {
                Network = network, NodeImplementation = downloadData
            });
        }