Commit c27aa6b4 authored by Sergei Zubov's avatar Sergei Zubov

Refactor mainnet settings

parent de60a0c6
using System; using NBitcoin.DataEncoders;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using NBitcoin.BouncyCastle.Math;
using NBitcoin.DataEncoders;
using NBitcoin.Networks; using NBitcoin.Networks;
using NBitcoin.Protocol;
namespace NBitcoin namespace NBitcoin
{ {
public partial class Network public partial class Network
{ {
/// <summary>
/// The name of the root folder containing the different Stratis blockchains (StratisMain, StratisTest,
/// <summary> The name of the root folder containing the different Stratis blockchains (StratisMain, StratisTest, StratisRegTest). </summary> /// StratisRegTest).
public const string DeStreamRootFolderName = "destream"; /// </summary>
protected const string DeStreamRootFolderName = "destream";
/// <summary> The default name used for the Stratis configuration file. </summary> /// <summary> The default name used for the Stratis configuration file. </summary>
public const string DeStreamDefaultConfigFilename = "destream.conf"; protected const string DeStreamDefaultConfigFilename = "destream.conf";
public const int StratisMaxTimeOffsetSeconds = 25 * 60; protected const int DeStreamMaxTimeOffsetSeconds = 25 * 60;
public const int StratisDefaultMaxTipAgeInSeconds = 2 * 60 * 60;
protected const int DeStreamDefaultMaxTipAgeInSeconds = 2 * 60 * 60;
public const string WalletAddressDeStreamMain = "TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"; public const string WalletAddressDeStreamMain = "TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft";
public static Network DeStreamMain => NetworksContainer.GetNetwork("DeStreamMain") ?? NetworksContainer.Register(new DeStreamMain()); public static Network DeStreamMain => NetworksContainer.GetNetwork("DeStreamMain") ??
NetworksContainer.Register(new DeStreamMain());
public static Network DeStreamTest => NetworksContainer.GetNetwork("DeStreamTest") ?? NetworksContainer.Register(new DeStreamTest()); public static Network DeStreamTest => NetworksContainer.GetNetwork("DeStreamTest") ??
NetworksContainer.Register(new DeStreamTest());
public static Network DeStreamRegTest => NetworksContainer.GetNetwork("DeStreamRegTest") ?? NetworksContainer.Register(new DeStreamRegTest()); public static Network DeStreamRegTest => NetworksContainer.GetNetwork("DeStreamRegTest") ??
NetworksContainer.Register(new DeStreamRegTest());
internal static Block CreateStratisGenesisBlock(ConsensusFactory consensusFactory, uint nTime, uint nNonce, uint nBits, int nVersion, Money genesisReward) internal static Block CreateStratisGenesisBlock(ConsensusFactory consensusFactory, uint nTime, uint nNonce,
uint nBits, int nVersion, Money genesisReward)
{ {
string pszTimestamp = "http://www.theonion.com/article/olympics-head-priestess-slits-throat-official-rio--53466"; string pszTimestamp =
return CreateStratisGenesisBlock(consensusFactory, pszTimestamp, nTime, nNonce, nBits, nVersion, genesisReward); "http://www.theonion.com/article/olympics-head-priestess-slits-throat-official-rio--53466";
return CreateStratisGenesisBlock(consensusFactory, pszTimestamp, nTime, nNonce, nBits, nVersion,
genesisReward);
} }
internal static Block CreateStratisGenesisBlock(ConsensusFactory consensusFactory, string pszTimestamp, uint nTime, uint nNonce, uint nBits, int nVersion, Money genesisReward) private static Block CreateStratisGenesisBlock(ConsensusFactory consensusFactory, string pszTimestamp,
uint nTime, uint nNonce, uint nBits, int nVersion, Money genesisReward)
{ {
Transaction txNew = consensusFactory.CreateTransaction(); Transaction txNew = consensusFactory.CreateTransaction();
txNew.Version = 1; txNew.Version = 1;
txNew.Time = nTime; txNew.Time = nTime;
txNew.AddInput(new TxIn() txNew.AddInput(new TxIn
{ {
ScriptSig = new Script(Op.GetPushOp(0), new Op() ScriptSig = new Script(Op.GetPushOp(0), new Op
{ {
Code = (OpcodeType)0x1, Code = (OpcodeType) 0x1,
PushData = new[] { (byte)42 } PushData = new[] {(byte) 42}
}, Op.GetPushOp(Encoders.ASCII.DecodeData(pszTimestamp))) }, Op.GetPushOp(Encoders.ASCII.DecodeData(pszTimestamp)))
}); });
txNew.AddOutput(new TxOut() txNew.AddOutput(new TxOut
{ {
Value = genesisReward, Value = genesisReward
}); });
Block genesis = consensusFactory.CreateBlock(); Block genesis = consensusFactory.CreateBlock();
genesis.Header.BlockTime = Utils.UnixTimeToDateTime(nTime); genesis.Header.BlockTime = Utils.UnixTimeToDateTime(nTime);
...@@ -66,6 +67,5 @@ namespace NBitcoin ...@@ -66,6 +67,5 @@ namespace NBitcoin
genesis.UpdateMerkleRoot(); genesis.UpdateMerkleRoot();
return genesis; return genesis;
} }
} }
} }
\ No newline at end of file
...@@ -81,8 +81,8 @@ namespace NBitcoin.Networks ...@@ -81,8 +81,8 @@ namespace NBitcoin.Networks
this.MinTxFee = 10000; this.MinTxFee = 10000;
this.FallbackFee = 60000; this.FallbackFee = 60000;
this.MinRelayTxFee = 10000; this.MinRelayTxFee = 10000;
this.MaxTimeOffsetSeconds = StratisMaxTimeOffsetSeconds; this.MaxTimeOffsetSeconds = DeStreamMaxTimeOffsetSeconds;
this.MaxTipAge = StratisDefaultMaxTipAgeInSeconds; this.MaxTipAge = DeStreamDefaultMaxTipAgeInSeconds;
this.CoinTicker = "DST"; this.CoinTicker = "DST";
this.Consensus.SubsidyHalvingInterval = 210000; this.Consensus.SubsidyHalvingInterval = 210000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment