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
55c66483
Commit
55c66483
authored
6 years ago
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge network registration
parent
4dde29ea
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
429 additions
and
297 deletions
+429
-297
DeStream.Networks.cs
Sources/NBitcoin/DeStream.Networks.cs
+0
-71
DeStreamNetwork.cs
Sources/NBitcoin/DeStreamNetwork.cs
+73
-0
DeStreamRegTest.cs
Sources/NBitcoin/Networks/DeStreamRegTest.cs
+0
-79
DeStreamMain.cs
Sources/Stratis.Bitcoin.Networks/DeStreamMain.cs
+119
-143
DeStreamTest.cs
Sources/Stratis.Bitcoin.Networks/DeStreamTest.cs
+236
-0
Stratis.Bitcoin.Networks.csproj
.../Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj
+1
-4
No files found.
Sources/NBitcoin/DeStream.Networks.cs
deleted
100644 → 0
View file @
4dde29ea
using
NBitcoin.DataEncoders
;
using
NBitcoin.Networks
;
namespace
NBitcoin
{
public
partial
class
Network
{
/// <summary>
/// The name of the root folder containing the different Stratis blockchains (StratisMain, StratisTest,
/// StratisRegTest).
/// </summary>
protected
const
string
DeStreamRootFolderName
=
"destream"
;
/// <summary> The default name used for the Stratis configuration file. </summary>
protected
const
string
DeStreamDefaultConfigFilename
=
"destream.conf"
;
protected
const
int
DeStreamMaxTimeOffsetSeconds
=
25
*
60
;
protected
const
int
DeStreamDefaultMaxTipAgeInSeconds
=
2
*
60
*
60
;
public
const
string
WalletAddressDeStreamMain
=
"TPPL2wmtxGzP8U6hQsGkRA9yCMsazB33ft"
;
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
DeStreamRegTest
=>
NetworksContainer
.
GetNetwork
(
"DeStreamRegTest"
)
??
NetworksContainer
.
Register
(
new
DeStreamRegTest
());
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"
;
return
CreateStratisGenesisBlock
(
consensusFactory
,
pszTimestamp
,
nTime
,
nNonce
,
nBits
,
nVersion
,
genesisReward
);
}
private
static
Block
CreateStratisGenesisBlock
(
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
)))
});
txNew
.
AddOutput
(
new
TxOut
{
Value
=
genesisReward
});
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
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Sources/NBitcoin/DeStreamNetwork.cs
0 → 100644
View file @
55c66483
using
System
;
using
System.Collections.Generic
;
using
NBitcoin.DataEncoders
;
namespace
NBitcoin
{
public
abstract
class
DeStreamNetwork
:
Network
{
/// <summary>
/// The name of the root folder containing the different Stratis blockchains (StratisMain, StratisTest,
/// StratisRegTest).
/// </summary>
protected
const
string
DeStreamRootFolderName
=
"destream"
;
/// <summary> The default name used for the Stratis configuration file. </summary>
protected
const
string
DeStreamDefaultConfigFilename
=
"destream.conf"
;
protected
const
int
DeStreamMaxTimeOffsetSeconds
=
25
*
60
;
protected
const
int
DeStreamDefaultMaxTipAgeInSeconds
=
2
*
60
*
60
;
protected
LinkedList
<
string
>
DeStreamWallets
;
public
string
GenesisWalletAddress
{
get
;
protected
set
;
}
private
LinkedListNode
<
string
>
DeStreamWalletsNode
{
get
;
set
;
}
public
string
DeStreamWallet
{
get
{
DeStreamWalletsNode
=
DeStreamWalletsNode
.
NextOrFirst
()
??
DeStreamWallets
.
First
;
return
DeStreamWalletsNode
.
Value
;
}
}
/// <summary>
/// </summary>
public
double
DeStreamFeePart
{
get
;
set
;
}
/// <summary>
/// Fee applied to all transactions
/// </summary>
public
double
FeeRate
{
get
;
set
;
}
/// <summary>
/// Splits fee between miner and DeStream
/// </summary>
/// <param name="fee">Total amount of fees to be split</param>
/// <param name="deStreamFee">DeStream fee part</param>
/// <param name="minerReward">Miner fee part</param>
public
void
SplitFee
(
long
fee
,
out
long
deStreamFee
,
out
long
minerReward
)
{
deStreamFee
=
Convert
.
ToInt64
(
fee
*
DeStreamFeePart
);
minerReward
=
fee
-
deStreamFee
;
}
/// <summary>
/// Subtracts fee from sum of fees and transfer funds
/// </summary>
/// <param name="value">Sum of fees and transfer funds</param>
/// <returns>Transfer funds without fees</returns>
public
Money
SubtractFee
(
Money
value
)
{
return
Convert
.
ToInt64
(
value
.
Satoshi
/
(
1.0
+
FeeRate
));
}
public
bool
IsDeStreamAddress
(
string
address
)
{
return
DeStreamWallets
.
Contains
(
address
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Sources/NBitcoin/Networks/DeStreamRegTest.cs
deleted
100644 → 0
View file @
4dde29ea
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
NBitcoin.BouncyCastle.Math
;
using
NBitcoin.DataEncoders
;
namespace
NBitcoin.Networks
{
public
class
DeStreamRegTest
:
Network
{
public
DeStreamRegTest
()
{
// TODO: move this to Networks
var
messageStart
=
new
byte
[
4
];
messageStart
[
0
]
=
0xcd
;
messageStart
[
1
]
=
0xf2
;
messageStart
[
2
]
=
0xc0
;
messageStart
[
3
]
=
0xef
;
var
magic
=
BitConverter
.
ToUInt32
(
messageStart
,
0
);
// 0xefc0f2cd
this
.
Name
=
"DeStreamRegTest"
;
this
.
RootFolderName
=
DeStreamRootFolderName
;
this
.
DefaultConfigFilename
=
DeStreamDefaultConfigFilename
;
this
.
Magic
=
magic
;
this
.
DefaultPort
=
18444
;
this
.
RPCPort
=
18442
;
this
.
MaxTimeOffsetSeconds
=
DeStreamMaxTimeOffsetSeconds
;
this
.
MaxTipAge
=
DeStreamDefaultMaxTipAgeInSeconds
;
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
(
uint256
.
Parse
(
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
));
this
.
Consensus
.
PowTargetTimespan
=
TimeSpan
.
FromSeconds
(
14
*
24
*
60
*
60
);
// two weeks
this
.
Consensus
.
PowTargetSpacing
=
TimeSpan
.
FromSeconds
(
10
*
60
);
this
.
Consensus
.
PowAllowMinDifficultyBlocks
=
true
;
this
.
Consensus
.
PowNoRetargeting
=
true
;
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
=
null
;
// turn off assumevalid for regtest.
Block
genesis
=
CreateStratisGenesisBlock
(
this
.
Consensus
.
ConsensusFactory
,
1470467000
,
1831645
,
0x1e0fffff
,
1
,
Money
.
Zero
);
genesis
.
Header
.
Time
=
1494909211
;
genesis
.
Header
.
Nonce
=
2433759
;
genesis
.
Header
.
Bits
=
this
.
Consensus
.
PowLimit
;
this
.
Genesis
=
genesis
;
this
.
Consensus
.
HashGenesisBlock
=
genesis
.
GetHash
();
Assert
(
this
.
Consensus
.
HashGenesisBlock
==
uint256
.
Parse
(
"0x93925104d664314f581bc7ecb7b4bad07bcfabd1cfce4256dbd2faddcf53bd1f"
));
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
};
var
encoder
=
new
Bech32Encoder
(
"bc"
);
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_PUBKEY_ADDRESS
]
=
encoder
;
this
.
Bech32Encoders
[(
int
)
Bech32Type
.
WITNESS_SCRIPT_ADDRESS
]
=
encoder
;
}
}
}
This diff is collapsed.
Click to expand it.
Sources/
NBitcoin/
Networks/DeStreamMain.cs
→
Sources/
Stratis.Bitcoin.
Networks/DeStreamMain.cs
View file @
55c66483
This diff is collapsed.
Click to expand it.
Sources/
NBitcoin/
Networks/DeStreamTest.cs
→
Sources/
Stratis.Bitcoin.
Networks/DeStreamTest.cs
View file @
55c66483
This diff is collapsed.
Click to expand it.
Sources/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj
View file @
55c66483
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<Description>Stratis Bitcoin FullNode</Description>
<Description>Stratis Bitcoin FullNode</Description>
<AssemblyTitle>Stratis.Bitcoin.Networks</AssemblyTitle>
<AssemblyTitle>Stratis.Bitcoin.Networks</AssemblyTitle>
...
@@ -18,9 +17,7 @@
...
@@ -18,9 +17,7 @@
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<CodeAnalysisRuleSet>..\None.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\None.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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