diff --git a/NBitcoin.Altcoins/AltcoinNetworkSets.cs b/NBitcoin.Altcoins/AltcoinNetworkSets.cs index 25c10ec0fc..d755f352d3 100644 --- a/NBitcoin.Altcoins/AltcoinNetworkSets.cs +++ b/NBitcoin.Altcoins/AltcoinNetworkSets.cs @@ -31,6 +31,7 @@ public class AltNetworkSets public static Bitcoinplus Bitcoinplus { get; } = Bitcoinplus.Instance; public static Chaincoin Chaincoin { get; } = Chaincoin.Instance; public static Stratis Stratis { get; } = Stratis.Instance; + public static SmartCash SmartCash { get; } = SmartCash.Instance; public static IEnumerable GetAll() { @@ -57,6 +58,7 @@ public static IEnumerable GetAll() yield return Koto; yield return Bitcoinplus; yield return Chaincoin; + yield return SmartCash; } } } diff --git a/NBitcoin.Altcoins/README.md b/NBitcoin.Altcoins/README.md index 3f5421b3a8..7a29aa61a3 100644 --- a/NBitcoin.Altcoins/README.md +++ b/NBitcoin.Altcoins/README.md @@ -20,6 +20,7 @@ Currently supported altcoins are: * Koto * Bitcoinplus * Chaincoin +* SmartCash ## How to use? diff --git a/NBitcoin.Altcoins/SmartCash.Internals/SmartCashKeccak.cs b/NBitcoin.Altcoins/SmartCash.Internals/SmartCashKeccak.cs new file mode 100644 index 0000000000..cff0c203ff --- /dev/null +++ b/NBitcoin.Altcoins/SmartCash.Internals/SmartCashKeccak.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NBitcoin.Altcoins.SmartCashInternals +{ + public class SmartCashKeccak + { + public byte[] ComputeHash(byte[] input) + { + byte[] hashResult = input; + var keccak256 = HashX11.HashFactory.Crypto.SHA3.CreateKeccak256(); + hashResult = keccak256.ComputeBytes(hashResult).GetBytes(); + return hashResult.Take(32).ToArray(); + } + } +} diff --git a/NBitcoin.Altcoins/SmartCash.cs b/NBitcoin.Altcoins/SmartCash.cs new file mode 100644 index 0000000000..a489272922 --- /dev/null +++ b/NBitcoin.Altcoins/SmartCash.cs @@ -0,0 +1,363 @@ +using NBitcoin; +using NBitcoin.Altcoins.SmartCashInternals; +using NBitcoin.Crypto; +using NBitcoin.DataEncoders; +using NBitcoin.Protocol; +using NBitcoin.RPC; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; + +namespace NBitcoin.Altcoins +{ + public class SmartCash : NetworkSetBase + { + public class SmartCashEncoder : Base58CheckEncoder + { + + private static readonly SmartCashEncoder _Instance = new SmartCashEncoder(); + + public static SmartCashEncoder Instance + { + get + { + return _Instance; + } + } + private SmartCashEncoder() + { + + } + + protected override byte[] CalculateHash(byte[] bytes, int offset, int length) + { + var smartCashKeccak = new SmartCashKeccak(); + return smartCashKeccak.ComputeHash(bytes.Skip(offset).Take(length).ToArray()); + } + } + + public static SmartCash Instance { get; } = new SmartCash(); + public override string CryptoCode => "SMART"; + + public SmartCash() + { + + } + + public class SmartCashFactory : ConsensusFactory + { + private SmartCashFactory() + { + } + public static SmartCashFactory Instance { get; } = new SmartCashFactory(); + + public override BlockHeader CreateBlockHeader() + { + return new SmartCashBlockHeader(); + } + public override Block CreateBlock() + { + return new SmartCashBlock(new SmartCashBlockHeader()); + } + + public override Transaction CreateTransaction() + { + return new SmartCashTransaction(); + } + + +#pragma warning disable CS0618 // Type or member is obsolete + public class SmartCashTransaction : Transaction + { + protected override HashStreamBase CreateHashStream() + { + return BufferedHashStream.CreateFrom(Hashes.SHA256, 300); + } + + public override ConsensusFactory GetConsensusFactory() + { + return SmartCashFactory.Instance; + } + + protected override HashStreamBase CreateSignatureHashStream() + { + return BufferedHashStream.CreateFrom(Hashes.SHA256, 150); + } + } + } + +#pragma warning disable CS0618 // Type or member is obsolete + public class SmartCashBlock : Block + { + public SmartCashBlock(SmartCashBlockHeader header) : base(header) + { + + } + + public override ConsensusFactory GetConsensusFactory() + { + return SmartCashFactory.Instance; + } + } + public class SmartCashBlockHeader : BlockHeader + { + public override uint256 GetPoWHash() + { + var headerBytes = this.ToBytes(); + var h = NBitcoin.Crypto.SCrypt.ComputeDerivedKey(headerBytes, headerBytes, 1024, 1, 1, null, 32); + return new uint256(h); + } + } +#pragma warning restore CS0618 // Type or member is obsolete + + //Format visual studio + //{({.*?}), (.*?)} + //Tuple.Create(new byte[]$1, $2) + + class SmartCashStringParser : NetworkStringParser + { + private static readonly SmartCashStringParser _Instance = new SmartCashStringParser(); + public static SmartCashStringParser Instance + { + get + { + return _Instance; + } + } + private SmartCashStringParser() + { + + } + + public override Base58CheckEncoder GetBase58CheckEncoder() + { + return SmartCashEncoder.Instance; + } + } + + static Tuple[] pnSeed6_main = { + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x01,0xca,0x80,0xda}, 10333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x18,0x92,0x06,0x11}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x1f,0x1f,0x4f,0x86}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x25,0x3b,0x18,0x0f}, 8331), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x25,0x61,0xa8,0xc8}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x25,0x8b,0x09,0xf8}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x26,0x6d,0xda,0x72}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x28,0x89,0x72}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x37,0xb0,0x1a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0x1c,0xc9,0x44}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0x94,0x10,0xca}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0xac,0x04,0x1f}, 9335), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0xf9,0x2f,0xe9}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2f,0x5a,0x04,0x29}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2f,0x5a,0x2e,0xcb}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2f,0xbd,0x81,0xda}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x32,0x07,0x2f,0x5a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x32,0x16,0x67,0x82}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x34,0x29,0x09,0x40}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x3c,0xcd,0x3a,0x20}, 7749), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x3f,0xe7,0xef,0xd4}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x49,0x59,0xc3,0x81}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x4a,0xd0,0x2b,0x36}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x50,0xde,0x27,0x4d}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x50,0xf1,0xda,0x38}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x52,0xa5,0x80,0xd5}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0x95,0x7d,0x4f}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0xac,0x45,0x9a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0xd4,0x75,0x8c}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x54,0x34,0x91,0x24}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x54,0x57,0x79,0x0b}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x54,0x92,0x3f,0xdf}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x55,0x19,0x92,0x4a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x58,0xb9,0x9b,0x86}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x5b,0xe2,0x0a,0x5a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x5b,0xf0,0x8d,0xaf}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x5e,0x71,0x9c,0xdd}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x60,0x38,0x91,0xfa}, 10333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x60,0xff,0x06,0xfd}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x68,0xdf,0x3b,0x8c}, 23333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x6c,0x1f,0x0f,0x9a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x6d,0xec,0x5a,0x7a}, 59333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x6f,0xcd,0x01,0xf6}, 10333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x71,0x0a,0x9c,0xb6}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x72,0x37,0x4a,0x02}, 20044), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x74,0x7d,0x78,0x1a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x77,0x3f,0x2c,0x85}, 19992), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x77,0x93,0x89,0x9b}, 19992), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x86,0xd5,0xde,0xa1}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x93,0x9c,0x54,0xba}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x95,0xd2,0xab,0xe1}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xa2,0xf3,0xd8,0xf4}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xa3,0xac,0x21,0x4e}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xa3,0xac,0x23,0xf7}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xad,0xd0,0xc2,0x5e}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xae,0x3c,0x89,0x4c}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0x3f,0x12,0x03}, 9335), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0x3f,0x72,0x19}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0xfe,0x28,0x29}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb7,0x3d,0x92,0x85}, 19992), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x3c,0xf4,0xfb}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x57,0xb8,0x1d}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xbc,0x00,0xb6,0x0a}, 9335), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xbc,0x8a,0x21,0x21}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xbc,0x9b,0x88,0x46}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc0,0x63,0x3e,0x17}, 5001), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc0,0xc6,0x64,0x54}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc0,0xf1,0xa6,0x70}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc6,0x0c,0x4b,0x19}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xcb,0xb1,0x8e,0x25}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd3,0x6e,0x01,0x11}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd3,0x95,0xf6,0x96}, 1022), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd4,0x5d,0xe2,0x5a}, 9333), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd5,0x7e,0x8d,0x3c}, 9333) +}; + static Tuple[] pnSeed6_test = { + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x68,0xec,0xd3,0xce}, 19335), + Tuple.Create(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x42,0xb2,0xb6,0x23}, 19335) +}; + + protected override NetworkBuilder CreateMainnet() + { + NetworkBuilder builder = new NetworkBuilder(); + builder.SetConsensus(new Consensus() + { + SubsidyHalvingInterval = 840000, + MajorityEnforceBlockUpgrade = 750, + MajorityRejectBlockOutdated = 950, + MajorityWindow = 1000, + BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"), + PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), + PowTargetTimespan = TimeSpan.FromSeconds(3.5 * 24 * 60 * 60), + PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60), + PowAllowMinDifficultyBlocks = false, + PowNoRetargeting = false, + RuleChangeActivationThreshold = 6048, + MinerConfirmationWindow = 8064, + CoinbaseMaturity = 100, + ConsensusFactory = SmartCashFactory.Instance, + //HashGenesisBlock = new uint256("0x000007acc6970b812948d14ea5a0a13db0fdd07d5047c7e69101fa8b361e05a4"), + //GetPoWHash = GetPoWHash, + LitecoinWorkCalculation = true + }) + .SetNetworkStringParser(SmartCashStringParser.Instance) + .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 63 }) + .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 18 }) + //.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 128 }) + .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 191 }) + .SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { 0x04, 0x88, 0xB2, 0x1E }) + .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { 0x04, 0x88, 0xAD, 0xE4 }) + .SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, Encoders.Bech32("smart")) + .SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("smart")) + .SetMagic(0xdbb6c0fb) + .SetPort(9678) + .SetRPCPort(9679) + .SetName("smart-main") + .AddAlias("smart-mainnet") + .AddAlias("smartcash-mainnet") + .AddAlias("smartcash-main") + .AddDNSSeeds(new[] + { + new DNSSeedData("seed.smartcash.cc", "seed.smartcash.cc"), + new DNSSeedData("seed2.smartcash.cc", "seed2.smartcash.cc"), + new DNSSeedData("seed3.smartcash.cc", "seed3.smartcash.cc"), + new DNSSeedData("seed4.smartcash.cc", "seed4.smartcash.cc"), + }) + .AddSeeds(ToSeed(pnSeed6_main)) + .SetGenesis("02000000000000000000000000000000000000000000000000000000000000000000000062d421ff675e5e9e829ba28cd9097b1e8f247642d30d7398c35e4dced88791b70a4a3259f0ff0f1e7fc003000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2e04ffff0f1e010421536d617274436173682c20436f6d6d756e696e74792044726976656e204361736804833e0000ffffffff0100000000000000000000000000"); + + return builder; + } + + protected override NetworkBuilder CreateTestnet() + { + NetworkBuilder builder = new NetworkBuilder(); + builder.SetConsensus(new Consensus() + { + SubsidyHalvingInterval = 840000, + MajorityEnforceBlockUpgrade = 51, + MajorityRejectBlockOutdated = 75, + MajorityWindow = 1000, + PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), + PowTargetTimespan = TimeSpan.FromSeconds(3.5 * 24 * 60 * 60), + PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60), + PowAllowMinDifficultyBlocks = true, + PowNoRetargeting = false, + RuleChangeActivationThreshold = 1512, + MinerConfirmationWindow = 2016, + CoinbaseMaturity = 100, + //HashGenesisBlock = new uint256("f5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f"), + //GetPoWHash = GetPoWHash, + LitecoinWorkCalculation = true + }) + .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 111 }) + .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 58 }) + .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 239 }) + .SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { 0x04, 0x35, 0x87, 0xCF }) + .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { 0x04, 0x35, 0x83, 0x94 }) + .SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, Encoders.Bech32("smart")) + .SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("smart")) + .SetMagic(0xf1c8d2fd) + .SetPort(19678) + .SetRPCPort(19679) + .SetName("smart-test") + .AddAlias("smart-testnet") + .AddAlias("smartcash-test") + .AddAlias("smartcash-testnet") + .AddDNSSeeds(new[] + { + new DNSSeedData("testnet.smartcash.cc", "testnet.smartcash.cc"), + new DNSSeedData("testnet.smart.cash", "testnet.smart.cash"), + }) + .AddSeeds(ToSeed(pnSeed6_test)) + .SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000d9ced4ed1130f7b7faad9be25323ffafa33232a17c3edf6cfd97bee6bafbdd97f6028c4ef0ff0f1e38c3f6160101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4804ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536ffffffff0100f2052a010000004341040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9ac00000000"); + + return builder; + } + + protected override NetworkBuilder CreateRegtest() + { + NetworkBuilder builder = new NetworkBuilder(); + builder.SetConsensus(new Consensus() + { + SubsidyHalvingInterval = 840000, + MajorityEnforceBlockUpgrade = 750, + MajorityRejectBlockOutdated = 950, + MajorityWindow = 1000, + BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"), + PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), + PowTargetTimespan = TimeSpan.FromSeconds(3.5 * 24 * 60 * 60), + PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60), + PowAllowMinDifficultyBlocks = false, + PowNoRetargeting = false, + RuleChangeActivationThreshold = 6048, + MinerConfirmationWindow = 8064, + CoinbaseMaturity = 100, + //HashGenesisBlock = new uint256("0x000007acc6970b812948d14ea5a0a13db0fdd07d5047c7e69101fa8b361e05a4"), + //GetPoWHash = GetPoWHash, + LitecoinWorkCalculation = true, + }) + .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 63 }) + .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 18 }) + //.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 239 }) + .SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { 0x04, 0x88, 0xB2, 0x1E }) + .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { 0x04, 0x88, 0xAD, 0xE4 }) + .SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, Encoders.Bech32("smart")) + .SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("smart")) + .SetMagic(0xdbb6c0fb) + .SetPort(9678) + .SetRPCPort(9679) + .SetName("smart-reg") + .AddAlias("smart-regtest") + .AddAlias("smartcash-regtest") + .AddAlias("smartcash-reg") + .AddDNSSeeds(new DNSSeedData[0]) + .AddSeeds(new NetworkAddress[0]) + .SetGenesis("02000000000000000000000000000000000000000000000000000000000000000000000062d421ff675e5e9e829ba28cd9097b1e8f247642d30d7398c35e4dced88791b70a4a3259f0ff0f1e7fc003000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2e04ffff0f1e010421536d617274436173682c20436f6d6d756e696e74792044726976656e204361736804833e0000ffffffff0100000000000000000000000000"); + + return builder; + } + + } +} diff --git a/NBitcoin.TestFramework/WellknownNodeDownloadData.cs b/NBitcoin.TestFramework/WellknownNodeDownloadData.cs index edcae52da7..203fada3e7 100644 --- a/NBitcoin.TestFramework/WellknownNodeDownloadData.cs +++ b/NBitcoin.TestFramework/WellknownNodeDownloadData.cs @@ -881,6 +881,35 @@ public class StratisNodeDownloadData }; } + public class SmartCashNodeDownloadData + { + public NodeDownloadData v1_2_8 = new NodeDownloadData() + { + Version = "1.2.8", + Windows = new NodeOSDownloadData() + { + DownloadLink = "https://www.dropbox.com/s/rulwm5bigm3xmfx/smartcashd-v{0}.zip?dl=1", + Archive = "smartcashd-v{0}.zip", + Executable = "smartcashd.exe", + Hash = "d78968049874617b9703323bf9ca03a8d140ebf605fff415437693abe3ccc5a0" + }, + Linux = new NodeOSDownloadData() + { + DownloadLink = "https://github.com/SmartCash/Core-Smart/releases/download/v{0}/smartcash-{0}-x86_64-linux-gnu.tar.gz", + Archive = "smartcash-{0}-x86_64-linux-gnu.tar.gz", + Executable = "smartcash-{0}-x86_64-linux-gnu/smartcash", + Hash = "D8738E8C3D97A3B776414278991EDCCD1E555756713911FDC21E77836D00A3F9" + }, + Mac = new NodeOSDownloadData() + { + DownloadLink = "https://github.com/SmartCash/Core-Smart/releases/download/v{0}/smartcash-{0}-osx.dmg", + Archive = "smartcash-{0}-osx.dmg", + Executable = "smartcash-{0}-osx.dmg/smartcash", + Hash = "13B0DBF2480EB47D2B8A5B82145FE2FC87AEF22CB5CDF78E01C27A41C8CD41D1" + } + }; + } + public static GoByteNodeDownloadData GoByte { get; set; @@ -1005,6 +1034,11 @@ public static StratisNodeDownloadData Stratis get; set; } = new StratisNodeDownloadData(); + public static SmartCashNodeDownloadData SmartCash + { + get; set; + } = new SmartCashNodeDownloadData(); + public bool UseSectionInConfigFile { get; private set; } public string AdditionalRegtestConfig { get; private set; } } diff --git a/NBitcoin.Tests/NodeBuilderEx.cs b/NBitcoin.Tests/NodeBuilderEx.cs index 506fa85e9c..6c6b396993 100644 --- a/NBitcoin.Tests/NodeBuilderEx.cs +++ b/NBitcoin.Tests/NodeBuilderEx.cs @@ -54,6 +54,8 @@ public static NodeBuilder Create([CallerMemberName] string caller = null) //var builder = NodeBuilder.Create(NodeDownloadData.Koto.v2_0_0, Altcoins.Koto.Regtest, caller); //var builder = NodeBuilder.Create(NodeDownloadData.Chaincoin.v0_16_4 , Altcoins.AltNetworkSets.Chaincoin.Regtest, caller); //var builder = NodeBuilder.Create(NodeDownloadData.Stratis.v3_0_0, Altcoins.AltNetworkSets.Stratis.Regtest, caller); + //var builder = NodeBuilder.Create(NodeDownloadData.SmartCash.v1_2_8, Altcoins.AltNetworkSets.SmartCash.Testnet, caller); + return builder; }