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
f2d2e2e9
Commit
f2d2e2e9
authored
Jan 15, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix network settings
parent
046c7d88
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
96 deletions
+54
-96
DeStreamPosConsensusOptions.cs
...Bitcoin.Features.Consensus/DeStreamPosConsensusOptions.cs
+1
-4
DeStreamMain.cs
Sources/Stratis.Bitcoin.Networks/DeStreamMain.cs
+24
-18
DeStreamTest.cs
Sources/Stratis.Bitcoin.Networks/DeStreamTest.cs
+25
-74
KnownNetworks.cs
Sources/Stratis.Bitcoin.Tests.Common/KnownNetworks.cs
+4
-0
No files found.
Sources/Stratis.Bitcoin.Features.Consensus/DeStreamPosConsensusOptions.cs
View file @
f2d2e2e9
...
...
@@ -7,10 +7,7 @@ namespace Stratis.Bitcoin.Features.Consensus
{
public
override
int
GetStakeMinConfirmations
(
int
height
,
Network
network
)
{
if
(
network
.
IsTest
())
return
height
<
CoinstakeMinConfirmationActivationHeightTestnet
?
10
:
20
;
return
500
;
return
network
.
IsTest
()
?
20
:
500
;
}
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Networks/DeStreamMain.cs
View file @
f2d2e2e9
...
...
@@ -4,6 +4,7 @@ using System.Linq;
using
NBitcoin
;
using
NBitcoin.BouncyCastle.Math
;
using
NBitcoin.DataEncoders
;
using
Stratis.Bitcoin.Networks.Deployments
;
namespace
Stratis.Bitcoin.Networks
{
...
...
@@ -41,6 +42,21 @@ namespace Stratis.Bitcoin.Networks
var
consensusFactory
=
new
PosConsensusFactory
();
this
.
Base58Prefixes
=
new
byte
[
12
][];
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
30
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
90
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
30
+
90
};
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
};
// Create the genesis block.
var
initialWalletAddresses
=
new
[]
{
...
...
@@ -64,7 +80,7 @@ namespace Stratis.Bitcoin.Networks
this
.
GenesisReward
=
Money
.
Coins
(
initialCoins
);
this
.
GenesisWalletAddress
=
initialWalletAddresses
.
First
();
var
genesisBlock
=
this
.
CreateDeStreamGenesisBlock
(
this
.
Consensus
.
C
onsensusFactory
,
this
.
GenesisTime
,
var
genesisBlock
=
this
.
CreateDeStreamGenesisBlock
(
c
onsensusFactory
,
this
.
GenesisTime
,
this
.
GenesisNonce
,
this
.
GenesisBits
,
this
.
GenesisVersion
,
this
.
GenesisReward
,
initialWalletAddresses
);
...
...
@@ -86,7 +102,12 @@ namespace Stratis.Bitcoin.Networks
[
BuriedDeployments
.
BIP66
]
=
0
};
//TODO: BIP9
var
bip9Deployments
=
new
StratisBIP9Deployments
()
{
[
StratisBIP9Deployments
.
ColdStaking
]
=
new
BIP9DeploymentsParameters
(
2
,
new
DateTime
(
2018
,
12
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
),
new
DateTime
(
2019
,
12
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
))
};
this
.
Consensus
=
new
NBitcoin
.
Consensus
(
consensusFactory
:
consensusFactory
,
...
...
@@ -98,7 +119,7 @@ namespace Stratis.Bitcoin.Networks
majorityRejectBlockOutdated
:
950
,
majorityWindow
:
1000
,
buriedDeployments
:
buriedDeployments
,
bip9Deployments
:
null
,
//TODO: BIP9
bip9Deployments
:
bip9Deployments
,
bip34Hash
:
new
uint256
(
"0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"
),
ruleChangeActivationThreshold
:
1916
,
// 95% of 2016
minerConfirmationWindow
:
2016
,
// nPowTargetTimespan / nPowTargetSpacing
...
...
@@ -122,21 +143,6 @@ namespace Stratis.Bitcoin.Networks
proofOfStakeReward
:
Money
.
Zero
);
this
.
Base58Prefixes
=
new
byte
[
12
][];
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
30
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
90
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
30
+
90
};
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
};
this
.
Checkpoints
=
new
Dictionary
<
int
,
CheckpointInfo
>
{
{
...
...
Sources/Stratis.Bitcoin.Networks/DeStreamTest.cs
View file @
f2d2e2e9
...
...
@@ -5,10 +5,11 @@ using NBitcoin;
using
NBitcoin.BouncyCastle.Math
;
using
NBitcoin.DataEncoders
;
using
NBitcoin.Protocol
;
using
Stratis.Bitcoin.Networks.Deployments
;
namespace
Stratis.Bitcoin.Networks
{
public
class
DeStreamTest
:
DeStream
Network
public
class
DeStreamTest
:
DeStream
Main
{
public
DeStreamTest
()
{
// The message start string is designed to be unlikely to occur in normal data.
...
...
@@ -22,22 +23,10 @@ namespace Stratis.Bitcoin.Networks
uint
magic
=
BitConverter
.
ToUInt32
(
messageStart
,
0
);
this
.
Name
=
"DeStreamTest"
;
this
.
Magic
=
magic
;
this
.
DefaultPort
=
56849
;
this
.
DefaultMaxOutboundConnections
=
16
;
this
.
DefaultMaxInboundConnections
=
109
;
this
.
RPCPort
=
56848
;
this
.
MaxTipAge
=
DeStreamDefaultMaxTipAgeInSeconds
;
this
.
MinTxFee
=
10000
;
this
.
FallbackFee
=
60000
;
this
.
MinRelayTxFee
=
10000
;
this
.
RootFolderName
=
DeStreamRootFolderName
;
this
.
DefaultConfigFilename
=
DeStreamDefaultConfigFilename
;
this
.
MaxTimeOffsetSeconds
=
DeStreamMaxTimeOffsetSeconds
;
this
.
CoinTicker
=
"TDST"
;
this
.
DeStreamFeePart
=
0.9
;
this
.
FeeRate
=
0.0077
;
var
consensusFactory
=
new
PosConsensusFactory
();
...
...
@@ -67,9 +56,11 @@ namespace Stratis.Bitcoin.Networks
};
const
decimal
initialCoins
=
6000000000
;
this
.
GenesisTime
=
1470467000
;
var
powLimit
=
new
Target
(
new
uint256
(
"0000ffff00000000000000000000000000000000000000000000000000000000"
));
this
.
GenesisTime
=
(
uint
)
new
DateTimeOffset
(
2019
,
2
,
11
,
0
,
0
,
0
,
new
TimeSpan
()).
ToUnixTimeSeconds
();
this
.
GenesisNonce
=
1831645
;
this
.
GenesisBits
=
0x1e0fffff
;
this
.
GenesisBits
=
powLimit
;
this
.
GenesisVersion
=
1
;
this
.
GenesisReward
=
Money
.
Coins
(
initialCoins
);
this
.
GenesisWalletAddress
=
initialWalletAddresses
.
First
();
...
...
@@ -77,7 +68,11 @@ namespace Stratis.Bitcoin.Networks
var
genesisBlock
=
this
.
CreateDeStreamGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
this
.
GenesisTime
,
this
.
GenesisNonce
,
this
.
GenesisBits
,
this
.
GenesisVersion
,
this
.
GenesisReward
,
initialWalletAddresses
);
genesisBlock
.
Header
.
Time
=
(
uint
)
new
DateTimeOffset
(
2019
,
2
,
11
,
12
,
0
,
0
,
new
TimeSpan
()).
ToUnixTimeSeconds
();
genesisBlock
.
Header
.
Nonce
=
2433759
;
genesisBlock
.
Header
.
Bits
=
powLimit
;
this
.
Genesis
=
genesisBlock
;
// Taken from StratisX.
...
...
@@ -96,8 +91,14 @@ namespace Stratis.Bitcoin.Networks
[
BuriedDeployments
.
BIP66
]
=
0
};
//TODO: BIP9
var
bip9Deployments
=
new
StratisBIP9Deployments
()
{
[
StratisBIP9Deployments
.
ColdStaking
]
=
new
BIP9DeploymentsParameters
(
2
,
new
DateTime
(
2018
,
12
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
),
new
DateTime
(
2019
,
12
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
))
};
//TODO: BIP9
this
.
Consensus
=
new
NBitcoin
.
Consensus
(
consensusFactory
:
consensusFactory
,
consensusOptions
:
consensusOptions
,
...
...
@@ -108,12 +109,12 @@ namespace Stratis.Bitcoin.Networks
majorityRejectBlockOutdated
:
950
,
majorityWindow
:
1000
,
buriedDeployments
:
buriedDeployments
,
bip9Deployments
:
null
,
//TODO: BIP9
bip9Deployments
:
bip9Deployments
,
bip34Hash
:
new
uint256
(
"0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"
),
ruleChangeActivationThreshold
:
1916
,
// 95% of 2016
minerConfirmationWindow
:
2016
,
// nPowTargetTimespan / nPowTargetSpacing
maxReorgLength
:
500
,
defaultAssumeValid
:
new
uint256
(
"0x
55a8205ae4bbf18f4d238c43f43005bd66e0b1f679b39e2c5c62cf6903693a5
e"
),
// 795970
defaultAssumeValid
:
new
uint256
(
"0x
98fa6ef0bca5b431f15fd79dc6f879dc45b83ed4b1bbe933a383ef438321958
e"
),
// 795970
maxMoney
:
long
.
MaxValue
,
coinbaseMaturity
:
10
,
premineHeight
:
0
,
...
...
@@ -123,29 +124,18 @@ namespace Stratis.Bitcoin.Networks
powTargetSpacing
:
TimeSpan
.
FromSeconds
(
10
*
60
),
powAllowMinDifficultyBlocks
:
false
,
powNoRetargeting
:
false
,
powLimit
:
new
Target
(
new
uint256
(
"00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
))
,
powLimit
:
powLimit
,
minimumChainWork
:
null
,
isProofOfStake
:
true
,
lastPowBlock
:
1
25
00
,
lastPowBlock
:
1
0
00
,
proofOfStakeLimit
:
new
BigInteger
(
uint256
.
Parse
(
"00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
).
ToBytes
(
false
)),
proofOfStakeLimitV2
:
new
BigInteger
(
uint256
.
Parse
(
"000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff"
).
ToBytes
(
false
)),
proofOfStakeReward
:
Money
.
Zero
);
this
.
Base58Prefixes
=
new
byte
[
12
][];
this
.
Base58Prefixes
[(
int
)
Base58Type
.
PUBKEY_ADDRESS
]
=
new
byte
[]
{
66
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SCRIPT_ADDRESS
]
=
new
byte
[]
{
128
};
this
.
Base58Prefixes
[(
int
)
Base58Type
.
SECRET_KEY
]
=
new
byte
[]
{
66
+
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
};
this
.
Checkpoints
=
new
Dictionary
<
int
,
CheckpointInfo
>();
// TODO: Add genesis and premine block to Checkpoints
...
...
@@ -159,7 +149,7 @@ namespace Stratis.Bitcoin.Networks
this
.
DNSSeeds
=
new
List
<
DNSSeedData
>
{
new
DNSSeedData
(
"testnode1.destream.io"
,
"testnode1.destream.io"
)
//
new DNSSeedData("testnode1.destream.io", "testnode1.destream.io")
};
this
.
SeedNodes
=
new
List
<
NetworkAddress
>();
...
...
@@ -189,48 +179,9 @@ namespace Stratis.Bitcoin.Networks
}.
OrderBy
(
p
=>
Guid
.
NewGuid
()));
Assert
(
this
.
Consensus
.
HashGenesisBlock
==
uint256
.
Parse
(
"
95dfb30e229e18197a812ece5d8d6c03efc9b9b65a9122a73f17d99613841b1b
"
));
uint256
.
Parse
(
"
7882881de9a12aef120d13a660d6bb0075fbf305208a01ac6548d11caea8125a
"
));
Assert
(
this
.
Genesis
.
Header
.
HashMerkleRoot
==
uint256
.
Parse
(
"6598d7cc968eae6d6e66e7ac88707f5e0948b816dc8ba52433d7edc1a1f2c6a3"
));
}
protected
Block
CreateDeStreamGenesisBlock
(
ConsensusFactory
consensusFactory
,
uint
nTime
,
uint
nNonce
,
uint
nBits
,
int
nVersion
,
Money
initialCoins
,
string
[]
initialWalletAddresses
)
{
const
string
pszTimestamp
=
"DESTREAM IS THE FIRST DECENTRALIZED GLOBAL FINANCIAL ECOSYSTEM FOR STREAMERS "
+
"https://sputniknews.com/science/201810281069300462-ai-cyborg-sophia-gets-robot-visa/"
;
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
];
foreach
(
string
initialWalletAddress
in
initialWalletAddresses
)
{
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
();
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
;
uint256
.
Parse
(
"17ba0a15112b8149c485827f5a2dbbf87a60d8c9bb0d29ffe52fbf762e3ef2ec"
));
}
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Tests.Common/KnownNetworks.cs
View file @
f2d2e2e9
...
...
@@ -19,5 +19,9 @@ namespace Stratis.Bitcoin.Tests.Common
public
static
Network
StratisTest
=>
NetworkRegistration
.
GetNetwork
(
"StratisTest"
)
??
NetworkRegistration
.
Register
(
new
StratisTest
());
public
static
Network
StratisRegTest
=>
NetworkRegistration
.
GetNetwork
(
"StratisRegTest"
)
??
NetworkRegistration
.
Register
(
new
StratisRegTest
());
public
static
Network
DeStreamMain
=>
NetworkRegistration
.
GetNetwork
(
"DeStreamMain"
)
??
NetworkRegistration
.
Register
(
new
DeStreamMain
());
public
static
Network
DeStreamTest
=>
NetworkRegistration
.
GetNetwork
(
"DeStreamTest"
)
??
NetworkRegistration
.
Register
(
new
DeStreamTest
());
}
}
\ No newline at end of file
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