Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
destream-blockchain
Commits
8d9a202e
Commit
8d9a202e
authored
Sep 05, 2018
by
Alexey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review fixes have been introduced for genesis-block generation routine
Some solution tuning performed
parent
02cb8519
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
133 deletions
+110
-133
launchSettings.json
Sources/DeStream.DeStreamD/Properties/launchSettings.json
+8
-2
DeStream.Stratis.Bitcoin.FullNode.sln
Sources/DeStream.Stratis.Bitcoin.FullNode.sln
+7
-1
Network.cs
Sources/NBitcoin/Network.cs
+2
-0
DeStreamMain.cs
Sources/NBitcoin/Networks/DeStreamMain.cs
+53
-21
DeStreamTest.cs
Sources/NBitcoin/Networks/DeStreamTest.cs
+40
-109
No files found.
Sources/DeStream.DeStreamD/Properties/launchSettings.json
View file @
8d9a202e
{
"profiles"
:
{
"Stratis.StratisD"
:
{
"DeStream.DeStream"
:
{
"commandName"
:
"Project"
},
"DeStream.DeStreamD Test"
:
{
"commandName"
:
"Project"
,
"commandLineArgs"
:
"-testnet -debug -loglevel=trace "
"commandLineArgs"
:
"-testnet -debug -loglevel=trace"
},
"Stratis.StratisD"
:
{
"commandName"
:
"Project"
},
"Stratis.StratisD Test"
:
{
"commandName"
:
"Project"
,
...
...
Sources/DeStream.Stratis.Bitcoin.FullNode.sln
View file @
8d9a202e
...
...
@@ -103,7 +103,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Tests.Walle
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.IntegrationTests.Common", "Stratis.Bitcoin.IntegrationTests.Common\Stratis.Bitcoin.IntegrationTests.Common.csproj", "{F7DD01DA-B888-4817-A5FA-3A87B69BFCA7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeStream.DeStreamD.ForTest", "DeStream.DeStreamD.ForTest\DeStream.DeStreamD.ForTest.csproj", "{D6749732-118C-4BDD-B184-5229AAB83341}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeStream.DeStreamD.ForTest", "DeStream.DeStreamD.ForTest\DeStream.DeStreamD.ForTest.csproj", "{D6749732-118C-4BDD-B184-5229AAB83341}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DeStream", "DeStream", "{4F374E46-C086-44BE-B785-2F88E2093016}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -308,6 +310,10 @@ Global
{6181B889-81B0-4A1E-A29F-E20DCD8BFC1F} = {15D29FFD-6142-4DC5-AFFD-10BA0CA55C45}
{CB7A2800-8E98-4CD5-A88A-832E03AF7ABF} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
{978482B2-AE17-421E-AD6F-ED9667C6B8A1} = {A0CEDD86-D446-436E-8C35-261B30CEE5D3}
{DFFB8C9F-4186-417F-A843-A5E1E6125164} = {4F374E46-C086-44BE-B785-2F88E2093016}
{5303E8B0-C422-4D1C-8096-24DF6AF75E31} = {4F374E46-C086-44BE-B785-2F88E2093016}
{CFE3D6A4-8B4F-4466-984B-74909ED2DA20} = {4F374E46-C086-44BE-B785-2F88E2093016}
{79B71F10-9B43-45C2-ADA4-A84324810D5C} = {4F374E46-C086-44BE-B785-2F88E2093016}
{B6FB52FE-F754-49B0-A65F-02F5C82B33EE} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
{F1755154-88DC-4434-98FB-7D22C95BA640} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
{F7DD01DA-B888-4817-A5FA-3A87B69BFCA7} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
...
...
Sources/NBitcoin/Network.cs
View file @
8d9a202e
...
...
@@ -198,6 +198,8 @@ namespace NBitcoin
/// </summary>
public
Money
GenesisReward
{
get
;
protected
set
;
}
public
string
GenesisWalletAddress
{
get
;
protected
set
;
}
/// <summary>
/// Mines a new genesis block, to use with a new network.
/// Typically, 3 such genesis blocks need to be created when bootstrapping a new coin: for Main, Test and Reg networks.
...
...
Sources/NBitcoin/Networks/DeStreamMain.cs
View file @
8d9a202e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
NBitcoin.BouncyCastle.Math
;
using
NBitcoin.DataEncoders
;
...
...
@@ -12,6 +13,8 @@ namespace NBitcoin.Networks
public
DeStreamMain
()
{
string
InitialWalletAddress
=
"TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"
;
decimal
InitialCoins
=
6000000000
;
var
messageStart
=
new
byte
[
4
];
messageStart
[
0
]
=
0x70
;
...
...
@@ -31,6 +34,7 @@ namespace NBitcoin.Networks
this
.
MinRelayTxFee
=
10000
;
this
.
MaxTimeOffsetSeconds
=
StratisMaxTimeOffsetSeconds
;
this
.
MaxTipAge
=
StratisDefaultMaxTipAgeInSeconds
;
this
.
CoinTicker
=
"DST"
;
this
.
Consensus
.
SubsidyHalvingInterval
=
210000
;
this
.
Consensus
.
MajorityEnforceBlockUpgrade
=
750
;
...
...
@@ -55,11 +59,6 @@ namespace NBitcoin.Networks
this
.
Consensus
.
CoinType
=
105
;
this
.
Consensus
.
DefaultAssumeValid
=
new
uint256
(
"0x55a8205ae4bbf18f4d238c43f43005bd66e0b1f679b39e2c5c62cf6903693a5e"
);
// 795970
this
.
Genesis
=
CreateStratisGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
1470467000
,
1831645
,
0x1e0fffff
,
1
,
Money
.
Zero
);
this
.
Consensus
.
HashGenesisBlock
=
this
.
Genesis
.
GetHash
();
Assert
(
this
.
Consensus
.
HashGenesisBlock
==
uint256
.
Parse
(
"0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"
));
Assert
(
this
.
Genesis
.
Header
.
HashMerkleRoot
==
uint256
.
Parse
(
"0x65a26bc20b0351aebf05829daefa8f7db2f800623439f3c114257c91447f1518"
));
this
.
Checkpoints
=
new
Dictionary
<
int
,
CheckpointInfo
>
{
{
0
,
new
CheckpointInfo
(
new
uint256
(
"0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"
),
new
uint256
(
"0x0000000000000000000000000000000000000000000000000000000000000000"
))
},
...
...
@@ -81,6 +80,7 @@ namespace NBitcoin.Networks
{
576000
,
new
CheckpointInfo
(
new
uint256
(
"0xe705476b940e332098d1d5b475d7977312ff8c08cbc8256ce46a3e2c6d5408b8"
),
new
uint256
(
"0x10e31bb5e245ea19650280cfd3ac1a76259fa0002d02e861d2ab5df290534b56"
))
},
};
this
.
Base58Prefixes
=
new
byte
[
12
][];
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
(
63
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
(
125
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
(
63
+
128
)
};
...
...
@@ -95,32 +95,64 @@ namespace NBitcoin.Networks
this
.
Base58Prefixes
[(
int
)
Base58Type
.
COLORED_ADDRESS
]
=
new
byte
[]
{
0x13
};
var
encoder
=
new
Bech32Encoder
(
"bc"
);
this
.
Bech32Encoders
=
new
Bech32Encoder
[
2
];
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_PUBKEY_ADDRESS
]
=
encoder
;
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_SCRIPT_ADDRESS
]
=
encoder
;
this
.
DNSSeeds
.
AddRange
(
new
[]
this
.
DNSSeeds
=
new
List
<
DNSSeedData
>
{
new
DNSSeedData
(
"node1.destream.io"
,
"node1.destream.io"
),
new
DNSSeedData
(
"node2.destream.io"
,
"node2.destream.io"
)
});
};
string
[]
seedNodes
=
{
"95.128.181.103"
,
"95.128.181.80"
};
this
.
SeedNodes
=
ConvertToNetworkAddresses
(
seedNodes
,
this
.
DefaultPort
).
ToList
();
// Create the genesis block.
this
.
GenesisTime
=
1470467000
;
this
.
GenesisNonce
=
1831645
;
this
.
GenesisBits
=
0x1e0fffff
;
this
.
GenesisVersion
=
1
;
this
.
GenesisReward
=
Money
.
Coins
(
InitialCoins
);
this
.
GenesisWalletAddress
=
InitialWalletAddress
;
this
.
Genesis
=
CreateDeStreamGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
this
.
GenesisTime
,
this
.
GenesisNonce
,
this
.
GenesisBits
,
this
.
GenesisVersion
,
this
.
GenesisReward
,
this
.
GenesisWalletAddress
);
this
.
Consensus
.
HashGenesisBlock
=
this
.
Genesis
.
GetHash
();
var
seeds
=
new
[]
{
"95.128.181.103"
,
"95.128.181.80"
}
;
// Convert the seeds array into usable address objects.
Random
rand
=
new
Random
();
TimeSpan
oneWeek
=
TimeSpan
.
FromDays
(
7
);
foreach
(
string
seed
in
seed
s
)
// Assert(this.Consensus.HashGenesisBlock == uint256.Parse("c5974b227ccb19ebd97578285a5937bb4bfb6dcdbf473966d8a2f9c714a8dbb0"))
;
// Assert(this.Genesis.Header.HashMerkleRoot == uint256.Parse("9e3fff58fb1ba15a69198e22d99572fa024afb754bfe1d3b8d28b86fd9de62df"));
}
protected
Block
CreateDeStreamGenesisBlock
(
ConsensusFactory
consensusFactory
,
uint
nTime
,
uint
nNonce
,
uint
nBits
,
int
nVersion
,
Money
InitialCoins
,
string
InitialWalletAddres
s
)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time' of between one and two weeks ago.
NetworkAddress
addr
=
new
NetworkAddress
string
pszTimestamp
=
"DESTREAM IS THE FIRST DECENTRALIZED GLOBAL FINANCIAL ECOSYSTEM FOR STREAMERS"
;
Transaction
txNew
=
consensusFactory
.
CreateTransaction
();
txNew
.
Version
=
1
;
txNew
.
Time
=
nTime
;
txNew
.
AddInput
(
new
TxIn
()
{
Time
=
DateTime
.
UtcNow
-
(
TimeSpan
.
FromSeconds
(
rand
.
NextDouble
()
*
oneWeek
.
TotalSeconds
))
-
oneWeek
,
Endpoint
=
Utils
.
ParseIpEndpoint
(
seed
,
this
.
DefaultPort
)
};
ScriptSig
=
new
Script
(
Op
.
GetPushOp
(
0
),
new
Op
()
{
Code
=
(
OpcodeType
)
0x1
,
PushData
=
new
[]
{
(
byte
)
42
}
},
Op
.
GetPushOp
(
Encoders
.
ASCII
.
DecodeData
(
pszTimestamp
)))
});
this
.
SeedNodes
.
Add
(
addr
);
}
byte
[]
prefix
=
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
];
byte
[]
destination_publicKey
=
Encoders
.
Base58Check
.
DecodeData
(
InitialWalletAddress
).
Skip
(
prefix
.
Length
).
ToArray
();
Script
destination
=
(
new
KeyId
(
new
uint160
(
destination_publicKey
))).
ScriptPubKey
;
txNew
.
AddOutput
(
new
TxOut
(
InitialCoins
,
destination
));
Block
genesis
=
consensusFactory
.
CreateBlock
();
genesis
.
Header
.
BlockTime
=
Utils
.
UnixTimeToDateTime
(
nTime
);
genesis
.
Header
.
Bits
=
nBits
;
genesis
.
Header
.
Nonce
=
nNonce
;
genesis
.
Header
.
Version
=
nVersion
;
genesis
.
Transactions
.
Add
(
txNew
);
genesis
.
Header
.
HashPrevBlock
=
uint256
.
Zero
;
genesis
.
UpdateMerkleRoot
();
return
genesis
;
}
}
}
Sources/NBitcoin/Networks/DeStreamTest.cs
View file @
8d9a202e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
NBitcoin.BouncyCastle.Math
;
...
...
@@ -9,63 +8,36 @@ using NBitcoin.Protocol;
namespace
NBitcoin.Networks
{
public
class
DeStreamTest
:
Network
public
class
DeStreamTest
:
DeStreamMain
{
const
string
WalletAddressDeStreamTest
=
"TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"
;
public
DeStreamTest
()
//: base()
{
string
InitialWalletAddress
=
"TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"
;
decimal
InitialCoins
=
6000000000
;
this
.
DNSSeeds
=
new
List
<
DNSSeedData
>();
this
.
SeedNodes
=
new
List
<
NetworkAddress
>();
this
.
Checkpoints
=
new
Dictionary
<
int
,
CheckpointInfo
>();
this
.
Consensus
=
new
Consensus
();
this
.
Base58Prefixes
=
new
byte
[
12
][];
this
.
Bech32Encoders
=
new
Bech32Encoder
[
2
];
//The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF - 8, and produce
// a large 4 - byte int at any alignment.
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
var
messageStart
=
new
byte
[
4
];
messageStart
[
0
]
=
0x71
;
messageStart
[
1
]
=
0x31
;
messageStart
[
2
]
=
0x21
;
messageStart
[
3
]
=
0x11
;
var
magic
=
BitConverter
.
ToUInt32
(
messageStart
,
0
);
// 0x11213171;
uint
magic
=
BitConverter
.
ToUInt32
(
messageStart
,
0
);
// 0x11213171;
this
.
Name
=
"DeStreamTest"
;
this
.
RootFolderName
=
DeStreamRootFolderName
;
this
.
DefaultConfigFilename
=
DeStreamDefaultConfigFilename
;
this
.
Magic
=
magic
;
this
.
DefaultPort
=
0xDE11
;
//56849,
this
.
RPCPort
=
0xDE10
;
//56848,
this
.
MaxTimeOffsetSeconds
=
StratisMaxTimeOffsetSeconds
;
this
.
MaxTipAge
=
StratisDefaultMaxTipAgeInSeconds
;
this
.
MinTxFee
=
10000
;
this
.
FallbackFee
=
60000
;
this
.
MinRelayTxFee
=
10000
;
this
.
DefaultPort
=
26178
;
this
.
RPCPort
=
26174
;
this
.
CoinTicker
=
"TDST"
;
this
.
Consensus
.
SubsidyHalvingInterval
=
210000
;
this
.
Consensus
.
MajorityEnforceBlockUpgrade
=
750
;
this
.
Consensus
.
MajorityRejectBlockOutdated
=
950
;
this
.
Consensus
.
MajorityWindow
=
1000
;
this
.
Consensus
.
BuriedDeployments
[
BuriedDeployments
.
BIP34
]
=
0
;
this
.
Consensus
.
BuriedDeployments
[
BuriedDeployments
.
BIP65
]
=
0
;
this
.
Consensus
.
BuriedDeployments
[
BuriedDeployments
.
BIP66
]
=
0
;
this
.
Consensus
.
BIP34Hash
=
new
uint256
(
"0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"
);
this
.
Consensus
.
PowLimit
=
new
Target
(
new
uint256
(
"0000ffff00000000000000000000000000000000000000000000000000000000"
));
this
.
Consensus
.
PowTargetTimespan
=
TimeSpan
.
FromSeconds
(
14
*
24
*
60
*
60
);
// two weeks
this
.
Consensus
.
PowTargetSpacing
=
TimeSpan
.
FromSeconds
(
10
*
60
);
this
.
Consensus
.
PowAllowMinDifficultyBlocks
=
false
;
this
.
Consensus
.
PowNoRetargeting
=
false
;
this
.
Consensus
.
RuleChangeActivationThreshold
=
1916
;
// 95% of 2016
this
.
Consensus
.
MinerConfirmationWindow
=
2016
;
// nPowTargetTimespan / nPowTargetSpacing
this
.
Consensus
.
LastPOWBlock
=
12500
;
this
.
Consensus
.
IsProofOfStake
=
true
;
this
.
Consensus
.
ConsensusFactory
=
new
PosConsensusFactory
()
{
Consensus
=
this
.
Consensus
};
this
.
Consensus
.
ProofOfStakeLimit
=
new
BigInteger
(
uint256
.
Parse
(
"00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
).
ToBytes
(
false
));
this
.
Consensus
.
ProofOfStakeLimitV2
=
new
BigInteger
(
uint256
.
Parse
(
"000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff"
).
ToBytes
(
false
));
this
.
Consensus
.
CoinType
=
105
;
this
.
Consensus
.
DefaultAssumeValid
=
new
uint256
(
"0x98fa6ef0bca5b431f15fd79dc6f879dc45b83ed4b1bbe933a383ef438321958e"
);
// 372652
this
.
Consensus
.
CoinbaseMaturity
=
10
;
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
(
65
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
(
196
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
(
65
+
128
)
};
this
.
Checkpoints
=
new
Dictionary
<
int
,
CheckpointInfo
>
{
...
...
@@ -73,82 +45,41 @@ namespace NBitcoin.Networks
{
2
,
new
CheckpointInfo
(
new
uint256
(
"0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"
),
new
uint256
(
"0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02"
))
},
{
50000
,
new
CheckpointInfo
(
new
uint256
(
"0xb42c18eacf8fb5ed94eac31943bd364451d88da0fd44cc49616ffea34d530ad4"
),
new
uint256
(
"0x824934ddc5f935e854ac59ae7f5ed25f2d29a7c3914cac851f3eddb4baf96d78"
))
},
{
100000
,
new
CheckpointInfo
(
new
uint256
(
"0xf9e2f7561ee4b92d3bde400d251363a0e8924204c326da7f4ad9ccc8863aad79"
),
new
uint256
(
"0xdef8d92d20becc71f662ee1c32252aca129f1bf4744026b116d45d9bfe67e9fb"
))
},
{
115000
,
new
CheckpointInfo
(
new
uint256
(
"0x8496c77060c8a2b5c9a888ade991f25aa33c232b4413594d556daf9043fad400"
),
new
uint256
(
"0x1886430484a9a36b56a7eb8bd25e9ebe4fc8eec8f9a84f5073f71e08f2feac90"
))
},
{
163000
,
new
CheckpointInfo
(
new
uint256
(
"0x4e44a9e0119a2e7cbf15e570a3c649a5605baa601d953a465b5ebd1c1982212a"
),
new
uint256
(
"0x0646fc7db8f3426eb209e1228c7d82724faa46a060f5bbbd546683ef30be245c"
))
},
{
150000
,
new
CheckpointInfo
(
new
uint256
(
"0x08b7c20a450252ddf9ce41dbeb92ecf54932beac9090dc8250e933ad3a175381"
),
new
uint256
(
"0xf05dad15f733ae0acbd34adc449be9429099dbee5fa9ecd8e524cf28e9153adb"
))
},
{
200000
,
new
CheckpointInfo
(
new
uint256
(
"0x8609cc873222a0573615788dc32e377b88bfd6a0015791f627d969ee3a415115"
),
new
uint256
(
"0xfa28c1f20a8162d133607c6a1c8997833befac3efd9076567258a7683ac181fa"
))
},
{
250000
,
new
CheckpointInfo
(
new
uint256
(
"0xdd664e15ac679a6f3b96a7176303956661998174a697ad8231f154f1e32ff4a3"
),
new
uint256
(
"0x19fc0fa29418f8b19cbb6557c1c79dfd0eff6779c0eaaec5d245c5cdf3c96d78"
))
},
{
300000
,
new
CheckpointInfo
(
new
uint256
(
"0x2409eb5ae72c80d5b37c77903d75a8e742a33843ab633935ce6e5264db962e23"
),
new
uint256
(
"0xf5ec7af55516b8e264ed280e9a5dba0180a4a9d3713351bfea275b18f3f1514e"
))
},
{
350000
,
new
CheckpointInfo
(
new
uint256
(
"0x36811041e9060f4b4c26dc20e0850dca5efaabb60618e3456992e9c0b1b2120e"
),
new
uint256
(
"0xbfda55ef0756bcee8485e15527a2b8ca27ca877aa09c88e363ef8d3253cdfd1c"
))
},
{
400000
,
new
CheckpointInfo
(
new
uint256
(
"0xb6abcb933d3e3590345ca5d3abb697461093313f8886568ac8ae740d223e56f6"
),
new
uint256
(
"0xfaf5fcebee3ec0df5155393a99da43de18b12e620fef5edb111a791ecbfaa63a"
))
}
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
(
65
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
(
196
)
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
(
65
+
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
};
Block
genesis
=
CreateDeStreamGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
1470467000
,
1831645
,
0x1e0fffff
,
1
,
new
Money
(
6100000000
));
genesis
.
Header
.
Time
=
1493909211
;
genesis
.
Header
.
Nonce
=
2433759
;
genesis
.
Header
.
Bits
=
this
.
Consensus
.
PowLimit
;
this
.
Genesis
=
genesis
;
this
.
Consensus
.
HashGenesisBlock
=
genesis
.
GetHash
();
Assert
(
this
.
Consensus
.
HashGenesisBlock
==
uint256
.
Parse
(
"9588559fe38409c5a5d652e847dd059a105ef8f26015f43a512ef8c8a7962dff"
));
var
encoder
=
new
Bech32Encoder
(
"bc"
);
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_PUBKEY_ADDRESS
]
=
encoder
;
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_SCRIPT_ADDRESS
]
=
encoder
;
this
.
DNSSeeds
.
AddRange
(
new
[]
this
.
DNSSeeds
=
new
List
<
DNSSeedData
>
{
new
DNSSeedData
(
"testnode1.destream.io"
,
"testnode1.destream.io"
)
}
)
;
};
this
.
SeedNodes
.
AddRange
(
new
[]
this
.
SeedNodes
=
new
List
<
NetworkAddress
>
{
new
NetworkAddress
(
IPAddress
.
Parse
(
"95.128.181.196"
),
this
.
DefaultPort
),
//peak-srv-12
new
NetworkAddress
(
IPAddress
.
Parse
(
"40.121.9.206"
),
this
.
DefaultPort
)
});
}
internal
Block
CreateDeStreamGenesisBlock
(
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"
;
return
CreateDeStreamGenesisBlock
(
consensusFactory
,
pszTimestamp
,
nTime
,
nNonce
,
nBits
,
nVersion
,
genesisReward
);
}
internal
Block
CreateDeStreamGenesisBlock
(
ConsensusFactory
consensusFactory
,
string
pszTimestamp
,
uint
nTime
,
uint
nNonce
,
uint
nBits
,
int
nVersion
,
Money
genesisReward
)
{
Transaction
txNew
=
consensusFactory
.
CreateTransaction
();
txNew
.
Version
=
1
;
txNew
.
Time
=
nTime
;
txNew
.
AddInput
(
new
TxIn
()
{
ScriptSig
=
new
Script
(
Op
.
GetPushOp
(
0
),
new
Op
()
{
Code
=
(
OpcodeType
)
0x1
,
PushData
=
new
[]
{
(
byte
)
42
}
},
Op
.
GetPushOp
(
Encoders
.
ASCII
.
DecodeData
(
pszTimestamp
)))
});
};
byte
[]
prefix
=
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
];
Script
destination
=
(
new
KeyId
(
new
uint160
(
Encoders
.
Base58Check
.
DecodeData
(
WalletAddressDeStreamTest
).
Skip
((
int
)
prefix
?.
ToArray
().
Length
).
ToArray
()))).
ScriptPubKey
;
txNew
.
AddOutput
(
new
TxOut
(
genesisReward
,
destination
));
Block
genesis
=
consensusFactory
.
CreateBlock
();
genesis
.
Header
.
BlockTime
=
Utils
.
UnixTimeToDateTime
(
nTime
);
genesis
.
Header
.
Bits
=
nBits
;
genesis
.
Header
.
Nonce
=
nNonce
;
genesis
.
Header
.
Version
=
nVersion
;
genesis
.
Transactions
.
Add
(
txNew
);
genesis
.
Header
.
HashPrevBlock
=
uint256
.
Zero
;
genesis
.
UpdateMerkleRoot
();
return
genesis
;
// Create the genesis block.
this
.
GenesisTime
=
1470467000
;
this
.
GenesisNonce
=
1831645
;
this
.
GenesisBits
=
0x1e0fffff
;
this
.
GenesisVersion
=
1
;
this
.
GenesisReward
=
Money
.
Coins
(
InitialCoins
);
this
.
GenesisWalletAddress
=
InitialWalletAddress
;
this
.
Genesis
=
CreateDeStreamGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
this
.
GenesisTime
,
this
.
GenesisNonce
,
this
.
GenesisBits
,
this
.
GenesisVersion
,
this
.
GenesisReward
,
this
.
GenesisWalletAddress
);
this
.
Genesis
.
Header
.
Time
=
1493909211
;
this
.
Genesis
.
Header
.
Nonce
=
2433759
;
this
.
Genesis
.
Header
.
Bits
=
this
.
Consensus
.
PowLimit
;
this
.
Consensus
.
HashGenesisBlock
=
this
.
Genesis
.
GetHash
();
// Assert(this.Consensus.HashGenesisBlock == uint256.Parse("c5974b227ccb19ebd97578285a5937bb4bfb6dcdbf473966d8a2f9c714a8dbb0"));
// Assert(this.Genesis.Header.HashMerkleRoot == uint256.Parse("9e3fff58fb1ba15a69198e22d99572fa024afb754bfe1d3b8d28b86fd9de62df"));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment