Commit d977f393 authored by khvostenko's avatar khvostenko

DeStream.DeStreamD and DeStream.BreezeD added for DeStream

parent 984c1469
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>DeStream.BreezeD</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>DeStream.BreezeD</PackageId>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.LightWallet\Stratis.Bitcoin.Features.LightWallet.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Notifications\Stratis.Bitcoin.Features.Notifications.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup>
<PropertyGroup>
<RuntimeIdentifiers>win7-x86;win7-x64;win10-x86;win10-x64;osx.10.12-x64;ubuntu.14.04-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
cd ..
start cmd /k dotnet run
timeout 21
start cmd /k dotnet run stratis
\ No newline at end of file
cd ..
start cmd /k dotnet run -testnet -debug=all -loglevel=debug
timeout 21
start cmd /k dotnet run stratis -testnet -debug=all -loglevel=debug
\ No newline at end of file
using System;
using System.Linq;
using System.Threading.Tasks;
using NBitcoin;
using NBitcoin.Protocol;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Configuration;
using Stratis.Bitcoin.Features.Api;
using Stratis.Bitcoin.Features.LightWallet;
using Stratis.Bitcoin.Features.Notifications;
using Stratis.Bitcoin.Utilities;
namespace Stratis.BreezeD
{
public class Program
{
public static void Main(string[] args)
{
MainAsync(args).Wait();
}
public static async Task MainAsync(string[] args)
{
try
{
// Get the API uri.
var isTestNet = args.Contains("-testnet");
var isDeStream= args.Contains("destream");
var agent = "Breeze";
NodeSettings nodeSettings;
if (isDeStream)
{
Network network = isTestNet ? Network.DeStreamTest : Network.DeStreamMain;
nodeSettings = new NodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, agent, args:args, loadConfiguration:false);
}
else
{
nodeSettings = new NodeSettings(agent: agent, args: args, loadConfiguration:false);
}
IFullNodeBuilder fullNodeBuilder = new FullNodeBuilder()
.UseNodeSettings(nodeSettings)
.UseLightWallet()
.UseBlockNotification()
.UseTransactionNotification()
.UseApi();
IFullNode node = fullNodeBuilder.Build();
// Start Full Node - this will also start the API.
if (node != null)
await node.RunAsync();
}
catch (Exception ex)
{
Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.Message);
}
}
}
}
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Stratis.BreezeD")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1b598e33-667f-496d-bc0d-88276e8e7632")]
{
"profiles": {
"Bitcoin Main": {
"commandName": "Project",
"commandLineArgs": "-testnet"
},
"Bitcoin Test": {
"commandName": "Project",
"commandLineArgs": "-testnet -debug=all -loglevel=debug"
},
"Stratis Main": {
"commandName": "Project",
"commandLineArgs": "stratis "
},
"Stratis Test": {
"commandName": "Project",
"commandLineArgs": "stratis -testnet -debug=all -loglevel=debug"
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>DeStream.DeStreamD</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>DeStream.DeStreamD</PackageId>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.BlockStore\Stratis.Bitcoin.Features.BlockStore.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Consensus\Stratis.Bitcoin.Features.Consensus.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.MemoryPool\Stratis.Bitcoin.Features.MemoryPool.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Miner\Stratis.Bitcoin.Features.Miner.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.RPC\Stratis.Bitcoin.Features.RPC.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="NLog" Version="5.0.0-beta09" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-beta5" />
</ItemGroup>
</Project>
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using NBitcoin;
using NBitcoin.Protocol;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Configuration;
using Stratis.Bitcoin.Features.Api;
using Stratis.Bitcoin.Features.BlockStore;
using Stratis.Bitcoin.Features.Consensus;
using Stratis.Bitcoin.Features.MemoryPool;
using Stratis.Bitcoin.Features.Miner;
using Stratis.Bitcoin.Features.RPC;
using Stratis.Bitcoin.Features.Wallet;
using Stratis.Bitcoin.Utilities;
namespace Stratis.StratisD
{
public class Program
{
public static void Main(string[] args)
{
MainAsync(args).Wait();
}
public static async Task MainAsync(string[] args)
{
try
{
Network network = null;
if (args.Contains("-testnet"))
network = Network.DeStreamTest;
else
network = Network.DeStreamMain;
NodeSettings nodeSettings = new NodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, args:args, loadConfiguration:false);
Console.WriteLine($"current network: {network.Name}");
// 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)
.UsePosConsensus()
.UseBlockStore()
.UseMempool()
.UseWallet()
.AddPowPosMining()
.UseApi()
.AddRPC()
.Build();
if (node != null)
await node.RunAsync();
}
catch (Exception ex)
{
Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.Message);
}
}
}
}
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Stratis.StratisD")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("34c17104-704e-4790-b398-d1f73cbee31e")]
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishDir>bin\Release\PublishOutput</PublishDir>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"profiles": {
"Stratis.StratisD": {
"commandName": "Project",
"commandLineArgs": "-testnet"
},
"Stratis.StratisD Test": {
"commandName": "Project",
"commandLineArgs": "-testnet"
},
"Stratis.StratisD Test with RPC": {
"commandName": "Project",
"commandLineArgs": "-testnet -server -rpcpassword=password -rpcuser=user"
},
"Stratis.StratisD Test Keepalive 60s": {
"commandName": "Project",
"commandLineArgs": "-testnet -keepalive=60"
}
}
}
\ No newline at end of file
......@@ -89,6 +89,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.StratisDnsD", "Stra
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stratis", "Stratis", "{A0CEDD86-D446-436E-8C35-261B30CEE5D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeStream.DeStreamD", "DeStream.DeStreamD\DeStream.DeStreamD.csproj", "{DFFB8C9F-4186-417F-A843-A5E1E6125164}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeStream.BreezeD", "DeStream.BreezeD\DeStream.BreezeD.csproj", "{5303E8B0-C422-4D1C-8096-24DF6AF75E31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -223,6 +227,14 @@ Global
{978482B2-AE17-421E-AD6F-ED9667C6B8A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{978482B2-AE17-421E-AD6F-ED9667C6B8A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{978482B2-AE17-421E-AD6F-ED9667C6B8A1}.Release|Any CPU.Build.0 = Release|Any CPU
{DFFB8C9F-4186-417F-A843-A5E1E6125164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFFB8C9F-4186-417F-A843-A5E1E6125164}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DFFB8C9F-4186-417F-A843-A5E1E6125164}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DFFB8C9F-4186-417F-A843-A5E1E6125164}.Release|Any CPU.Build.0 = Release|Any CPU
{5303E8B0-C422-4D1C-8096-24DF6AF75E31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5303E8B0-C422-4D1C-8096-24DF6AF75E31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5303E8B0-C422-4D1C-8096-24DF6AF75E31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5303E8B0-C422-4D1C-8096-24DF6AF75E31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -62,8 +62,21 @@ namespace NBitcoin
public static Network StratisRegTest => Network.GetNetwork("StratisRegTest") ?? InitStratisRegTest();
public static Network DestreamTest => Network.GetNetwork("DestreamTest") ?? InitDestreamTest();
public static Network DestreamTestServer => Network.GetNetwork("DestreamTest") ?? InitDestreamTestServerNetwork();
#region DeStream
/// <summary> The name of the root folder containing the different Stratis blockchains (StratisMain, StratisTest, StratisRegTest). </summary>
public const string DeStreamRootFolderName = "destream";
/// <summary> The default name used for the Stratis configuration file. </summary>
public const string DeStreamDefaultConfigFilename = "destream.conf";
public static Network DeStreamMain => Network.GetNetwork("StratisMain") ?? InitDeStreamMain();
public static Network DeStreamTest => Network.GetNetwork("DeStreamTest") ?? InitDeStreamTest();
public static Network DeStreamRegTest => Network.GetNetwork("StratisRegTest") ?? InitDeStreamRegTest();
#endregion
private static Network InitMain()
{
......@@ -488,34 +501,176 @@ namespace NBitcoin
return builder.BuildAndRegister();
}
private static Network InitDestreamTest()
{
var builder = Network.GetDestreamTestNetworkBuilderWithCommonData();
builder.AddDNSSeeds(new[]
private static Network InitStratisRegTest()
{
new DNSSeedData("peak-srv-12.qb-systems.ru", "peak-srv-12.qb-systems.ru"),
new DNSSeedData("peak-srv-16.qb-systems.ru", "peak-srv-16.qb-systems.ru"),
new DNSSeedData("peak-srv-17.qb-systems.ru", "peak-srv-17.qb-systems.ru")
});
// TODO: move this to Networks
var net = Network.GetNetwork("StratisRegTest");
if (net != null)
return net;
builder.AddSeeds(new[]
{
new NetworkAddress(IPAddress.Parse("95.128.181.196"), builder.Port),
new NetworkAddress(IPAddress.Parse("95.128.181.103"), builder.Port),//16
new NetworkAddress(IPAddress.Parse("95.128.181.80"), builder.Port)//17
});
Block.BlockSignature = true;
Transaction.TimeStamp = true;
var consensus = Network.StratisTest.Consensus.Clone();
consensus.PowLimit = new Target(uint256.Parse("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
consensus.PowAllowMinDifficultyBlocks = true;
consensus.PowNoRetargeting = true;
var messageStart = new byte[4];
messageStart[0] = 0xcd;
messageStart[1] = 0xf2;
messageStart[2] = 0xc0;
messageStart[3] = 0xef;
var magic = BitConverter.ToUInt32(messageStart, 0);
var genesis = Network.StratisMain.GetGenesis();
genesis.Header.Time = 1494909211;
genesis.Header.Nonce = 2433759;
genesis.Header.Bits = consensus.PowLimit;
consensus.HashGenesisBlock = genesis.GetHash(consensus.NetworkOptions);
Assert(consensus.HashGenesisBlock == uint256.Parse("0x93925104d664314f581bc7ecb7b4bad07bcfabd1cfce4256dbd2faddcf53bd1f"));
consensus.DefaultAssumeValid = null; // turn off assumevalid for regtest.
var builder = new NetworkBuilder()
.SetName("StratisRegTest")
.SetRootFolderName(StratisRootFolderName)
.SetDefaultConfigFilename(StratisDefaultConfigFilename)
.SetConsensus(consensus)
.SetMagic(magic)
.SetGenesis(genesis)
.SetPort(18444)
.SetRPCPort(18442)
.SetMaxTimeOffsetSeconds(StratisMaxTimeOffsetSeconds)
.SetMaxTipAge(StratisDefaultMaxTipAgeInSeconds)
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (65) })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { (196) })
.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { (65 + 128) })
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_NO_EC, new byte[] { 0x01, 0x42 })
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_EC, new byte[] { 0x01, 0x43 })
.SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { (0x04), (0x88), (0xB2), (0x1E) })
.SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { (0x04), (0x88), (0xAD), (0xE4) });
return builder.BuildAndRegister();
}
private static Network InitDestreamTestServerNetwork()
#region DeStream
private static Network InitDeStreamMain()
{
var builder = Network.GetDestreamTestNetworkBuilderWithCommonData();
Block.BlockSignature = true;
Transaction.TimeStamp = true;
var consensus = new Consensus();
consensus.NetworkOptions = new NetworkOptions() { IsProofOfStake = true };
consensus.GetPoWHash = (n, h) => Crypto.HashX13.Instance.Hash(h.ToBytes(options: n));
consensus.SubsidyHalvingInterval = 210000;
consensus.MajorityEnforceBlockUpgrade = 750;
consensus.MajorityRejectBlockOutdated = 950;
consensus.MajorityWindow = 1000;
consensus.BuriedDeployments[BuriedDeployments.BIP34] = 227931;
consensus.BuriedDeployments[BuriedDeployments.BIP65] = 388381;
consensus.BuriedDeployments[BuriedDeployments.BIP66] = 363725;
consensus.BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
consensus.PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
consensus.PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60); // two weeks
consensus.PowTargetSpacing = TimeSpan.FromSeconds(10 * 60);
consensus.PowAllowMinDifficultyBlocks = false;
consensus.PowNoRetargeting = false;
consensus.RuleChangeActivationThreshold = 1916; // 95% of 2016
consensus.MinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
consensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 1199145601, 1230767999);
consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1462060800, 1493596800);
consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 0, 0);
consensus.LastPOWBlock = 12500;
consensus.ProofOfStakeLimit = new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false));
consensus.ProofOfStakeLimitV2 = new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false));
consensus.CoinType = 105;
consensus.DefaultAssumeValid = new uint256("0x8c2cf95f9ca72e13c8c4cdf15c2d7cc49993946fb49be4be147e106d502f1869"); // 642930
Block genesis = CreateStratisGenesisBlock(1470467000, 1831645, 0x1e0fffff, 1, Money.Zero);
consensus.HashGenesisBlock = genesis.GetHash(consensus.NetworkOptions);
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
var messageStart = new byte[4];
messageStart[0] = 0x70;
messageStart[1] = 0x35;
messageStart[2] = 0x22;
messageStart[3] = 0x05;
var magic = BitConverter.ToUInt32(messageStart, 0); //0x5223570;
Assert(consensus.HashGenesisBlock == uint256.Parse("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"));
Assert(genesis.Header.HashMerkleRoot == uint256.Parse("0x65a26bc20b0351aebf05829daefa8f7db2f800623439f3c114257c91447f1518"));
var builder = new NetworkBuilder()
.SetName("DeStreamMain")
.SetRootFolderName(DeStreamRootFolderName)
.SetDefaultConfigFilename(DeStreamDefaultConfigFilename)
.SetConsensus(consensus)
.SetMagic(magic)
.SetGenesis(genesis)
.SetPort(16178)
.SetRPCPort(16174)
.SetTxFees(10000, 60000, 10000)
.SetMaxTimeOffsetSeconds(StratisMaxTimeOffsetSeconds)
.SetMaxTipAge(StratisDefaultMaxTipAgeInSeconds)
.AddDNSSeeds(new[]
{
new DNSSeedData("seednode1.stratisplatform.com", "seednode1.stratisplatform.com"),
new DNSSeedData("seednode2.stratis.cloud", "seednode2.stratis.cloud"),
new DNSSeedData("seednode3.stratisplatform.com", "seednode3.stratisplatform.com"),
new DNSSeedData("seednode4.stratis.cloud", "seednode4.stratis.cloud")
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (63) })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { (125) })
.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { (63 + 128) })
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_NO_EC, new byte[] { 0x01, 0x42 })
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_EC, new byte[] { 0x01, 0x43 })
.SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { (0x04), (0x88), (0xB2), (0x1E) })
.SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { (0x04), (0x88), (0xAD), (0xE4) })
.SetBase58Bytes(Base58Type.PASSPHRASE_CODE, new byte[] { 0x2C, 0xE9, 0xB3, 0xE1, 0xFF, 0x39, 0xE2 })
.SetBase58Bytes(Base58Type.CONFIRMATION_CODE, new byte[] { 0x64, 0x3B, 0xF6, 0xA8, 0x9A })
.SetBase58Bytes(Base58Type.STEALTH_ADDRESS, new byte[] { 0x2a })
.SetBase58Bytes(Base58Type.ASSET_ID, new byte[] { 23 })
.SetBase58Bytes(Base58Type.COLORED_ADDRESS, new byte[] { 0x13 })
.SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, "bc")
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, "bc");
var seed = new[] { "101.200.198.155", "103.24.76.21", "104.172.24.79" };
var fixedSeeds = new List<NetworkAddress>();
// Convert the pnSeeds array into usable address objects.
Random rand = new Random();
TimeSpan oneWeek = TimeSpan.FromDays(7);
for (int i = 0; i < seed.Length; i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
NetworkAddress addr = new NetworkAddress();
// Seed nodes are given a random 'last seen time' of between one and two
// weeks ago.
addr.Time = DateTime.UtcNow - (TimeSpan.FromSeconds(rand.NextDouble() * oneWeek.TotalSeconds)) - oneWeek;
addr.Endpoint = Utils.ParseIpEndpoint(seed[i], builder.Port);
fixedSeeds.Add(addr);
}
builder.AddSeeds(fixedSeeds);
return builder.BuildAndRegister();
}
private static NetworkBuilder GetDestreamTestNetworkBuilderWithCommonData()
private static Network InitDeStreamTest()
{
Block.BlockSignature = true;
Transaction.TimeStamp = true;
......@@ -544,9 +699,9 @@ namespace NBitcoin
consensus.DefaultAssumeValid = new uint256("0x12ae16993ce7f0836678f225b2f4b38154fa923bd1888f7490051ddaf4e9b7fa"); // 218810
var builder = new NetworkBuilder()
.SetName("DestreamTest")
.SetRootFolderName(StratisRootFolderName)
.SetDefaultConfigFilename(StratisDefaultConfigFilename)
.SetName("DeStreamTest")
.SetRootFolderName(DeStreamRootFolderName)
.SetDefaultConfigFilename(DeStreamDefaultConfigFilename)
.SetConsensus(consensus)
.SetMagic(magic)
.SetGenesis(genesis)
......@@ -561,15 +716,29 @@ namespace NBitcoin
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_NO_EC, new byte[] { 0x01, 0x42 })
.SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_EC, new byte[] { 0x01, 0x43 })
.SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { (0x04), (0x88), (0xB2), (0x1E) })
.SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { (0x04), (0x88), (0xAD), (0xE4) });
return builder;
}
.SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { (0x04), (0x88), (0xAD), (0xE4) })
.AddDNSSeeds(new[]
{
new DNSSeedData("peak-srv-12.qb-systems.ru", "peak-srv-12.qb-systems.ru"),
new DNSSeedData("peak-srv-16.qb-systems.ru", "peak-srv-16.qb-systems.ru"),
new DNSSeedData("peak-srv-17.qb-systems.ru", "peak-srv-17.qb-systems.ru")
});
private static Network InitStratisRegTest()
builder.AddSeeds(new[]
{
new NetworkAddress(IPAddress.Parse("95.128.181.196"), builder.Port), //peak-srv-12
new NetworkAddress(IPAddress.Parse("95.128.181.103"), builder.Port), //peak-srv-16
new NetworkAddress(IPAddress.Parse("95.128.181.80"), builder.Port) //peak-srv-17
});
return builder.BuildAndRegister();
}
private static Network InitDeStreamRegTest()
{
// TODO: move this to Networks
var net = Network.GetNetwork("StratisRegTest");
var net = Network.GetNetwork("DeStreamRegTest");
if (net != null)
return net;
......@@ -600,9 +769,9 @@ namespace NBitcoin
consensus.DefaultAssumeValid = null; // turn off assumevalid for regtest.
var builder = new NetworkBuilder()
.SetName("StratisRegTest")
.SetRootFolderName(StratisRootFolderName)
.SetDefaultConfigFilename(StratisDefaultConfigFilename)
.SetName("DeStreamRegTest")
.SetRootFolderName(DeStreamRootFolderName)
.SetDefaultConfigFilename(DeStreamDefaultConfigFilename)
.SetConsensus(consensus)
.SetMagic(magic)
.SetGenesis(genesis)
......@@ -621,6 +790,8 @@ namespace NBitcoin
return builder.BuildAndRegister();
}
#endregion
private static Block CreateGenesisBlock(uint nTime, uint nNonce, uint nBits, int nVersion, Money genesisReward)
{
string pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
......
......@@ -95,6 +95,11 @@ namespace Stratis.Bitcoin.Cli
defaultRestApiPort = 37221;
network = Network.StratisMain;
}
else if (networkName.Contains("destream"))
{
defaultRestApiPort = 37221;
network = Network.StratisMain;
}
else
{
defaultRestApiPort = 37220;
......
using NBitcoin;
using System.Linq;
namespace Stratis.Bitcoin.Utilities
{
......@@ -20,6 +21,26 @@ namespace Stratis.Bitcoin.Utilities
return network.Name.ToLowerInvariant().Contains("test");
}
/// <summary>
/// Determines whether this network is a Stratis-network.
/// </summary>
/// <param name="network">The network.</param>
/// <returns><c>true</c> if the specified network is Stratis, <c>false</c> otherwise.</returns>
public static bool IsStratis(this Network network)
{
return network.Name.ToLowerInvariant().Contains("stratis");
}
/// <summary>
/// Determines whether this network is a DeStream-network.
/// </summary>
/// <param name="network">The network.</param>
/// <returns><c>true</c> if the specified network is DeStream, <c>false</c> otherwise.</returns>
public static bool IsDeStream(this Network network)
{
return network.Name.ToLowerInvariant().Contains("destream");
}
/// <summary>
/// Determines whether this network is a bitcoin network.
/// </summary>
......@@ -27,7 +48,9 @@ namespace Stratis.Bitcoin.Utilities
/// <returns><c>true</c> if the specified network is bitcoin, <c>false</c> otherwise.</returns>
public static bool IsBitcoin(this Network network)
{
return !network.Name.ToLowerInvariant().Contains("stratis");
//return !(new string[] { "stratis", "destream" }.Any(s => network.Name.ToLowerInvariant().Contains(s)));
return !IsStratis(network) && !IsDeStream(network);
}
}
}
......@@ -27,18 +27,12 @@ namespace Stratis.BreezeD
// Get the API uri.
var isTestNet = args.Contains("-testnet");
var isStratis = args.Contains("stratis");
var isDestreamTest = args.Contains("-destreamtest");
var agent = "Breeze";
NodeSettings nodeSettings;
if(isDestreamTest)
{
Network network = Network.DestreamTest;
nodeSettings = new NodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, agent, args: args, loadConfiguration: false);
}
else if (isStratis)
if (isStratis)
{
Network network = isTestNet ? Network.StratisTest : Network.StratisMain;
if (isTestNet)
......
{
"profiles": {
"Bitcoin Main": {
"commandName": "Project",
"commandLineArgs": "-destreamtest"
"commandName": "Project"
},
"Bitcoin Test": {
"commandName": "Project",
......
......@@ -31,10 +31,6 @@ namespace Stratis.StratisD
Network network = null;
if (args.Contains("-testnet"))
network = Network.StratisTest;
else if (args.Contains("-destreamtest"))
network = Network.DestreamTest;
else if (args.Contains("-destreamtestserver"))
network = Network.DestreamTestServer;
else
network = Network.StratisMain;
NodeSettings nodeSettings = new NodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, args:args, loadConfiguration:false);
......
{
"profiles": {
"Stratis.StratisD": {
"commandName": "Project",
"commandLineArgs": "-destreamtest"
"commandName": "Project"
},
"Stratis.StratisD Test": {
"commandName": "Project",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment