forked from MetacoSA/NBitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gobyte.cs
210 lines (209 loc) · 9.53 KB
/
Gobyte.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using NBitcoin;
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;
using System.Threading.Tasks;
namespace NBitcoin.Altcoins
{
public class GoByte : NetworkSetBase
{
public static GoByte Instance { get; } = new GoByte();
public override string CryptoCode => "GBX";
private GoByte()
{
}
public class GoByteConsensusFactory : ConsensusFactory
{
private GoByteConsensusFactory()
{
}
public static GoByteConsensusFactory Instance { get; } = new GoByteConsensusFactory();
public override BlockHeader CreateBlockHeader()
{
return new GoByteBlockHeader();
}
public override Block CreateBlock()
{
return new GoByteBlock(new GoByteBlockHeader());
}
}
#pragma warning disable CS0618 // Type or member is obsolete
public class GoByteBlockHeader : BlockHeader
{
static byte[] CalculateHash(byte[] data, int offset, int count)
{
// TODO: change the hash algorithm
return new HashX11.X11().ComputeBytes(data.Skip(offset).Take(count).ToArray());
}
protected override HashStreamBase CreateHashStream()
{
return BufferedHashStream.CreateFrom(CalculateHash, 80);
}
}
public class GoByteBlock : Block
{
#pragma warning disable CS0612 // Type or member is obsolete
public GoByteBlock(GoByteBlockHeader h) : base(h)
#pragma warning restore CS0612 // Type or member is obsolete
{
}
public override ConsensusFactory GetConsensusFactory()
{
return GoByteConsensusFactory.Instance;
}
}
#pragma warning restore CS0618 // Type or member is obsolete
protected override void PostInit()
{
RegisterDefaultCookiePath("GoByteCore");
}
static uint256 GetPoWHash(BlockHeader header)
{
var headerBytes = header.ToBytes();
var h = NBitcoin.Crypto.SCrypt.ComputeDerivedKey(headerBytes, headerBytes, 1024, 1, 1, null, 32);
return new uint256(h);
}
protected override NetworkBuilder CreateMainnet()
{
var builder = new NetworkBuilder();
builder.SetConsensus(new Consensus()
{
SubsidyHalvingInterval = 210240, // one year
MajorityEnforceBlockUpgrade = 750,
MajorityRejectBlockOutdated = 950,
MajorityWindow = 1000,
BIP34Hash = new uint256("0x00000c8a1ff01bae3f3875c81cb14115429af5744643b34b4ad1cbb7d2d59ca2"),
PowLimit = new Target(new uint256("00000fffff000000000000000000000000000000000000000000000000000000")),
MinimumChainWork = new uint256("00000fffff000000000000000000000000000000000000000000000000000000"),
PowTargetTimespan = TimeSpan.FromSeconds(60 * 60),
PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60),
PowAllowMinDifficultyBlocks = false,
CoinbaseMaturity = 100,
PowNoRetargeting = false,
RuleChangeActivationThreshold = 1916, // 95% of 2016
MinerConfirmationWindow = 2016,
ConsensusFactory = GoByteConsensusFactory.Instance,
SupportSegwit = false
}) // done
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 38 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 10 })
.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 198 })
.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("gobyte"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("gobyte"))
.SetMagic(0xD4C3B21A)
.SetPort(12455)
.SetRPCPort(12454)
.SetMaxP2PVersion(70209)
.SetName("gobyte-main")
.AddAlias("gobyte-mainnet")
.AddDNSSeeds(new[]
{
new DNSSeedData("seed1.gobyte.network", "seed1.gobyte.network"),
new DNSSeedData("seed2.gobyte.network", "seed2.gobyte.network"),
new DNSSeedData("seed3.gobyte.network", "seed3.gobyte.network"),
new DNSSeedData("seed4.gobyte.network", "seed4.gobyte.network"),
new DNSSeedData("seed5.gobyte.network", "seed5.gobyte.network"),
new DNSSeedData("seed6.gobyte.network", "seed6.gobyte.network"),
new DNSSeedData("seed7.gobyte.network", "seed7.gobyte.network"),
new DNSSeedData("seed8.gobyte.network", "seed8.gobyte.network"),
new DNSSeedData("seed9.gobyte.network", "seed9.gobyte.network"),
new DNSSeedData("seed10.gobyte.network", "seed10.gobyte.network")
}) // done
.AddSeeds(new NetworkAddress[0])
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000219f39f283f43185a0ef69cba1702151ab0cf02454a57e1039dabcc19d719adc00b60d5af0ff0f1e6fe618000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4204ffff001d01043a5468652053746172204d616c61797369612031377468204e6f76656d626572203230313720476f427974652047656e65736973205265626f726effffffff0100f2052a010000004341043e5a5fbfbb2caa5f4b7c8fd24d890d6c244de254d579b5ba629f64c1b48275f59e0e1c834a60f6ffb4aaa022aaa4866434ca729a12465f80618fb2070045cb16ac00000000");
return builder;
}
protected override NetworkBuilder CreateTestnet()
{
var builder = new NetworkBuilder();
builder.SetConsensus(new Consensus()
{
SubsidyHalvingInterval = 210240,
MajorityEnforceBlockUpgrade = 51,
MajorityRejectBlockOutdated = 75,
MajorityWindow = 100,
BIP34Hash = new uint256("0x0000064a72bc327f2c93169784623348d8ad8975873563a2c3e0e1deb6bcc9f7"),
PowLimit = new Target(new uint256("0x00000fffff000000000000000000000000000000000000000000000000000000")),
MinimumChainWork = new uint256("0x000000000000000000000000000000000000000000000000000006a96dd9119d"),
PowTargetTimespan = TimeSpan.FromSeconds(60 * 60),
PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60),
PowAllowMinDifficultyBlocks = true,
CoinbaseMaturity = 100,
PowNoRetargeting = false,
RuleChangeActivationThreshold = 1512,
MinerConfirmationWindow = 2016,
ConsensusFactory = GoByteConsensusFactory.Instance,
SupportSegwit = false
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 112 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 20 })
.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("tgobyte"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("tgobyte"))
.SetMagic(0xFFCAE2CE)
.SetPort(13455)
.SetRPCPort(13454)
.SetMaxP2PVersion(70209)
.SetName("gobyte-test")
.AddAlias("gobyte-testnet")
.AddDNSSeeds(new[]
{
new DNSSeedData("gobyte.network", "testnet-dns.gobyte.network"),
new DNSSeedData("gobyte.network", "testnet2-dns.gobyte.network")
})
.AddSeeds(new NetworkAddress[0])
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000219f39f283f43185a0ef69cba1702151ab0cf02454a57e1039dabcc19d719adc20de0b5af0ff0f1ebbc02d000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4204ffff001d01043a5468652053746172204d616c61797369612031377468204e6f76656d626572203230313720476f427974652047656e65736973205265626f726effffffff0100f2052a010000004341043e5a5fbfbb2caa5f4b7c8fd24d890d6c244de254d579b5ba629f64c1b48275f59e0e1c834a60f6ffb4aaa022aaa4866434ca729a12465f80618fb2070045cb16ac00000000");
return builder;
}
protected override NetworkBuilder CreateRegtest()
{
var builder = new NetworkBuilder();
builder.SetConsensus(new Consensus()
{
SubsidyHalvingInterval = 150,
MajorityEnforceBlockUpgrade = 750,
MajorityRejectBlockOutdated = 950,
MajorityWindow = 1000,
BIP34Hash = new uint256(),
PowLimit = new Target(new uint256("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),
MinimumChainWork = new uint256("0x000000000000000000000000000000000000000000000000000924e924a21715"),
PowTargetTimespan = TimeSpan.FromSeconds(24 * 60 * 60),
PowTargetSpacing = TimeSpan.FromSeconds(2.5 * 60),
PowAllowMinDifficultyBlocks = true,
CoinbaseMaturity = 100,
PowNoRetargeting = true,
RuleChangeActivationThreshold = 108,
MinerConfirmationWindow = 144,
ConsensusFactory = GoByteConsensusFactory.Instance,
SupportSegwit = false
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 112 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 20 })
.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 240 })
.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("tgobyte"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("tgobyte"))
.SetMagic(0x7BD5B3A1)
.SetPort(13565)
.SetRPCPort(13564)
.SetMaxP2PVersion(70209)
.SetName("gobyte-reg")
.AddAlias("gobyte-regtest")
.AddDNSSeeds(new DNSSeedData[0])
.AddSeeds(new NetworkAddress[0])
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000219f39f283f43185a0ef69cba1702151ab0cf02454a57e1039dabcc19d719adcbcdd0b5af0ff0f1e63c00d000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4204ffff001d01043a5468652053746172204d616c61797369612031377468204e6f76656d626572203230313720476f427974652047656e65736973205265626f726effffffff0100f2052a010000004341043e5a5fbfbb2caa5f4b7c8fd24d890d6c244de254d579b5ba629f64c1b48275f59e0e1c834a60f6ffb4aaa022aaa4866434ca729a12465f80618fb2070045cb16ac00000000");
return builder;
}
}
}