public void IsStrictDerSigTest(int height, bool expected) { Consensus cs = new Consensus(height, NetworkType.MainNet); Assert.Equal(expected, cs.IsStrictDerSig); }
internal static TimeSpan GetEstimatedTime(Consensus consensus, int blocks) { return(TimeSpan.FromTicks(consensus.PowTargetSpacing.Ticks * blocks)); }
public SolarisRegTest() { NetworkType = NetworkType.Regtest; Name = SolarisSetup.RegTest.Name; CoinTicker = SolarisSetup.RegTest.CoinTicker; Magic = ConversionTools.ConvertToUInt32(SolarisSetup.Magic, true); RootFolderName = SolarisSetup.RegTest.RootFolderName; DefaultPort = SolarisSetup.RegTest.DefaultPort; DefaultRPCPort = SolarisSetup.RegTest.DefaultRPCPort; DefaultAPIPort = SolarisSetup.RegTest.DefaultAPIPort; var consensusFactory = new PosConsensusFactory(); Block genesisBlock = CreateGenesisBlock(consensusFactory, SolarisSetup.RegTest.GenesisTime, SolarisSetup.RegTest.GenesisNonce, SolarisSetup.RegTest.GenesisBits, SolarisSetup.RegTest.GenesisVersion, SolarisSetup.RegTest.GenesisReward, SolarisSetup.GenesisText); Genesis = genesisBlock; // Taken from StratisX. var consensusOptions = new PosConsensusOptions { MaxBlockBaseSize = 1_000_000, MaxStandardVersion = 2, MaxStandardTxWeight = 100_000, MaxBlockSigopsCost = 20_000, MaxStandardTxSigopsCost = 20_000 / 5, WitnessScaleFactor = 4 }; var buriedDeployments = new BuriedDeploymentsArray { [BuriedDeployments.BIP34] = 0, [BuriedDeployments.BIP65] = 0, [BuriedDeployments.BIP66] = 0 }; Consensus = new Consensus( consensusFactory: consensusFactory, consensusOptions: consensusOptions, coinType: SolarisSetup.CoinType, hashGenesisBlock: genesisBlock.GetHash(), subsidyHalvingInterval: 260000, majorityEnforceBlockUpgrade: 750, majorityRejectBlockOutdated: 950, majorityWindow: 1000, buriedDeployments: buriedDeployments, bip9Deployments: new NoBIP9Deployments(), bip34Hash: null, minerConfirmationWindow: 2016, // nPowTargetTimespan / nPowTargetSpacing maxReorgLength: 500, defaultAssumeValid: null, maxMoney: long.MaxValue, coinbaseMaturity: 10, premineHeight: 2, premineReward: Money.Coins(SolarisSetup.PremineReward), proofOfWorkReward: Money.Coins(SolarisSetup.PoWBlockReward), targetTimespan: TimeSpan.FromSeconds(14 * 24 * 60 * 60), // two weeks targetSpacing: SolarisSetup.TargetSpacing, powAllowMinDifficultyBlocks: true, posNoRetargeting: true, powNoRetargeting: true, powLimit: new Target(new uint256("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), minimumChainWork: null, isProofOfStake: true, lastPowBlock: SolarisSetup.LastPowBlock, proofOfStakeLimit: new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)), proofOfStakeLimitV2: new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)), proofOfStakeReward: Money.Coins(SolarisSetup.PoSBlockReward), proofOfStakeTimestampMask: SolarisSetup.ProofOfStakeTimestampMask ); Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (SolarisSetup.RegTest.PubKeyAddress) }; Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (SolarisSetup.RegTest.ScriptAddress) }; Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (239) }; Base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { (0x04), (0x35), (0x87), (0xCF) }; Base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x35), (0x83), (0x94) }; // Base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2b }; Base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 115 }; Bech32Encoders = new Bech32Encoder[2]; var encoder = new Bech32Encoder(SolarisSetup.RegTest.CoinTicker.ToLowerInvariant()); Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder; Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder; Checkpoints = SolarisSetup.RegTest.Checkpoints; DNSSeeds = SolarisSetup.RegTest.DNS; SeedNodes = SolarisSetup.RegTest.Nodes; StandardScriptsRegistry = new SolarisStandardScriptsRegistry(); // 64 below should be changed to TargetSpacingSeconds when we move that field. Assert(DefaultBanTimeSeconds <= Consensus.MaxReorgLength * 64 / 2); Assert(Consensus.HashGenesisBlock == uint256.Parse(SolarisSetup.RegTest.HashGenesisBlock)); Assert(Genesis.Header.HashMerkleRoot == uint256.Parse(SolarisSetup.RegTest.HashMerkleRoot)); RegisterRules(Consensus); RegisterMempoolRules(Consensus); } }
public BitcoinRegTest() { this.Name = "RegTest"; this.AdditionalNames = new List <string> { "reg" }; this.Magic = 0xDAB5BFFA; this.DefaultPort = 18444; this.RPCPort = 18332; this.CoinTicker = "TBTC"; // Taken from BitcoinMain Consensus options var consensus = new Consensus(); consensus.MajorityEnforceBlockUpgrade = 750; consensus.MajorityRejectBlockOutdated = 950; consensus.MajorityWindow = 1000; consensus.PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60); // two weeks consensus.PowTargetSpacing = TimeSpan.FromSeconds(10 * 60); consensus.CoinbaseMaturity = 100; consensus.PremineReward = Money.Zero; consensus.ProofOfWorkReward = Money.Coins(50); consensus.ProofOfStakeReward = Money.Zero; consensus.MaxReorgLength = 0; consensus.MaxMoney = 21000000 * Money.COIN; // BitcoinRegTest differences consensus.CoinType = 0; consensus.PowAllowMinDifficultyBlocks = true; consensus.PowNoRetargeting = true; consensus.RuleChangeActivationThreshold = 108; consensus.MinerConfirmationWindow = 144; consensus.SubsidyHalvingInterval = 150; consensus.BIP34Hash = new uint256(); consensus.PowLimit = new Target(new uint256("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); consensus.MinimumChainWork = uint256.Zero; consensus.DefaultAssumeValid = null; // turn off assumevalid for regtest. consensus.BuriedDeployments[BuriedDeployments.BIP34] = 100000000; consensus.BuriedDeployments[BuriedDeployments.BIP65] = 100000000; consensus.BuriedDeployments[BuriedDeployments.BIP66] = 100000000; consensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 0, 999999999); consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 0, 999999999); consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, BIP9DeploymentsParameters.AlwaysActive, 999999999); this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (111) }; this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (196) }; this.Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (239) }; this.Base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { (0x04), (0x35), (0x87), (0xCF) }; this.Base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x35), (0x83), (0x94) }; this.Base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2b }; this.Base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 115 }; var encoder = new Bech32Encoder("tb"); this.Bech32Encoders = new Bech32Encoder[2]; this.Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder; this.Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder; this.Checkpoints = new Dictionary <int, CheckpointInfo>(); this.DNSSeeds = new List <DNSSeedData>(); this.SeedNodes = new List <NetworkAddress>(); // Create the genesis block. this.GenesisTime = 1296688602; this.GenesisNonce = 2; this.GenesisBits = 0x207fffff; this.GenesisVersion = 1; this.GenesisReward = Money.Coins(50m); this.Genesis = CreateBitcoinGenesisBlock(consensus.ConsensusFactory, this.GenesisTime, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward); consensus.HashGenesisBlock = this.Genesis.GetHash(); this.Consensus = consensus; Assert(this.Consensus.HashGenesisBlock == uint256.Parse("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")); }
public BitcoinTest() { this.Name = "TestNet"; this.AdditionalNames = new List <string> { "test" }; this.Magic = 0x0709110B; this.DefaultPort = 18333; this.RPCPort = 18332; this.CoinTicker = "TBTC"; // Taken from BitcoinMain Consensus options var consensus = new Consensus(); consensus.SubsidyHalvingInterval = 210000; consensus.PowLimit = new Target(new uint256("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); consensus.PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60); // two weeks consensus.PowTargetSpacing = TimeSpan.FromSeconds(10 * 60); consensus.PowNoRetargeting = false; consensus.MinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing consensus.CoinbaseMaturity = 100; consensus.PremineReward = Money.Zero; consensus.ProofOfWorkReward = Money.Coins(50); consensus.ProofOfStakeReward = Money.Zero; consensus.MaxReorgLength = 0; consensus.MaxMoney = 21000000 * Money.COIN; // BitcoinTest differences consensus.MajorityEnforceBlockUpgrade = 51; consensus.MajorityRejectBlockOutdated = 75; consensus.MajorityWindow = 100; consensus.BIP34Hash = new uint256("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8"); consensus.MinimumChainWork = new uint256("0x0000000000000000000000000000000000000000000000198b4def2baa9338d6"); consensus.DefaultAssumeValid = new uint256("0x000000000000015682a21fc3b1e5420435678cba99cace2b07fe69b668467651"); // 1292762 consensus.BuriedDeployments[BuriedDeployments.BIP34] = 21111; consensus.BuriedDeployments[BuriedDeployments.BIP65] = 581885; consensus.BuriedDeployments[BuriedDeployments.BIP66] = 330776; consensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 1199145601, 1230767999); consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1456790400, 1493596800); consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 1462060800, 1493596800); consensus.PowAllowMinDifficultyBlocks = true; consensus.RuleChangeActivationThreshold = 1512; // 75% for testchains consensus.CoinType = 1; this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (111) }; this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (196) }; this.Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (239) }; this.Base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { (0x04), (0x35), (0x87), (0xCF) }; this.Base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x35), (0x83), (0x94) }; this.Base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2b }; this.Base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 115 }; var encoder = new Bech32Encoder("tb"); this.Bech32Encoders = new Bech32Encoder[2]; this.Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder; this.Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder; // Partially obtained from https://github.com/bitcoin/bitcoin/blob/b1973d6181eacfaaf45effb67e0c449ea3a436b8/src/chainparams.cpp#L246 this.Checkpoints = new Dictionary <int, CheckpointInfo> { { 546, new CheckpointInfo(new uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")) }, { 1210000, new CheckpointInfo(new uint256("00000000461201277cf8c635fc10d042d6f0a7eaa57f6c9e8c099b9e0dbc46dc")) } }; this.DNSSeeds = new List <DNSSeedData> { new DNSSeedData("bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org"), new DNSSeedData("bluematt.me", "testnet-seed.bluematt.me"), new DNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de") }; this.SeedNodes = new List <NetworkAddress>(); // Create the genesis block. this.GenesisTime = 1296688602; this.GenesisNonce = 414098458; this.GenesisBits = 0x1d00ffff; this.GenesisVersion = 1; this.GenesisReward = Money.Coins(50m); this.Genesis = CreateBitcoinGenesisBlock(consensus.ConsensusFactory, this.GenesisTime, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward); consensus.HashGenesisBlock = this.Genesis.GetHash(); this.Consensus = consensus; Assert(this.Consensus.HashGenesisBlock == uint256.Parse("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943")); }
public void Load(byte[] chain, Consensus consensus) { Load(chain, consensus, null); }
public ConcurrentChain(byte[] bytes, Consensus consensus, ChainSerializationFormat format) { Load(bytes, consensus, format); }
public Target GetWorkRequired(Consensus consensus) { AssertHasHeader(); // Genesis block if (Height == 0) { return(consensus.PowLimit); } var nProofOfWorkLimit = consensus.PowLimit; var pindexLast = this.Previous; var height = Height; if (pindexLast == null) { return(nProofOfWorkLimit); } // Only change once per interval if ((height) % consensus.DifficultyAdjustmentInterval != 0) { if (consensus.PowAllowMinDifficultyBlocks) { // Special difficulty rule for testnet: // If the new block's timestamp is more than 2* 10 minutes // then allow mining of a min-difficulty block. if (this.Header.BlockTime > pindexLast.Header.BlockTime + TimeSpan.FromTicks(consensus.PowTargetSpacing.Ticks * 2)) { return(nProofOfWorkLimit); } else { // Return the last non-special-min-difficulty-rules-block ChainedBlock pindex = pindexLast; while (pindex.Previous != null && (pindex.Height % consensus.DifficultyAdjustmentInterval) != 0 && pindex.Header.Bits == nProofOfWorkLimit) { pindex = pindex.Previous; } return(pindex.Header.Bits); } } return(pindexLast.Header.Bits); } long pastHeight = 0; if (consensus.LitecoinWorkCalculation) { long blockstogoback = consensus.DifficultyAdjustmentInterval - 1; if ((pindexLast.Height + 1) != consensus.DifficultyAdjustmentInterval) { blockstogoback = consensus.DifficultyAdjustmentInterval; } pastHeight = pindexLast.Height - blockstogoback; } else { // Go back by what we want to be 14 days worth of blocks pastHeight = pindexLast.Height - (consensus.DifficultyAdjustmentInterval - 1); } ChainedBlock pindexFirst = this.EnumerateToGenesis().FirstOrDefault(o => o.Height == pastHeight); assert(pindexFirst); if (consensus.PowNoRetargeting) { return(pindexLast.Header.Bits); } // Limit adjustment step var nActualTimespan = pindexLast.Header.BlockTime - pindexFirst.Header.BlockTime; if (nActualTimespan < TimeSpan.FromTicks(consensus.PowTargetTimespan.Ticks / 4)) { nActualTimespan = TimeSpan.FromTicks(consensus.PowTargetTimespan.Ticks / 4); } if (nActualTimespan > TimeSpan.FromTicks(consensus.PowTargetTimespan.Ticks * 4)) { nActualTimespan = TimeSpan.FromTicks(consensus.PowTargetTimespan.Ticks * 4); } // Retarget var bnNew = pindexLast.Header.Bits.ToBigInteger(); bnNew = bnNew.Multiply(BigInteger.ValueOf((long)nActualTimespan.TotalSeconds)); bnNew = bnNew.Divide(BigInteger.ValueOf((long)consensus.PowTargetTimespan.TotalSeconds)); var newTarget = new Target(bnNew); if (newTarget > nProofOfWorkLimit) { newTarget = nProofOfWorkLimit; } return(newTarget); }
public bool CheckProofOfWorkAndTarget(Consensus consensus) { AssertHasHeader(); return(Height == 0 || (Header.CheckProofOfWork() && Header.Bits == GetWorkRequired(consensus))); }
/// <summary> /// 通过Akka框架通知共识服务开始工作 /// </summary> /// <param name="wallet">钱包对象</param> public void StartConsensus(Wallet wallet) { Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, wallet)); Consensus.Tell(new ConsensusService.Start()); }
public Target GetNextWorkRequired(BlockHeader block, Consensus consensus) { return(new ChainedBlock(block, block.GetHash(), this).GetWorkRequired(consensus)); }
public static Target GetNextTargetRequired(ChainedBlock indexLast, Consensus consensus, bool proofOfStake) { // Genesis block if (indexLast == null) { return(consensus.PowLimit); } // find the last two blocks that correspond to the mining algo // (i.e if this is a POS block we need to find the last two POS blocks) var targetLimit = proofOfStake ? GetProofOfStakeLimit(consensus, indexLast.Height) : consensus.PowLimit.ToBigInteger(); // first block var pindexPrev = GetLastBlockIndex(indexLast, proofOfStake); if (pindexPrev.Previous == null) { return(new Target(targetLimit)); } // second block var pindexPrevPrev = GetLastBlockIndex(pindexPrev.Previous, proofOfStake); if (pindexPrevPrev == null) { return(new Target(targetLimit)); } int targetSpacing = GetTargetSpacing(indexLast.Height); int actualSpacing = (int)(pindexPrev.Header.Time - pindexPrevPrev.Header.Time); if (IsProtocolV1RetargetingFixed(indexLast.Height)) { if (actualSpacing < 0) { actualSpacing = targetSpacing; } } if (IsProtocolV3((int)indexLast.Header.Time)) { if (actualSpacing > targetSpacing * 10) { actualSpacing = targetSpacing * 10; } } // target change every block // retarget with exponential moving toward target spacing var targetTimespan = 16 * 60; // 16 mins var target = pindexPrev.Header.Bits.ToBigInteger(); int interval = targetTimespan / targetSpacing; target *= ((interval - 1) * targetSpacing + actualSpacing + actualSpacing); target /= ((interval + 1) * targetSpacing); if (target <= 0 || target > targetLimit) { target = targetLimit; } return(new Target(target)); }
private static System.Numerics.BigInteger GetProofOfStakeLimit(Consensus consensus, int height) { return(IsProtocolV2(height) ? consensus.ProofOfStakeLimitV2 : consensus.ProofOfStakeLimit); }
public void IsBip112EnabledTest(int height, bool expected) { Consensus cs = new Consensus(height, NetworkType.MainNet); Assert.Equal(expected, cs.IsBip112Enabled); }
public BlockHeader(byte[] data, Consensus consensus) : this(data, consensus?.ConsensusFactory ?? throw new ArgumentNullException(nameof(consensus))) { }
public void StartConsensus() { Consensus = ActorSystem.ActorOf(ConsensusService.Props(this, this._hostEnv, this._hub, this.LocalNode, TheBlockchain)); Consensus.Tell(new ConsensusService.Startup { }, TheBlockchain); }
public void Load(byte[] chain, Consensus consensus, ChainSerializationFormat format) { Load(new MemoryStream(chain), consensus, format); }
public NetworkBuilder SetConsensus(Consensus consensus) { _consensus = consensus == null ? null : consensus.Clone(); return(this); }
public ConcurrentChain(byte[] bytes, Consensus consensus) : this(bytes, consensus, null) { }
public StratisTest() { // 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] = 0x71; messageStart[1] = 0x31; messageStart[2] = 0x21; messageStart[3] = 0x11; uint magic = BitConverter.ToUInt32(messageStart, 0); // 0x11213171; this.Name = "StratisTest"; this.Magic = magic; this.DefaultPort = 26178; this.RPCPort = 26174; this.CoinTicker = "TSTRAT"; var consensus = new Consensus(); consensus.SubsidyHalvingInterval = 210000; consensus.MajorityEnforceBlockUpgrade = 750; consensus.MajorityRejectBlockOutdated = 950; consensus.MajorityWindow = 1000; consensus.BuriedDeployments[BuriedDeployments.BIP34] = 0; consensus.BuriedDeployments[BuriedDeployments.BIP65] = 0; consensus.BuriedDeployments[BuriedDeployments.BIP66] = 0; consensus.BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"); 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.LastPOWBlock = 12500; consensus.IsProofOfStake = true; consensus.ConsensusFactory = new PosConsensusFactory() { Consensus = consensus }; consensus.ProofOfStakeLimit = new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)); consensus.ProofOfStakeLimitV2 = new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)); consensus.CoinType = 105; consensus.PremineReward = Money.Coins(98000000); consensus.PremineHeight = 2; consensus.ProofOfWorkReward = Money.Coins(4); consensus.ProofOfStakeReward = Money.COIN; consensus.MaxReorgLength = 500; consensus.MaxMoney = long.MaxValue; // StratisTest consensus differences consensus.PowLimit = new Target(new uint256("0000ffff00000000000000000000000000000000000000000000000000000000")); consensus.DefaultAssumeValid = new uint256("0x98fa6ef0bca5b431f15fd79dc6f879dc45b83ed4b1bbe933a383ef438321958e"); // 372652 consensus.CoinbaseMaturity = 10; this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (65) }; this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (196) }; this.Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (65 + 128) }; this.Checkpoints = new Dictionary <int, CheckpointInfo> { { 0, new CheckpointInfo(new uint256("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, { 2, new CheckpointInfo(new uint256("0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"), new uint256("0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02")) }, { 50000, new CheckpointInfo(new uint256("0xb42c18eacf8fb5ed94eac31943bd364451d88da0fd44cc49616ffea34d530ad4"), new uint256("0x824934ddc5f935e854ac59ae7f5ed25f2d29a7c3914cac851f3eddb4baf96d78")) }, { 100000, new CheckpointInfo(new uint256("0xf9e2f7561ee4b92d3bde400d251363a0e8924204c326da7f4ad9ccc8863aad79"), new uint256("0xdef8d92d20becc71f662ee1c32252aca129f1bf4744026b116d45d9bfe67e9fb")) }, { 150000, new CheckpointInfo(new uint256("0x08b7c20a450252ddf9ce41dbeb92ecf54932beac9090dc8250e933ad3a175381"), new uint256("0xf05dad15f733ae0acbd34adc449be9429099dbee5fa9ecd8e524cf28e9153adb")) }, { 200000, new CheckpointInfo(new uint256("0x8609cc873222a0573615788dc32e377b88bfd6a0015791f627d969ee3a415115"), new uint256("0xfa28c1f20a8162d133607c6a1c8997833befac3efd9076567258a7683ac181fa")) }, { 250000, new CheckpointInfo(new uint256("0xdd664e15ac679a6f3b96a7176303956661998174a697ad8231f154f1e32ff4a3"), new uint256("0x19fc0fa29418f8b19cbb6557c1c79dfd0eff6779c0eaaec5d245c5cdf3c96d78")) }, { 300000, new CheckpointInfo(new uint256("0x2409eb5ae72c80d5b37c77903d75a8e742a33843ab633935ce6e5264db962e23"), new uint256("0xf5ec7af55516b8e264ed280e9a5dba0180a4a9d3713351bfea275b18f3f1514e")) }, { 350000, new CheckpointInfo(new uint256("0x36811041e9060f4b4c26dc20e0850dca5efaabb60618e3456992e9c0b1b2120e"), new uint256("0xbfda55ef0756bcee8485e15527a2b8ca27ca877aa09c88e363ef8d3253cdfd1c")) }, { 400000, new CheckpointInfo(new uint256("0xb6abcb933d3e3590345ca5d3abb697461093313f8886568ac8ae740d223e56f6"), new uint256("0xfaf5fcebee3ec0df5155393a99da43de18b12e620fef5edb111a791ecbfaa63a")) } }; this.DNSSeeds = new List <DNSSeedData> { new DNSSeedData("testnet1.stratisplatform.com", "testnet1.stratisplatform.com"), new DNSSeedData("testnet2.stratisplatform.com", "testnet2.stratisplatform.com"), new DNSSeedData("testnet3.stratisplatform.com", "testnet3.stratisplatform.com"), new DNSSeedData("testnet4.stratisplatform.com", "testnet4.stratisplatform.com") }; this.SeedNodes = new List <NetworkAddress> { new NetworkAddress(IPAddress.Parse("51.140.231.125"), this.DefaultPort), // danger cloud node new NetworkAddress(IPAddress.Parse("13.70.81.5"), 3389), // beard cloud node new NetworkAddress(IPAddress.Parse("191.235.85.131"), 3389), // fassa cloud node new NetworkAddress(IPAddress.Parse("52.232.58.52"), 26178), // neurosploit public node }; // Create the genesis block. this.GenesisTime = 1470467000; this.GenesisNonce = 1831645; this.GenesisBits = 0x1e0fffff; this.GenesisVersion = 1; this.GenesisReward = Money.Zero; this.Genesis = CreateStratisGenesisBlock(consensus.ConsensusFactory, this.GenesisTime, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward); this.Genesis.Header.Time = 1493909211; this.Genesis.Header.Nonce = 2433759; this.Genesis.Header.Bits = consensus.PowLimit; consensus.HashGenesisBlock = this.Genesis.GetHash(); this.Consensus = consensus; Assert(this.Consensus.HashGenesisBlock == uint256.Parse("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9")); }
public DeploymentFlags(ChainedHeader nextBlock, ThresholdState[] prevBlockStates, Consensus chainparams, ConcurrentChain chain) { // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. // If such overwrites are allowed, coinbases and transactions depending upon those // can be duplicated to remove the ability to spend the first instance -- even after // being sent to another address. // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information. // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool // already refuses previously-known transaction ids entirely. // This rule was originally applied to all blocks with a timestamp after March 15, 2012, 0:00 UTC. // Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the // two in the chain that violate it. This prevents exploiting the issue against nodes during their // initial block download. this.EnforceBIP30 = (nextBlock.HashBlock == null) || // Enforce on CreateNewBlock invocations which don't have a hash. !((nextBlock.Height == 91842 && nextBlock.HashBlock == new uint256("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) || (nextBlock.Height == 91880 && nextBlock.HashBlock == new uint256("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"))); // Once BIP34 activated it was not possible to create new duplicate coinbases and thus other than starting // with the 2 existing duplicate coinbase pairs, not possible to create overwriting txs. But by the // time BIP34 activated, in each of the existing pairs the duplicate coinbase had overwritten the first // before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further // duplicate transactions descending from the known pairs either. // If we're on the known chain at height greater than where BIP34 activated, we can save the db accesses needed for the BIP30 check. ChainedHeader bip34HeightChainedHeader = chain.GetBlock(chainparams.BuriedDeployments[BuriedDeployments.BIP34]); //Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond. this.EnforceBIP30 = this.EnforceBIP30 && ((bip34HeightChainedHeader == null) || !(bip34HeightChainedHeader.HashBlock == chainparams.BIP34Hash)); // BIP16 didn't become active until Apr 1 2012. var nBIP16SwitchTime = Utils.UnixTimeToDateTime(1333238400); bool fStrictPayToScriptHash = (nextBlock.Header.BlockTime >= nBIP16SwitchTime); this.ScriptFlags = fStrictPayToScriptHash ? ScriptVerify.P2SH : ScriptVerify.None; // Start enforcing the DERSIG (BIP66) rule. if (nextBlock.Height >= chainparams.BuriedDeployments[BuriedDeployments.BIP66]) { this.ScriptFlags |= ScriptVerify.DerSig; } // Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4 // blocks, when 75% of the network has upgraded. if (nextBlock.Height >= chainparams.BuriedDeployments[BuriedDeployments.BIP65]) { this.ScriptFlags |= ScriptVerify.CheckLockTimeVerify; } // Start enforcing BIP68 (sequence locks), BIP112 (CHECKSEQUENCEVERIFY) and BIP113 (Median Time Past) using versionbits logic. if (prevBlockStates[(int)BIP9Deployments.CSV] == ThresholdState.Active) { this.ScriptFlags |= ScriptVerify.CheckSequenceVerify; this.LockTimeFlags |= Transaction.LockTimeFlags.VerifySequence; this.LockTimeFlags |= Transaction.LockTimeFlags.MedianTimePast; } // Start enforcing WITNESS rules using versionbits logic. if (prevBlockStates[(int)BIP9Deployments.Segwit] == ThresholdState.Active) { this.ScriptFlags |= ScriptVerify.Witness; } // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height if (nextBlock.Height >= chainparams.BuriedDeployments[BuriedDeployments.BIP34]) { this.EnforceBIP34 = true; } }
// only need for the Base58 addresses in Blockexplorer, // the rest is not even accurate for Obsidian! public static Network ObsidianMain() { if (_mainnet != null) { return(_mainnet); } NetworkConfig.UseSingleNetwork = true; // fix Block.BlockSignature = true; // ? Transaction.TimeStamp = true; // ? NetworkBuilder builder = new NetworkBuilder(); Block mainGenesisBlock = CreateGenesisBlock(nTime: 1503532800, nNonce: 36151509, nBits: 0x1e0fffff, nVersion: 1, genesisReward: Money.Zero); var odnMainConsensus = new Consensus { SubsidyHalvingInterval = 210000, MajorityEnforceBlockUpgrade = 750, MajorityRejectBlockOutdated = 950, MajorityWindow = 1000, BIP34Hash = null, PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60), // two weeks, 20160 minutes PowTargetSpacing = TimeSpan.FromSeconds(10 * 60), // 10 minutes PowAllowMinDifficultyBlocks = false, PowNoRetargeting = false, RuleChangeActivationThreshold = 1916, // 95% of 2016 MinerConfirmationWindow = 2016, // nPowTargetTimespan / nPowTargetSpacing CoinbaseMaturity = 100, HashGenesisBlock = mainGenesisBlock.GetHash(), GetPoWHash = null, LitecoinWorkCalculation = false, // PoS LastPOWBlock = 12500, ProofOfStakeLimit = new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)), ProofOfStakeLimitV2 = new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)) }; odnMainConsensus.BIP34Hash = odnMainConsensus.HashGenesisBlock; odnMainConsensus.BuriedDeployments[BuriedDeployments.BIP34] = 227931; odnMainConsensus.BuriedDeployments[BuriedDeployments.BIP65] = 388381; odnMainConsensus.BuriedDeployments[BuriedDeployments.BIP66] = 363725; odnMainConsensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 1199145601, 1230767999); odnMainConsensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1462060800, 1493596800); odnMainConsensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 0, 0); // Start copied from StratisMain var pchMessageStart = new byte[4]; pchMessageStart[0] = 0x70; pchMessageStart[1] = 0x35; pchMessageStart[2] = 0x22; pchMessageStart[3] = 0x05; var magic = BitConverter.ToUInt32(pchMessageStart, 0); //0x5223570; // End copied from StratisMain _mainnet = builder.SetConsensus(odnMainConsensus) .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (75) }) // ODN / X .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { (125) }) .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { (75 + 128) }) // ODN .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") // bc? .SetMagic(magic) .SetPort(0) .SetRPCPort(0) .SetName("odn-main") .AddAlias("odn-mainnet") .AddAlias("obsidian-main") .AddAlias("obsidian-mainnet") .AddDNSSeeds(new DNSSeedData[] { //new DNSSeedData("obsidianseednode1.westeurope.cloudapp.azure.com", "obsidianseednode1.westeurope.cloudapp.azure.com") }) .SetGenesis(mainGenesisBlock) .BuildAndRegister(); return(_mainnet); }
public void StartConsensus(Wallet wallet) { Consensus = ActorSystem.ActorOf(ConsensusService.Props(this, wallet)); Consensus.Tell(new ConsensusService.Start()); }
public void AddTransaction(Consensus consensus, Transaction tx, int height) { SetCoins(tx.GetHash(), new Coins(tx, height)); }
internal static int GetBlocksCount(Consensus consensus, int minutes) { return((int)Math.Ceiling((double)TimeSpan.FromMinutes(minutes).Ticks / consensus.PowTargetSpacing.Ticks)); }
public ThresholdConditionCache(Consensus consensus) { Guard.NotNull(consensus, nameof(consensus)); this.consensus = consensus; }
public StandardCycles(Consensus consensus, bool debug) { _Debug = debug; _Shorty = new StandardCycle() { FriendlyName = "Shorty", Consensus = consensus, Denomination = Money.Coins(0.01m), Generator = new OverlappedCycleGenerator() { RegistrationOverlap = 1, FirstCycle = new CycleParameters() { Start = 1, RegistrationDuration = GetBlocksCount(consensus, 20) + 1, SafetyPeriodDuration = GetBlocksCount(consensus, 10), ClientChannelEstablishmentDuration = GetBlocksCount(consensus, 20), TumblerChannelEstablishmentDuration = GetBlocksCount(consensus, 20), PaymentPhaseDuration = GetBlocksCount(consensus, 20), TumblerCashoutDuration = GetBlocksCount(consensus, 40), ClientCashoutDuration = GetBlocksCount(consensus, 20), } } }; _Shorty2x = new StandardCycle() { FriendlyName = "Shorty2x", Consensus = consensus, Denomination = Money.Coins(0.001m), Generator = new OverlappedCycleGenerator() { RegistrationOverlap = 1, FirstCycle = new CycleParameters() { Start = 1, RegistrationDuration = GetBlocksCount(consensus, 20 * 2) + 1, SafetyPeriodDuration = GetBlocksCount(consensus, 10), ClientChannelEstablishmentDuration = GetBlocksCount(consensus, 20 * 4), TumblerChannelEstablishmentDuration = GetBlocksCount(consensus, 20 * 4), PaymentPhaseDuration = GetBlocksCount(consensus, 20 * 2), TumblerCashoutDuration = GetBlocksCount(consensus, 40 * 2), ClientCashoutDuration = GetBlocksCount(consensus, 20 * 2), } } }; _Kotori = new StandardCycle() { FriendlyName = "Kotori", Consensus = consensus, Denomination = Money.Coins(0.001m), Generator = new OverlappedCycleGenerator() { RegistrationOverlap = 1, FirstCycle = new CycleParameters() { Start = 0, //one cycle per day RegistrationDuration = GetBlocksCount(consensus, 60 * 4) + 1, //make sure tor circuit get renewed SafetyPeriodDuration = GetBlocksCount(consensus, 20), ClientChannelEstablishmentDuration = GetBlocksCount(consensus, 120), TumblerChannelEstablishmentDuration = GetBlocksCount(consensus, 120), PaymentPhaseDuration = GetBlocksCount(consensus, 30), TumblerCashoutDuration = GetBlocksCount(consensus, 5 * 60), ClientCashoutDuration = GetBlocksCount(consensus, 5 * 60) } } }; if (!_Debug) { //Verify that 2 phases are always at least separated by 20 minutes foreach (var standard in ToEnumerable()) { HashSet <uint256> states = new HashSet <uint256>(); var start = standard.Generator.FirstCycle.Start; var periods = standard.Generator.FirstCycle.GetPeriods(); var nonOverlappedPart = periods.Registration.End - periods.Registration.Start - standard.Generator.RegistrationOverlap; var total = periods.Total.End - periods.Total.Start; var maxOverlapped = Math.Ceiling((decimal)total / (decimal)nonOverlappedPart); for (int i = start;; i += nonOverlappedPart) { var starts = standard.Generator.GetCycles(i) .SelectMany(c => { var p = c.GetPeriods(); return(new[] { p.Registration.Start, p.ClientChannelEstablishment.Start, p.TumblerChannelEstablishment.Start, p.TumblerCashout.Start, p.ClientCashout.Start }); }).OrderBy(c => c).ToArray(); for (int ii = 1; ii < starts.Length; ii++) { //if(starts[ii] - starts[ii - 1] < GetBlocksCount(consensus, 20)) // throw new InvalidOperationException("A standard cycle generator generates cycles which overlap too much"); } //Check if it is a we already checked such state module total for (int ii = 0; ii < starts.Length; ii++) { starts[ii] = starts[ii] % total; } MemoryStream ms = new MemoryStream(); BitcoinStream bs = new BitcoinStream(ms, true); bs.ReadWrite(ref starts); if (!states.Add(Hashes.Hash256(ms.ToArray()))) { break; } } } } }
public BlockHeader(string hex, Consensus consensus) : this(hex, consensus?.ConsensusFactory ?? throw new ArgumentNullException(nameof(consensus))) { }
public AMSMain() { NetworkType = NetworkType.Mainnet; DefaultConfigFilename = AMSSetup.ConfigFileName; // The default name used for the AMS configuration file. Name = AMSSetup.Main.Name; CoinTicker = AMSSetup.Main.CoinTicker; Magic = ConversionTools.ConvertToUInt32(AMSSetup.Magic); RootFolderName = AMSSetup.Main.RootFolderName; DefaultPort = AMSSetup.Main.DefaultPort; DefaultRPCPort = AMSSetup.Main.DefaultRPCPort; DefaultAPIPort = AMSSetup.Main.DefaultAPIPort; DefaultMaxOutboundConnections = 16; DefaultMaxInboundConnections = 109; MaxTipAge = 2 * 60 * 60; MinTxFee = 50000; FallbackFee = 50000; MinRelayTxFee = 50000; MaxTimeOffsetSeconds = 25 * 60; DefaultBanTimeSeconds = 16000; // 500 (MaxReorg) * 64 (TargetSpacing) / 2 = 4 hours, 26 minutes and 40 seconds var consensusFactory = new PosConsensusFactory(); Block genesisBlock = CreateGenesisBlock(consensusFactory, AMSSetup.Main.GenesisTime, AMSSetup.Main.GenesisNonce, AMSSetup.Main.GenesisBits, AMSSetup.Main.GenesisVersion, AMSSetup.Main.GenesisReward, AMSSetup.GenesisText); Genesis = genesisBlock; // Taken from StratisX. var consensusOptions = new PosConsensusOptions { MaxBlockBaseSize = 1_000_000, MaxStandardVersion = 2, MaxStandardTxWeight = 100_000, MaxBlockSigopsCost = 20_000, MaxStandardTxSigopsCost = 20_000 / 5, WitnessScaleFactor = 4 }; var buriedDeployments = new BuriedDeploymentsArray { [BuriedDeployments.BIP34] = 0, [BuriedDeployments.BIP65] = 0, [BuriedDeployments.BIP66] = 0 }; Consensus = new Consensus( consensusFactory: consensusFactory, consensusOptions: consensusOptions, coinType: AMSSetup.CoinType, hashGenesisBlock: genesisBlock.GetHash(), subsidyHalvingInterval: 250000, majorityEnforceBlockUpgrade: 750, majorityRejectBlockOutdated: 950, majorityWindow: 1000, buriedDeployments: buriedDeployments, bip9Deployments: new NoBIP9Deployments(), bip34Hash: null, minerConfirmationWindow: 2016, // nPowTargetTimespan / nPowTargetSpacing maxReorgLength: 500, defaultAssumeValid: null, maxMoney: long.MaxValue, coinbaseMaturity: 50, premineHeight: 2, premineReward: Money.Coins(AMSSetup.PremineReward), proofOfWorkReward: Money.Coins(AMSSetup.PoWBlockReward), targetTimespan: TimeSpan.FromSeconds(14 * 24 * 60 * 60), // two weeks targetSpacing: AMSSetup.TargetSpacing, powAllowMinDifficultyBlocks: false, posNoRetargeting: false, powNoRetargeting: false, powLimit: new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), minimumChainWork: null, isProofOfStake: true, lastPowBlock: AMSSetup.LastPowBlock, proofOfStakeLimit: new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)), proofOfStakeLimitV2: new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)), proofOfStakeReward: Money.Coins(AMSSetup.PoSBlockReward), proofOfStakeTimestampMask: AMSSetup.ProofOfStakeTimestampMask ); Consensus.PosEmptyCoinbase = AMSSetup.IsPoSv3(); Consensus.PosUseTimeFieldInKernalHash = AMSSetup.IsPoSv3(); // TODO: Set your Base58Prefixes Base58Prefixes = new byte[12][]; Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (AMSSetup.Main.PubKeyAddress) }; Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (AMSSetup.Main.ScriptAddress) }; Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (AMSSetup.Main.SecretAddress) }; 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 }; Bech32Encoders = new Bech32Encoder[2]; var encoder = new Bech32Encoder(AMSSetup.Main.CoinTicker.ToLowerInvariant()); Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder; Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder; Checkpoints = AMSSetup.Main.Checkpoints; DNSSeeds = AMSSetup.Main.DNS; SeedNodes = AMSSetup.Main.Nodes; StandardScriptsRegistry = new AMSStandardScriptsRegistry(); // 64 below should be changed to TargetSpacingSeconds when we move that field. Assert(DefaultBanTimeSeconds <= Consensus.MaxReorgLength * 64 / 2); Assert(Consensus.HashGenesisBlock == uint256.Parse(AMSSetup.Main.HashGenesisBlock)); Assert(Genesis.Header.HashMerkleRoot == uint256.Parse(AMSSetup.Main.HashMerkleRoot)); RegisterRules(Consensus); RegisterMempoolRules(Consensus); }
[InlineData(600000, 4)] // BIP-65 public void MinBlockVersion(int height, int expected) { Consensus cs = new Consensus(height, NetworkType.MainNet); Assert.Equal(expected, cs.MinBlockVersion); }