-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainNet.cs
185 lines (171 loc) · 9.44 KB
/
MainNet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChainParams.Configuration;
using ChainParams.Rules;
using NBitcoin;
using NBitcoin.BouncyCastle.math;
using NBitcoin.DataEncoders;
using UnnamedCoin.Bitcoin.Features.Consensus.Rules.CommonRules;
using UnnamedCoin.Bitcoin.Features.Consensus.Rules.ProvenHeaderRules;
using UnnamedCoin.Bitcoin.Features.MemoryPool.Rules;
namespace ChainParams
{
public class MainNet : Network
{
public MainNet()
{
this.Name = nameof(MainNet);
this.CoinTicker = "XDS";
this.RootFolderName = "xds";
this.DefaultConfigFilename = "xds.conf";
this.Magic = 0x58445331;
this.DefaultPort = 38333;
this.DefaultRPCPort = 48333;
this.DefaultAPIPort = 48334;
this.DefaultMaxOutboundConnections = 16;
this.DefaultMaxInboundConnections = 109;
this.MaxTimeOffsetSeconds = 25 * 60;
this.DefaultBanTimeSeconds = 8000;
this.MaxTipAge = DateTime.UtcNow > new DateTime(2020, 1, 2, 23, 56, 00, DateTimeKind.Utc).AddDays(30) ? 2 * 60 * 60 : (int)TimeSpan.FromDays(30).TotalSeconds;
this.MinTxFee = Money.Coins(0.00001m).Satoshi;
this.FallbackFee = this.MinTxFee;
this.MinRelayTxFee = this.MinTxFee;
this.AbsoluteMinTxFee = Money.Coins(0.01m).Satoshi;
var consensusFactory = new MainNetConsensusFactory();
this.GenesisTime = Utils.DateTimeToUnixTime(new DateTime(2020, 1, 2, 23, 56, 00, DateTimeKind.Utc));
this.GenesisNonce = 15118976;
this.GenesisBits = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
this.GenesisVersion = 1;
this.GenesisReward = Money.Zero;
this.Genesis = consensusFactory.ComputeGenesisBlock(this.GenesisTime, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward);
var consensusOptions = new MainNetConsensusOptions(
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
};
var bip9Deployments = new MainNetBIP9DeploymentsArray
{
[MainNetBIP9DeploymentsArray.ColdStaking] = new BIP9DeploymentsParameters("ColdStaking", 27, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive),
[MainNetBIP9DeploymentsArray.CSV] = new BIP9DeploymentsParameters("CSV", 0, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive),
[MainNetBIP9DeploymentsArray.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive)
};
this.Consensus = new Consensus(
consensusFactory: consensusFactory,
consensusOptions: consensusOptions,
coinType: (int)this.GenesisNonce,
hashGenesisBlock: this.Genesis.GetHash(),
subsidyHalvingInterval: 210_000,
majorityEnforceBlockUpgrade: 750,
majorityRejectBlockOutdated: 950,
majorityWindow: 1000,
buriedDeployments: buriedDeployments,
bip9Deployments: bip9Deployments,
bip34Hash: this.Genesis.GetHash(),
minerConfirmationWindow: 2016,
maxReorgLength: 125,
defaultAssumeValid: uint256.Zero,
maxMoney: long.MaxValue,
coinbaseMaturity: 50,
premineHeight: 0,
premineReward: Money.Coins(0),
proofOfWorkReward: Money.Coins(50),
powTargetTimespan: TimeSpan.FromSeconds(14 * 24 * 60 * 60),
powTargetSpacing: TimeSpan.FromSeconds(10 * 60),
powAllowMinDifficultyBlocks: false,
posNoRetargeting: false,
powNoRetargeting: false,
powLimit: new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),
minimumChainWork: null,
isProofOfStake: true,
lastPowBlock: 1_000_000_000,
proofOfStakeLimit: new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)),
proofOfStakeLimitV2: new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false)),
proofOfStakeReward: Money.Coins(50),
posEmptyCoinbase: false);
this.StandardScriptsRegistry = new MainNetStandardScriptsRegistry();
this.Base58Prefixes = new byte[12][];
this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { 0 }; // deprecated - bech32/P2WPKH is used instead
this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { 5 }; // deprecated - bech32/P2WSH is used instead
this.Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { 128 };
this.Base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_NO_EC] = new byte[] { 0x01, 0x42 };
this.Base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_EC] = new byte[] { 0x01, 0x43 };
this.Base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { 0x04, 0x88, 0xB2, 0x1E };
this.Base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { 0x04, 0x88, 0xAD, 0xE4 };
this.Base58Prefixes[(int)Base58Type.PASSPHRASE_CODE] = new byte[] { 0x2C, 0xE9, 0xB3, 0xE1, 0xFF, 0x39, 0xE2 };
this.Base58Prefixes[(int)Base58Type.CONFIRMATION_CODE] = new byte[] { 0x64, 0x3B, 0xF6, 0xA8, 0x9A };
this.Base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2a };
this.Base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 23 };
this.Base58Prefixes[(int)Base58Type.COLORED_ADDRESS] = new byte[] { 0x13 };
var encoder = new Bech32Encoder(this.CoinTicker.ToLowerInvariant());
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 = this.ConvertToNetworkAddresses(new string[0], this.DefaultPort).ToList();
RegisterRules(this.Consensus);
}
private static void RegisterRules(IConsensus consensus)
{
consensus.ConsensusRules
.Register<HeaderTimeChecksRule>()
.Register<HeaderTimeChecksPosRule>()
.Register<PosFutureDriftRule>()
.Register<CheckDifficultyPosRule>()
.Register<MainNetHeaderVersionRule>()
.Register<ProvenHeaderSizeRule>()
.Register<ProvenHeaderCoinstakeRule>()
.Register<BlockMerkleRootRule>()
.Register<PosBlockSignatureRepresentationRule>()
.Register<PosBlockSignatureRule>()
.Register<SetActivationDeploymentsPartialValidationRule>()
.Register<PosTimeMaskRule>()
.Register<MainNetRequireWitnessRule>()
.Register<MainNetEmptyScriptSigRule>()
.Register<MainNetOutputNotWhitelistedRule>()
.Register<TransactionLocktimeActivationRule>()
.Register<CoinbaseHeightActivationRule>()
.Register<WitnessCommitmentsRule>()
.Register<BlockSizeRule>()
.Register<EnsureCoinbaseRule>()
.Register<CheckPowTransactionRule>()
.Register<CheckPosTransactionRule>()
.Register<CheckSigOpsRule>()
.Register<PosCoinstakeRule>()
.Register<SetActivationDeploymentsFullValidationRule>()
.Register<CheckDifficultyHybridRule>()
.Register<LoadCoinviewRule>()
.Register<TransactionDuplicationActivationRule>()
.Register<MainNetPosCoinviewRule>()
.Register<PosColdStakingRule>()
.Register<SaveCoinviewRule>();
consensus.MempoolRules = new List<Type>
{
typeof(MainNetPreMempoolChecksMempoolRule),
typeof(CheckConflictsMempoolRule),
typeof(CheckCoinViewMempoolRule),
typeof(CreateMempoolEntryMempoolRule),
typeof(MainNetRequireWitnessMempoolRule),
typeof(MainNetEmptyScriptSigMempoolRule),
typeof(MainNetOutputNotWhitelistedMempoolRule),
typeof(CheckSigOpsMempoolRule),
typeof(MainNetCheckFeeMempoolRule),
typeof(CheckRateLimitMempoolRule),
typeof(CheckAncestorsMempoolRule),
typeof(CheckReplacementMempoolRule),
typeof(CheckAllInputsMempoolRule)
};
}
}
}