Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding HomeCoin Network #289

Merged
merged 2 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Blockcore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockcore.Networks.X1", "Ne
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockcore.Networks.XRC", "Networks\Blockcore.Networks.XRC\Blockcore.Networks.XRC.csproj", "{4615D1C6-14CD-47CA-8B78-A462A37057F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockcore.Networks.HomeCoin", "Networks\Blockcore.Networks.HomeCoin\Blockcore.Networks.HomeCoin.csproj", "{074057D3-A1BE-409D-B4B4-F01CFA434D58}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -363,6 +365,10 @@ Global
{4615D1C6-14CD-47CA-8B78-A462A37057F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4615D1C6-14CD-47CA-8B78-A462A37057F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4615D1C6-14CD-47CA-8B78-A462A37057F6}.Release|Any CPU.Build.0 = Release|Any CPU
{074057D3-A1BE-409D-B4B4-F01CFA434D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{074057D3-A1BE-409D-B4B4-F01CFA434D58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{074057D3-A1BE-409D-B4B4-F01CFA434D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{074057D3-A1BE-409D-B4B4-F01CFA434D58}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -425,6 +431,7 @@ Global
{120500DF-C04F-43CC-9A1E-523A6429301F} = {3B56C02B-4468-4268-B797-851562789FCC}
{9A2BA15A-C316-42B4-8E4D-E01B4873190C} = {3B56C02B-4468-4268-B797-851562789FCC}
{4615D1C6-14CD-47CA-8B78-A462A37057F6} = {3B56C02B-4468-4268-B797-851562789FCC}
{074057D3-A1BE-409D-B4B4-F01CFA434D58} = {3B56C02B-4468-4268-B797-851562789FCC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C780ABA-5872-4B83-AD3F-A5BD423AD907}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Authors>Blockcore</Authors>
<AssemblyTitle>Blockcore.Networks.HomeCoin</AssemblyTitle>
<AssemblyName>Blockcore.Networks.HomeCoin</AssemblyName>
<PackageId>Blockcore.Networks.HomeCoin</PackageId>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<LangVersion>latest</LangVersion>
<Description>Home Crypto Coin</Description>
<PackageProjectUrl>https://homecoin.ru</PackageProjectUrl>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this idea about overriding the default Blockcore properties. All individual network definitions should do the same.

<RepositoryUrl>git://github.com/homecoin-ru/blockcore</RepositoryUrl>
<PackageTags>blockchain;cryptocurrency;crypto;C#;.NET;bitcoin;blockcore,homecoin</PackageTags>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="icon.png" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Features\Blockcore.Features.Consensus\Blockcore.Features.Consensus.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.MemoryPool\Blockcore.Features.MemoryPool.csproj" />
<ProjectReference Include="..\..\Features\Blockcore.Features.Miner\Blockcore.Features.Miner.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
123 changes: 123 additions & 0 deletions src/Networks/Blockcore.Networks.HomeCoin/HomeCoinSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using Blockcore.Consensus.Checkpoints;
using HomeCoin.Networks.Setup;
using NBitcoin;

namespace HomeCoin
{
internal class HomeCoinSetup
{
internal static HomeCoinSetup Instance = new HomeCoinSetup();

internal CoinSetup Setup = new CoinSetup
{
FileNamePrefix = "homecoin",
ConfigFileName = "homecoin.conf",
Magic = "48-4F-4D-45",
CoinType = 100500, //0x80018894// SLIP-0044: https://github.com/satoshilabs/slips/blob/master/slip-0044.md,
PremineReward = 1000000,
PoWBlockReward = 10,
PoSBlockReward = 10,
LastPowBlock = 100500,
MaxSupply = 21000000,
GenesisText = "I'd like to know what this whole show is all about before it's out.",
TargetSpacing = TimeSpan.FromSeconds(64),
ProofOfStakeTimestampMask = 0x0000000F,
PoSVersion = 3
};

internal NetworkSetup Main = new NetworkSetup
{
Name = "HomeCoinMain",
RootFolderName = "homecoin",
CoinTicker = "HOME",
DefaultPort = 33331,
DefaultRPCPort = 33332,
DefaultAPIPort = 33333,
DefaultSignalRPort = 33334,
PubKeyAddress = 40, // B https://en.bitcoin.it/wiki/List_of_address_prefixes
sondreb marked this conversation as resolved.
Show resolved Hide resolved
ScriptAddress = 100, // b
SecretAddress = 160,
GenesisTime = 1614259698,
GenesisNonce = 60494,
GenesisBits = 0x1E0FFFFF,
GenesisVersion = 1,
GenesisReward = Money.Zero,
HashGenesisBlock = "00000ae66e376bf115b9440f03a520bd88d28624ec6f13606b0d72051e56e635",
HashMerkleRoot = "f54bfdb51ebda155c70525ed6ef4fee32ca2564b8532767661acf42015cd5542",
DNS = new[] { "seed.homecoin.ru", "seed2.homecoin.ru", "seed3.homecoin.ru", "seed4.homecoin.ru", "seed5.homecoin.ru" },
Nodes = new[] { "167.86.77.3", "167.86.126.130", "158.101.197.109", "158.101.206.15", "40.76.201.247" },
Checkpoints = new Dictionary<int, CheckpointInfo>
{
{ 0, new CheckpointInfo(new uint256("0x00000ae66e376bf115b9440f03a520bd88d28624ec6f13606b0d72051e56e635"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, // Genisis
{ 2, new CheckpointInfo(new uint256("0x346e8a928dc03b3d92249cc67666d905a92b09f18b7bb5308198d7a28562bd98"), new uint256("0x8503c0bca8aeca76ed38648896d164637bf7229f5d9865d2b26448d448675c43")) }, // Premine
{ 1000, new CheckpointInfo(new uint256("0x10b7137bc293d3c9426b29548ff902fca123f60e7af8a844c8fa151a736dbb37"), new uint256("0x228f509a5761ca04c14e2c3aa1b2a3249485525dbc9c33e19271e13404c0a7ee")) },
}
};

internal NetworkSetup RegTest = new NetworkSetup
{
Name = "HomeCoinRegTest",
RootFolderName = "homecoinregtest",
CoinTicker = "THOME",
DefaultPort = 43331,
DefaultRPCPort = 43332,
DefaultAPIPort = 43333,
DefaultSignalRPort = 43334,
PubKeyAddress = 111,
ScriptAddress = 196,
SecretAddress = 239,
GenesisTime = 1614259704,
GenesisNonce = 83376,
GenesisBits = 0x1F00FFFF,
GenesisVersion = 1,
GenesisReward = Money.Zero,
HashGenesisBlock = "00008e71ca88630fe4f8156b826f04f564858315e0d2d38ffaf583f3c269de44",
HashMerkleRoot = "6c68247b2a96dabbcd8bffd2b0cc9adbca29662c7a94acedf3543ac3a98e9806",
DNS = new[] { "regtestseed.homecoin.ru", "regtestseed2.homecoin.ru", "regtestseed3.homecoin.ru", "regtestseed4.homecoin.ru", "regtestseed5.homecoin.ru" },
Nodes = new[] { "167.86.77.3", "167.86.126.130", "158.101.197.109", "158.101.196.76", "40.76.201.247" },
Checkpoints = new Dictionary<int, CheckpointInfo>
{
// TODO: Add checkpoints as the network progresses.
}
};

internal NetworkSetup Test = new NetworkSetup
{
Name = "HomeCoinTest",
RootFolderName = "homecointest",
CoinTicker = "THOME",
DefaultPort = 53331,
DefaultRPCPort = 53331,
DefaultAPIPort = 53331,
DefaultSignalRPort = 53334,
PubKeyAddress = 111,
ScriptAddress = 196,
SecretAddress = 239,
GenesisTime = 1614259712,
GenesisNonce = 1845,
GenesisBits = 0x1F0FFFFF,
GenesisVersion = 1,
GenesisReward = Money.Zero,
HashGenesisBlock = "0008c7ff991b012b8dc06bd91165b64b307e53f183d070850d8381f238c672df",
HashMerkleRoot = "277acb69460036d6f4aa04408164be0c38d6cc1c10cc771fb1385696036fe742",
DNS = new[] { "testseed.homecoin.ru", "testseed2.homecoin.ru", "testseed3.homecoin.ru", "testseed4.homecoin.ru", "testseed5.homecoin.ru" },
Nodes = new[] { "167.86.77.3", "167.86.126.130", "158.101.197.109", "158.101.196.76", "40.76.201.247" },
Checkpoints = new Dictionary<int, CheckpointInfo>
{
// TODO: Add checkpoints as the network progresses.
}
};

public bool IsPoSv3()
{
return this.Setup.PoSVersion == 3;
}

public bool IsPoSv4()
{
return this.Setup.PoSVersion == 4;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Blockcore.Base.Deployments;
using Blockcore.Consensus.ScriptInfo;
using Blockcore.Consensus.TransactionInfo;

namespace HomeCoin.Networks.Deployments
{
/// <summary>
/// BIP9 deployments for the Blockcore sample coin network.
/// </summary>
public class HomeCoinBIP9Deployments : BIP9DeploymentsArray
{
// The position of each deployment in the deployments array. Note that this is decoupled from the actual position of the flag bit for the deployment in the block version.
public const int CSV = 0;
public const int Segwit = 1;
public const int ColdStaking = 2; // TODO: Move this to the end of the deployments to leave room for others from Bitcoin?

// The number of deployments.
public const int NumberOfDeployments = 3;

/// <summary>
/// Constructs the BIP9 deployments array.
/// </summary>
public HomeCoinBIP9Deployments() : base(NumberOfDeployments)
{
}

/// <summary>
/// Gets the deployment flags to set when the deployment activates.
/// </summary>
/// <param name="deployment">The deployment number.</param>
/// <returns>The deployment flags.</returns>
public override BIP9DeploymentFlags GetFlags(int deployment)
{
// The flags get combined in the caller, so it is ok to make a fresh object here.
var flags = new BIP9DeploymentFlags();

switch (deployment)
{
case ColdStaking:
flags.ScriptFlags = ScriptVerify.CheckColdStakeVerify;
break;

case CSV:
// Start enforcing BIP68 (sequence locks), BIP112 (CHECKSEQUENCEVERIFY) and BIP113 (Median Time Past) using versionbits logic.
flags.ScriptFlags = ScriptVerify.CheckSequenceVerify;
flags.LockTimeFlags = Transaction.LockTimeFlags.VerifySequence | Transaction.LockTimeFlags.MedianTimePast;
break;

case Segwit:
// Start enforcing WITNESS rules using versionbits logic.
flags.ScriptFlags = ScriptVerify.Witness;
break;
}

return flags;
}
}
}
Loading