Example #1
0
        private Network InitMain()
        {
            Network network = new StratisMain();

            network.MoneyUnits = GetMoneyUnitsMain();
            return(network);
        }
Example #2
0
        public void MaxReorgIsCalculatedProperly()
        {
            var btc = new BitcoinMain();

            int maxReorgBtc = AddressIndexer.GetMaxReorgOrFallbackMaxReorg(btc);

            Assert.Equal(maxReorgBtc, AddressIndexer.FallBackMaxReorg);

            var stratis = new StratisMain();

            int maxReorgStratis = AddressIndexer.GetMaxReorgOrFallbackMaxReorg(stratis);

            Assert.Equal(maxReorgStratis, (int)stratis.Consensus.MaxReorgLength);
        }
Example #3
0
        public void correctly_identify_mainchain()
        {
            var stratisRegTest = new StratisRegTest();
            var chain          = stratisRegTest.ToChain();

            chain.Should().Be(Chain.Mainchain);
            chain.Should().NotBe(Chain.Sidechain);

            var stratisTest = new StratisTest();

            chain = stratisTest.ToChain();
            chain.Should().Be(Chain.Mainchain);
            chain.Should().NotBe(Chain.Sidechain);

            var stratisMain = new StratisMain();

            chain = stratisMain.ToChain();
            chain.Should().Be(Chain.Mainchain);
            chain.Should().NotBe(Chain.Sidechain);
        }
        public void Eight_Of_Fifteen_SufficientlyFunded()
        {
            var network = new StratisMain();

            const int n = 15;
            const int m = 8;

            Key[] keys = new Key[n];

            Key ultimateReceiver = new Key();

            for (int i = 0; i < n; i++)
            {
                keys[i] = new Key();
            }

            Script redeemScript = PayToMultiSigTemplate.Instance.GenerateScriptPubKey(m, keys.Select(x => x.PubKey).ToArray());

            const int     inputCount         = 50;
            const decimal fundingInputAmount = 100;
            const decimal fundingAmount      = 99; // Must be less than fundingInputAmount.

            var multiSigCoins = new List <ICoin>();

            for (int i = 0; i < inputCount; i++)
            {
                var builder = new TransactionBuilder(network);

                // Build transactions to fund the multisig
                Transaction funding = builder
                                      .AddCoins(GetCoinSource(keys[0], new[] { Money.Coins(fundingInputAmount) }))
                                      .AddKeys(keys[0])
                                      .Send(redeemScript.Hash, Money.Coins(fundingAmount))
                                      .SetChange(keys[0].PubKey.Hash)
                                      .SendFees(Money.Satoshis(5000))
                                      .BuildTransaction(true);

                multiSigCoins.Add(ScriptCoin.Create(network, funding, funding.Outputs.To(redeemScript.Hash).First(), redeemScript));
            }

            var fedPegSettings = new FederatedPegSettings(new NodeSettings(network, args: new string[]
            {
                "mainchain",
                "redeemscript=" + redeemScript.ToString(),
                "publickey=" + keys[0].PubKey.ToHex(),
                "federationips=0.0.0.0"
            }));

            // Construct the withdrawal tx
            var         txBuilder = new TransactionBuilder(network);
            Transaction tx        = txBuilder
                                    .AddCoins(multiSigCoins)
                                    .AddKeys(keys.Take(m).ToArray())
                                    .Send(ultimateReceiver.PubKey.Hash, Money.Coins(inputCount * fundingAmount - 1))
                                    .SetChange(redeemScript.Hash)
                                    .SendFees(fedPegSettings.GetWithdrawalTransactionFee(inputCount))
                                    .BuildTransaction(true);

            bool verify = txBuilder.Verify(tx, out TransactionPolicyError[] errors);

            Assert.True(verify);
        }