forked from MetacoSA/NBitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LBRYCredits.cs
191 lines (173 loc) · 7.75 KB
/
LBRYCredits.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
using System;
using System.Linq;
using NBitcoin.Crypto;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;
namespace NBitcoin.Altcoins
{
// Reference: https://github.com/lbryio/lbrycrd/blob/master/src/chainparams.cpp
public class LBRYCredits : NetworkSetBase
{
public static LBRYCredits Instance { get; } = new LBRYCredits();
public override string CryptoCode => "LBC";
private LBRYCredits()
{
}
public class LBRYCreditsConsensusFactory : ConsensusFactory
{
private LBRYCreditsConsensusFactory()
{
}
public static LBRYCreditsConsensusFactory Instance { get; } = new LBRYCreditsConsensusFactory();
public override BlockHeader CreateBlockHeader()
{
return new LBRYCreditsBlockHeader();
}
public override Block CreateBlock()
{
return new LBRYCreditsBlock(new LBRYCreditsBlockHeader());
}
}
#pragma warning disable CS0618 // Type or member is obsolete
public class LBRYCreditsBlockHeader : BlockHeader
{
public override uint256 GetPoWHash()
{
throw new NotSupportedException("PoW for LBC is not supported");
}
}
public class LBRYCreditsBlock : Block
{
public LBRYCreditsBlock(LBRYCreditsBlockHeader h) : base(h)
{
}
public override ConsensusFactory GetConsensusFactory()
{
return Instance.Mainnet.Consensus.ConsensusFactory;
}
}
#pragma warning restore CS0618 // Type or member is obsolete
protected override void PostInit()
{
RegisterDefaultCookiePath("LBC");
}
protected override NetworkBuilder CreateMainnet()
{
var builder = new NetworkBuilder();
builder.SetConsensus(new Consensus
{
SubsidyHalvingInterval = unchecked((int)4000000000),
MajorityEnforceBlockUpgrade = 750,
MajorityRejectBlockOutdated = 950,
MajorityWindow = 1000,
PowLimit = new Target(0 >> 1),
MinimumChainWork = new uint256("0x000000000000000000000000000000000000000000000000000a0c3931735170"),
PowTargetTimespan = TimeSpan.FromSeconds(3 * 50),
PowTargetSpacing = TimeSpan.FromSeconds(3 * 50),
PowAllowMinDifficultyBlocks = false,
CoinbaseMaturity = 50,
PowNoRetargeting = false,
ConsensusFactory = LBRYCreditsConsensusFactory.Instance,
SupportSegwit = false,
CoinType = 31
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 85 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 122 })
.SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 28 })
.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("LBC"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("LBC"))
.SetMagic(0xfae4aaf1)
.SetPort(9246)
.SetRPCPort(9245)
.SetMaxP2PVersion(70800)
.SetName("LBRYCredits-main")
.AddAlias("LBRYCredits-mainnet")
.AddDNSSeeds(new[]
{
new DNSSeedData("dnsseed1.lbry.io", "dnsseed1.lbry.io"),
new DNSSeedData("dnsseed2.lbry.io", "dnsseed2.lbry.io"),
new DNSSeedData("dnsseed3.lbry.io", "dnsseed3.lbry.io"),
})
.AddSeeds(new NetworkAddress[0])
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000cc59e59ff97ac092b55e423aa5495151ed6fb80570a5bb78cd5bd1c3821c21b8010000000000000000000000000000000000000000000000000000000000000033193156ffff001f070500000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f04ffff001d010417696e736572742074696d657374616d7020737472696e67ffffffff01000004bfc91b8e001976a914345991dbf57bfb014b87006acdfafbfc5fe8292f88ac00000000fae4aaf1d30000000000002063f4346a4db34fdfce29a70f5e8d11f065f6b91602b7036c7f22f3a03b28899cba888e2f9c037f831046f8ad");
return builder;
}
protected override NetworkBuilder CreateTestnet()
{
var builder = new NetworkBuilder();
builder.SetConsensus(new Consensus
{
SubsidyHalvingInterval = unchecked(1000000000),
MajorityEnforceBlockUpgrade = 51,
MajorityRejectBlockOutdated = 75,
MajorityWindow = 100,
PowLimit = new Target(0 >> 1),
MinimumChainWork = new uint256("0x000000000000000000000000000000000000000000000000000a0c3931735170"),
PowTargetTimespan = TimeSpan.FromSeconds(3 * 50),
PowTargetSpacing = TimeSpan.FromSeconds(3 * 50),
PowAllowMinDifficultyBlocks = true,
CoinbaseMaturity = 15,
PowNoRetargeting = false,
ConsensusFactory = LBRYCreditsConsensusFactory.Instance,
SupportSegwit = false,
CoinType = 1
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 111 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 196 })
.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("tLBC"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("tLBC"))
.SetMagic(0xfae4aae1)
.SetPort(29246)
.SetRPCPort(19245)
.SetMaxP2PVersion(70800)
.SetName("LBRYCredits-test")
.AddAlias("LBRYCredits-testnet")
.AddSeeds(new NetworkAddress[0])
//testnet down for now
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000cc59e59ff97ac092b55e423aa5495151ed6fb80570a5bb78cd5bd1c3821c21b8010000000000000000000000000000000000000000000000000000000000000033193156ffff001f070500000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f04ffff001d010417696e736572742074696d657374616d7020737472696e67ffffffff01000004bfc91b8e001976a914345991dbf57bfb014b87006acdfafbfc5fe8292f88ac0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
return builder;
}
protected override NetworkBuilder CreateRegtest()
{
var builder = new NetworkBuilder();
var res = builder.SetConsensus(new Consensus
{
SubsidyHalvingInterval = 150,
MajorityEnforceBlockUpgrade = 750,
MajorityRejectBlockOutdated = 950,
MajorityWindow = 1000,
PowLimit = new Target(0 >> 1),
MinimumChainWork = new uint256("0000000000000000000000000000000000000000000000000000000000000000"),
PowTargetTimespan = TimeSpan.FromSeconds(1),
PowTargetSpacing = TimeSpan.FromSeconds(1),
PowAllowMinDifficultyBlocks = false,
CoinbaseMaturity = 0,
PowNoRetargeting = true,
ConsensusFactory = LBRYCreditsConsensusFactory.Instance,
SupportSegwit = false
})
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 111 })
.SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 196 })
.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("rtLBC"))
.SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, Encoders.Bech32("rtLBC"))
.SetMagic(0xfae4aad1)
.SetPort(29246)
.SetRPCPort(29245)
.SetMaxP2PVersion(70800)
.SetName("LBRYCredits-reg")
.AddAlias("LBRYCredits-regtest")
.AddDNSSeeds(new DNSSeedData[0])
.AddSeeds(new NetworkAddress[0])
.SetGenesis("010000000000000000000000000000000000000000000000000000000000000000000000cc59e59ff97ac092b55e423aa5495151ed6fb80570a5bb78cd5bd1c3821c21b8010000000000000000000000000000000000000000000000000000000000000033193156ffff7f20010000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f04ffff001d010417696e736572742074696d657374616d7020737472696e67ffffffff01000004bfc91b8e001976a914345991dbf57bfb014b87006acdfafbfc5fe8292f88ac0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
return builder;
}
}
}