Commit 1df0738a authored by Sergei Zubov's avatar Sergei Zubov

Modify emission

Splitting initial coins to multiple addresses allows creating multiple
transactions from initial wallet in one block. Also, all funds won't be
locked awaiting confirmations, just part of them.
parent 6334754e
...@@ -10,7 +10,19 @@ namespace NBitcoin.Networks ...@@ -10,7 +10,19 @@ namespace NBitcoin.Networks
{ {
public DeStreamMain() public DeStreamMain()
{ {
const string initialWalletAddress = "TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"; var initialWalletAddresses = new[]
{
"TWyLf11aUSQvorSvG4oc3asMGXbqkf8MEa",
"TSX8RGmEod8K4a2SvPPWZtmJ5KtrBzzXSw",
"TTp1D1NrV1uwbuL2YvWm46M3xY8nYQLRHr",
"TBgvA3dKhGMGeWXpzCG9UUviXLFjZjsQ2S",
"TV37E8whdDUEzVFSsWRHHcj7bWbeDTv9gw",
"TWyiGrPmuKvcMj9s9SGR4BWzMxhZQXJxZk",
"TNL98Epf3ASKFod2QuincwNi2CxHLkkjMD",
"TG3N5ARtJaajqdNHgC9pxnW5kL9CeWkcDa",
"TA9GwihBb9KcW3evjxdVkUh1XdQ5wbEcif",
"TBxudKvSsw1hL7aGf9a34dSdxV4e97dx5y"
};
const decimal initialCoins = 6000000000; const decimal initialCoins = 6000000000;
const int numberOfEmissionTransactions = 6; const int numberOfEmissionTransactions = 6;
...@@ -103,11 +115,11 @@ namespace NBitcoin.Networks ...@@ -103,11 +115,11 @@ namespace NBitcoin.Networks
this.GenesisBits = 0x1e0fffff; this.GenesisBits = 0x1e0fffff;
this.GenesisVersion = 1; this.GenesisVersion = 1;
this.GenesisReward = Money.Coins(initialCoins); this.GenesisReward = Money.Coins(initialCoins);
this.GenesisWalletAddress = initialWalletAddress; this.GenesisWalletAddress = initialWalletAddresses.First();
this.Genesis = this.CreateDeStreamGenesisBlock(this.Consensus.ConsensusFactory, this.GenesisTime, this.Genesis = this.CreateDeStreamGenesisBlock(this.Consensus.ConsensusFactory, this.GenesisTime,
this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward,
this.GenesisWalletAddress, numberOfEmissionTransactions); initialWalletAddresses);
this.Consensus.HashGenesisBlock = this.Genesis.GetHash(); this.Consensus.HashGenesisBlock = this.Genesis.GetHash();
// Assert(this.Consensus.HashGenesisBlock == uint256.Parse("c5974b227ccb19ebd97578285a5937bb4bfb6dcdbf473966d8a2f9c714a8dbb0")); // Assert(this.Consensus.HashGenesisBlock == uint256.Parse("c5974b227ccb19ebd97578285a5937bb4bfb6dcdbf473966d8a2f9c714a8dbb0"));
...@@ -115,8 +127,7 @@ namespace NBitcoin.Networks ...@@ -115,8 +127,7 @@ namespace NBitcoin.Networks
} }
protected Block CreateDeStreamGenesisBlock(ConsensusFactory consensusFactory, uint nTime, uint nNonce, protected Block CreateDeStreamGenesisBlock(ConsensusFactory consensusFactory, uint nTime, uint nNonce,
uint nBits, int nVersion, Money initialCoins, string initialWalletAddress, uint nBits, int nVersion, Money initialCoins, string[] initialWalletAddresses)
uint numberOfEmissionTransactions)
{ {
const string pszTimestamp = "DESTREAM IS THE FIRST DECENTRALIZED GLOBAL FINANCIAL ECOSYSTEM FOR STREAMERS"; const string pszTimestamp = "DESTREAM IS THE FIRST DECENTRALIZED GLOBAL FINANCIAL ECOSYSTEM FOR STREAMERS";
...@@ -133,15 +144,14 @@ namespace NBitcoin.Networks ...@@ -133,15 +144,14 @@ namespace NBitcoin.Networks
}); });
byte[] prefix = this.Base58Prefixes[(int) Base58Type.PUBKEY_ADDRESS]; byte[] prefix = this.Base58Prefixes[(int) Base58Type.PUBKEY_ADDRESS];
byte[] destination_publicKey = foreach (string initialWalletAddress in initialWalletAddresses)
Encoders.Base58Check.DecodeData(initialWalletAddress).Skip(prefix.Length).ToArray();
Script destination = new KeyId(new uint160(destination_publicKey)).ScriptPubKey;
txNew.AddOutput(new Money(Money.Zero), new Script());
for (int i = 0; i < numberOfEmissionTransactions; i++)
{ {
txNew.AddOutput(new TxOut(initialCoins / numberOfEmissionTransactions, destination)); byte[] destinationPublicKey =
Encoders.Base58Check.DecodeData(initialWalletAddress).Skip(prefix.Length).ToArray();
Script destination = new KeyId(new uint160(destinationPublicKey)).ScriptPubKey;
txNew.AddOutput(new TxOut(initialCoins / initialWalletAddresses.Length, destination));
} }
Block genesis = consensusFactory.CreateBlock(); Block genesis = consensusFactory.CreateBlock();
genesis.Header.BlockTime = Utils.UnixTimeToDateTime(nTime); genesis.Header.BlockTime = Utils.UnixTimeToDateTime(nTime);
genesis.Header.Bits = nBits; genesis.Header.Bits = nBits;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net; using System.Net;
using NBitcoin.Protocol; using NBitcoin.Protocol;
...@@ -9,7 +11,18 @@ namespace NBitcoin.Networks ...@@ -9,7 +11,18 @@ namespace NBitcoin.Networks
{ {
public DeStreamTest() //: base() public DeStreamTest() //: base()
{ {
const string initialWalletAddress = "TAE5v2wDwkrCPTDN51ru4YSZ8KvnFFrUQc"; var initialWalletAddresses = new []{
"TWyLf11aUSQvorSvG4oc3asMGXbqkf8MEa",
"TSX8RGmEod8K4a2SvPPWZtmJ5KtrBzzXSw",
"TTp1D1NrV1uwbuL2YvWm46M3xY8nYQLRHr",
"TBgvA3dKhGMGeWXpzCG9UUviXLFjZjsQ2S",
"TV37E8whdDUEzVFSsWRHHcj7bWbeDTv9gw",
"TWyiGrPmuKvcMj9s9SGR4BWzMxhZQXJxZk",
"TNL98Epf3ASKFod2QuincwNi2CxHLkkjMD",
"TG3N5ARtJaajqdNHgC9pxnW5kL9CeWkcDa",
"TA9GwihBb9KcW3evjxdVkUh1XdQ5wbEcif",
"TBxudKvSsw1hL7aGf9a34dSdxV4e97dx5y"
};
const decimal initialCoins = 6000000000; const decimal initialCoins = 6000000000;
const int numberOfEmissionTransactions = 6; const int numberOfEmissionTransactions = 6;
...@@ -43,6 +56,8 @@ namespace NBitcoin.Networks ...@@ -43,6 +56,8 @@ namespace NBitcoin.Networks
this.Consensus.CoinbaseMaturity = 10; this.Consensus.CoinbaseMaturity = 10;
this.Consensus.MaxMoney = long.MaxValue; this.Consensus.MaxMoney = long.MaxValue;
this.Consensus.ProofOfWorkReward = Money.Zero; this.Consensus.ProofOfWorkReward = Money.Zero;
this.Consensus.ProofOfStakeReward = Money.COIN;
this.Consensus.LastPOWBlock = 12500;
this.Base58Prefixes[(int) Base58Type.PUBKEY_ADDRESS] = new byte[] {65}; this.Base58Prefixes[(int) Base58Type.PUBKEY_ADDRESS] = new byte[] {65};
this.Base58Prefixes[(int) Base58Type.SCRIPT_ADDRESS] = new byte[] {196}; this.Base58Prefixes[(int) Base58Type.SCRIPT_ADDRESS] = new byte[] {196};
...@@ -70,11 +85,11 @@ namespace NBitcoin.Networks ...@@ -70,11 +85,11 @@ namespace NBitcoin.Networks
this.GenesisBits = 0x1e0fffff; this.GenesisBits = 0x1e0fffff;
this.GenesisVersion = 1; this.GenesisVersion = 1;
this.GenesisReward = Money.Coins(initialCoins); this.GenesisReward = Money.Coins(initialCoins);
this.GenesisWalletAddress = initialWalletAddress; this.GenesisWalletAddress = initialWalletAddresses.First();
this.Genesis = this.CreateDeStreamGenesisBlock(this.Consensus.ConsensusFactory, this.GenesisTime, this.Genesis = this.CreateDeStreamGenesisBlock(this.Consensus.ConsensusFactory, this.GenesisTime,
this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward,
this.GenesisWalletAddress, numberOfEmissionTransactions); initialWalletAddresses);
this.Genesis.Header.Time = (uint) new DateTimeOffset(2018,09,24,16,13,00, TimeSpan.FromHours(3)).ToUnixTimeSeconds(); this.Genesis.Header.Time = (uint) new DateTimeOffset(2018,09,24,16,13,00, TimeSpan.FromHours(3)).ToUnixTimeSeconds();
this.Genesis.Header.Nonce = 2433759; this.Genesis.Header.Nonce = 2433759;
this.Genesis.Header.Bits = this.Consensus.PowLimit; this.Genesis.Header.Bits = this.Consensus.PowLimit;
......
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