Skip to content

Commit

Permalink
Upload from local repo
Browse files Browse the repository at this point in the history
  • Loading branch information
noescape00 committed Jun 8, 2021
1 parent c561e75 commit 95e5c34
Show file tree
Hide file tree
Showing 72 changed files with 10,793 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Unity3dIntegration
# Unity3d_Stratis



Unity3d client for Stratis.
Binary file added Resources/StratisUnity3d_v1.unitypackage
Binary file not shown.
59 changes: 59 additions & 0 deletions Src/StratisUnity3d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties
6 changes: 6 additions & 0 deletions Src/StratisUnity3d/.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
8 changes: 8 additions & 0 deletions Src/StratisUnity3d/Assets/Code.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Src/StratisUnity3d/Assets/Code/Dependencies.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Src/StratisUnity3d/Assets/Code/Dependencies/CirrusNetwork.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using NBitcoin;
using NBitcoin.DataEncoders;

namespace Stratis.Sidechains.Networks
{
public static class CirrusNetwork
{
/// <summary> The name of the root folder containing the different side chain block data.</summary>
public const string NetworkRootFolderName = "cirrus";

/// <summary> The default name used for the side chain configuration file. </summary>
public const string NetworkDefaultConfigFilename = "cirrus.conf";

public static Block CreateGenesis(ConsensusFactory consensusFactory, uint genesisTime, uint nonce, uint bits, int version, Money reward, string coinbaseText)
{
Transaction genesisTransaction = consensusFactory.CreateTransaction();
// TODO: Remove Cirrus networks from this solution?
//genesisTransaction.Time = genesisTime;
genesisTransaction.Version = 1;
genesisTransaction.AddInput(new TxIn()
{
ScriptSig = new Script(Op.GetPushOp(0), new Op()
{
Code = (OpcodeType)0x1,
PushData = new[] { (byte)42 }
}, Op.GetPushOp(Encoders.ASCII.DecodeData(coinbaseText)))
});

genesisTransaction.AddOutput(new TxOut()
{
Value = reward
});

Block genesis = consensusFactory.CreateBlock();
genesis.Header.BlockTime = Utils.UnixTimeToDateTime(genesisTime);
genesis.Header.Bits = bits;
genesis.Header.Nonce = nonce;
genesis.Header.Version = version;
genesis.Transactions.Add(genesisTransaction);
genesis.Header.HashPrevBlock = uint256.Zero;
genesis.UpdateMerkleRoot();

return genesis;
}
}
}
11 changes: 11 additions & 0 deletions Src/StratisUnity3d/Assets/Code/Dependencies/CirrusNetwork.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Src/StratisUnity3d/Assets/Code/Dependencies/Networks.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 161 additions & 0 deletions Src/StratisUnity3d/Assets/Code/Dependencies/Networks/CirrusMain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using NBitcoin;
using NBitcoin.DataEncoders;

namespace Stratis.Sidechains.Networks
{
public class CirrusMain : Network
{
public CirrusMain()
{
this.Name = "CirrusMain";
this.NetworkType = NetworkType.Mainnet;
this.CoinTicker = "CRS";
this.Magic = 0x522357AC;
this.DefaultPort = 16179;
this.DefaultMaxOutboundConnections = 16;
this.DefaultMaxInboundConnections = 109;
this.DefaultRPCPort = 16175;
this.DefaultAPIPort = 37223;
this.DefaultSignalRPort = 38823;
this.MaxTipAge = 768; // 20% of the fastest time it takes for one MaxReorgLength of blocks to be mined.
this.MinTxFee = 10000;
this.FallbackFee = 10000;
this.MinRelayTxFee = 10000;
this.RootFolderName = CirrusNetwork.NetworkRootFolderName;
this.DefaultConfigFilename = CirrusNetwork.NetworkDefaultConfigFilename;
this.MaxTimeOffsetSeconds = 25 * 60;
this.DefaultBanTimeSeconds = 1920; // 240 (MaxReorg) * 16 (TargetSpacing) / 2 = 32 Minutes

this.CirrusRewardDummyAddress = "CPqxvnzfXngDi75xBJKqi4e6YrFsinrJka";

var consensusFactory = new ConsensusFactory();

// Create the genesis block.
this.GenesisTime = 1561982325;
this.GenesisNonce = 3038481;
this.GenesisBits = new Target(new uint256("00000fffff000000000000000000000000000000000000000000000000000000"));
this.GenesisVersion = 1;
this.GenesisReward = Money.Zero;

string coinbaseText = "https://github.com/stratisproject/StratisBitcoinFullNode";
Block genesisBlock = CirrusNetwork.CreateGenesis(consensusFactory, this.GenesisTime, this.GenesisNonce, this.GenesisBits, this.GenesisVersion, this.GenesisReward, coinbaseText);

this.Genesis = genesisBlock;

this.Federations = new Federations();
var straxFederationTransactionSigningKeys = new List<PubKey>()
{
new PubKey("03797a2047f84ba7dcdd2816d4feba45ae70a59b3aa97f46f7877df61aa9f06a21"),
new PubKey("0209cfca2490dec022f097114090c919e85047de0790c1c97451e0f50c2199a957"),
new PubKey("032e4088451c5a7952fb6a862cdad27ea18b2e12bccb718f13c9fdcc1caf0535b4"),
new PubKey("035bf78614171397b080c5b375dbb7a5ed2a4e6fb43a69083267c880f66de5a4f9"),
new PubKey("02387a219b1de54d4dc73a710a2315d957fc37ab04052a6e225c89205b90a881cd"),
new PubKey("028078c0613033e5b4d4745300ede15d87ed339e379daadc6481d87abcb78732fa"),
new PubKey("02b3e16d2e4bbad6dba1e699934a52d58d9b60b6e7eed303e400e95f2dbc2ef3fd"),
new PubKey("02ba8b842997ce50c8e29c24a5452de5482f1584ae79778950b7bae24d4cc68dad"),
new PubKey("02cbd907b0bf4d757dee7ea4c28e63e46af19dc8df0c924ee5570d9457be2f4c73"),
new PubKey("02d371f3a0cffffcf5636e6d4b79d9f018a1a18fbf64c39542b382c622b19af9de"),
new PubKey("02f891910d28fc26f272da8d7f548fdc18c286704907673e839dc07e8df416c15e"),
new PubKey("0337e816a3433c71c4bbc095a54a0715a6da7a70526d2afb8dba3d8d78d33053bf"),
new PubKey("035569e42835e25c854daa7de77c20f1009119a5667494664a46b5154db7ee768a"),
new PubKey("03cda7ea577e8fbe5d45b851910ec4a795e5cc12d498cf80d39ba1d9a455942188"),
new PubKey("02680321118bce869933b07ea42cc04d2a2804134b06db582427d6b9688b3536a4")
};

// Register the new set of federation members.
this.Federations.RegisterFederation(new Federation(straxFederationTransactionSigningKeys));

var buriedDeployments = new BuriedDeploymentsArray
{
[BuriedDeployments.BIP34] = 0,
[BuriedDeployments.BIP65] = 0,
[BuriedDeployments.BIP66] = 0
};

var bip9Deployments = new NoBIP9Deployments();

this.Consensus = new Consensus(
consensusFactory: consensusFactory,
consensusOptions: null,
coinType: 401,
hashGenesisBlock: genesisBlock.GetHash(),
subsidyHalvingInterval: 210000,
majorityEnforceBlockUpgrade: 750,
majorityRejectBlockOutdated: 950,
majorityWindow: 1000,
buriedDeployments: buriedDeployments,
bip9Deployments: bip9Deployments,
bip34Hash: new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"),
minerConfirmationWindow: 2016, // nPowTargetTimespan / nPowTargetSpacing
maxReorgLength: 240, // Heuristic. Roughly 2 * mining members
defaultAssumeValid: new uint256("0xbfd4a96a6c5250f18bf7c586761256fa5f8753ffa10b24160f0648a452823a95"), // 1400000
maxMoney: Money.Coins(100_000_000),
coinbaseMaturity: 1,
premineHeight: 2,
premineReward: Money.Coins(100_000_000),
proofOfWorkReward: Money.Coins(0),
powTargetTimespan: TimeSpan.FromDays(14), // two weeks
targetSpacing: TimeSpan.FromSeconds(16),
powAllowMinDifficultyBlocks: false,
posNoRetargeting: false,
powNoRetargeting: true,
powLimit: null,
minimumChainWork: null,
isProofOfStake: false,
lastPowBlock: 0,
proofOfStakeLimit: null,
proofOfStakeLimitV2: null,
proofOfStakeReward: Money.Zero
);

// Same as current smart contracts test networks to keep tests working
this.Base58Prefixes = new byte[12][];
this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { 28 }; // C
this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { 88 }; // c
this.Base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (239) };
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), (0x35), (0x87), (0xCF) };
this.Base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x35), (0x83), (0x94) };
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[] { 0x2b };
this.Base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 115 };
this.Base58Prefixes[(int)Base58Type.COLORED_ADDRESS] = new byte[] { 0x13 };

Bech32Encoder encoder = Encoders.Bech32("tb");
this.Bech32Encoders = new Bech32Encoder[2];
this.Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder;
this.Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder;

this.StandardScriptsRegistry = new PoAStandardScriptsRegistry();

Assert(this.DefaultBanTimeSeconds <= this.Consensus.MaxReorgLength * this.Consensus.TargetSpacing.TotalSeconds / 2);
Assert(this.Consensus.HashGenesisBlock == uint256.Parse("000005769503496300ec879afd7543dc9f86d3b3d679950b2b83e2f49f525856"));
Assert(this.Genesis.Header.HashMerkleRoot == uint256.Parse("1669a55d45b642af0ce82c5884cf5b8d8efd5bdcb9a450c95f442b9bd1ff65ea"));
}
}

/// <summary>
/// PoA-specific standard transaction definitions.
/// </summary>
public class PoAStandardScriptsRegistry : StandardScriptsRegistry
{
public const int MaxOpReturnRelay = 153;

private static readonly List<ScriptTemplate> scriptTemplates = new List<ScriptTemplate>
{
{ new PayToPubkeyHashTemplate() },
{ new PayToPubkeyTemplate() },
{ new PayToScriptHashTemplate() },
{ new PayToMultiSigTemplate() },
{ new PayToFederationTemplate() },
{ new TxNullDataTemplate(MaxOpReturnRelay) },
{ new PayToWitTemplate() }
};

public override List<ScriptTemplate> GetScriptTemplates => scriptTemplates;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95e5c34

Please sign in to comment.