private static Network InitStratisRegTest() { // TODO: move this to Networks var net = Network.GetNetwork("StratisRegTest"); if (net != null) { return(net); } 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; // 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 pchMessageStart = new byte[4]; pchMessageStart[0] = 0xcd; pchMessageStart[1] = 0xf2; pchMessageStart[2] = 0xc0; pchMessageStart[3] = 0xef; var magic = BitConverter.ToUInt32(pchMessageStart, 0); //0x5223570; var genesis = Network.StratisMain.GetGenesis().Clone(); genesis.Header.Time = 1494909211; genesis.Header.Nonce = 2433759; genesis.Header.Bits = consensus.PowLimit; consensus.HashGenesisBlock = genesis.GetHash(); Guard.Assert(consensus.HashGenesisBlock == uint256.Parse("0x93925104d664314f581bc7ecb7b4bad07bcfabd1cfce4256dbd2faddcf53bd1f")); var builder = new NetworkBuilder() .SetName("StratisRegTest") .SetConsensus(consensus) .SetMagic(magic) .SetGenesis(genesis) .SetPort(18444) .SetRPCPort(18442) .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()); }
public void CanCreateNetwork() { NetworkBuilder builder = new NetworkBuilder(); builder.CopyFrom(Network.Main); builder.SetName(null); Assert.Throws <InvalidOperationException>(() => builder.BuildAndRegister()); builder.SetName("new"); builder.AddAlias("newalias"); var network = builder.BuildAndRegister(); Assert.Throws <InvalidOperationException>(() => builder.BuildAndRegister()); Assert.Equal(network, Network.GetNetwork("new")); Assert.Equal(network, Network.GetNetwork("newalias")); CanGetNetworkFromName(); Assert.True(Network.GetNetworks().Contains(network)); }
private static Network InitStratisTest() { Block.BlockSignature = true; Transaction.TimeStamp = true; var consensus = Network.StratisMain.Consensus.Clone(); consensus.PowLimit = new Target(uint256.Parse("0000ffff00000000000000000000000000000000000000000000000000000000")); // 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 pchMessageStart = new byte[4]; pchMessageStart[0] = 0x71; pchMessageStart[1] = 0x31; pchMessageStart[2] = 0x21; pchMessageStart[3] = 0x11; var magic = BitConverter.ToUInt32(pchMessageStart, 0); //0x5223570; var genesis = Network.StratisMain.GetGenesis().Clone(); genesis.Header.Time = 1493909211; genesis.Header.Nonce = 2433759; genesis.Header.Bits = consensus.PowLimit; consensus.HashGenesisBlock = genesis.GetHash(); Guard.Assert(consensus.HashGenesisBlock == uint256.Parse("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9")); var builder = new NetworkBuilder() .SetName("StratisTest") .SetConsensus(consensus) .SetMagic(magic) .SetGenesis(genesis) .SetPort(26178) .SetRPCPort(26174) .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) }) .AddDNSSeeds(new[] { new DNSSeedData("stratisplatform.com", "testnode1.stratisplatform.com"), }); return(builder.BuildAndRegister()); }
private static Network InitLLCoin() { Block.BlockSignature = true; Transaction.TimeStamp = true; var consensus = Network.StratisMain.Consensus.Clone(); consensus.PowLimit = new Target(uint256.Parse("0x000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); // 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 pchMessageStart = new byte[4]; pchMessageStart[0] = 0x71; pchMessageStart[1] = 0x31; pchMessageStart[2] = 0x21; pchMessageStart[3] = 0x11; var magic = BitConverter.ToUInt32(pchMessageStart, 0); //0x5223570; //var genesis = Network.StratisMain.GetGenesis().Clone(); var genesis = CreateStratisGenesisBlock(1496069495, 1840204, consensus.PowLimit, 1, Money.Zero); consensus.HashGenesisBlock = genesis.GetHash(); Guard.Assert(consensus.HashGenesisBlock == uint256.Parse("0x0002c75e4179fd8dc22391536af7e647bdd88b83d9ed57fcf09e5ae3d06cae78")); var builder = new NetworkBuilder() .SetName("LLCoin") .SetConsensus(consensus) .SetMagic(magic) .SetGenesis(genesis) .SetPort(36178) .SetRPCPort(36174) .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (63) }) .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { (125) }) .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { (63 + 125) }) .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), (0xC2), (0x1E) }) .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { (0x04), (0x88), (0xB2), (0xDD) }) .AddDNSSeeds(new[] { new DNSSeedData("stratisplatform.com", "testnode1.stratisplatform.com"), }); return(builder.BuildAndRegister()); }
private static Network InitBitcoinMain() { //SpendableCoinbaseDepth = 100; //name = "Main"; var consensus = new Consensus(); 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("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); consensus.SegWitHeight = 2000000000; 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.HashGenesisBlock = uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); //genesis.GetHash(); var builder = new NetworkBuilder() .SetConsensus(consensus) .SetMagic(0xD9B4BEF9) .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (0) }) .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { (5) }) .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { (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 }) .SetBase58Bytes(Base58Type.WITNESS_P2WPKH, new byte[] { 0x6 }) .SetBase58Bytes(Base58Type.WITNESS_P2WSH, new byte[] { (10) }) .SetName("BitcoinMain") .SetGenesis(CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, Money.Coins(50m))); return(builder.BuildAndRegister()); // 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. //magic = 0xD9B4BEF9; //vAlertPubKey = Encoders.Hex.DecodeData("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284"); //nDefaultPort = 8333; //nRPCPort = 8332; //nSubsidyHalvingInterval = 210000; // the genesis block can not be generated as the Block serialization is different // set the the gemesis hash manually. //genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, Money.Coins(50m)); //consensus.HashGenesisBlock = uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); //genesis.GetHash(); //assert(consensus.HashGenesisBlock == uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")); //assert(genesis.Header.HashMerkleRoot == uint256.Parse("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); //base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (0) }; //base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (5) }; //base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (128) }; //base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_NO_EC] = new byte[] { 0x01, 0x42 }; //base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_EC] = new byte[] { 0x01, 0x43 }; //base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { (0x04), (0x88), (0xB2), (0x1E) }; //base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x88), (0xAD), (0xE4) }; //base58Prefixes[(int)Base58Type.PASSPHRASE_CODE] = new byte[] { 0x2C, 0xE9, 0xB3, 0xE1, 0xFF, 0x39, 0xE2 }; //base58Prefixes[(int)Base58Type.CONFIRMATION_CODE] = new byte[] { 0x64, 0x3B, 0xF6, 0xA8, 0x9A }; //base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2a }; //base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 23 }; //base58Prefixes[(int)Base58Type.COLORED_ADDRESS] = new byte[] { 0x13 }; //base58Prefixes[(int)Base58Type.WITNESS_P2WPKH] = new byte[] { 0x6 }; //base58Prefixes[(int)Base58Type.WITNESS_P2WSH] = new byte[] { (10) }; }