コード例 #1
0
        static void Main(string[] args)
        {
            IAddressTransaction txn5 = SetupTransactions();

            //Only needed if we want it to be a private blockchain
            //IKeyStore keyStore = new KeyStore(Hmac.GenerateKey());
            IKeyStore keyStore = null;

            IBlock <IAddressTransaction> block1 = new Block(0, keyStore, 3);
            IBlock <IAddressTransaction> block2 = new Block(1, keyStore, 3);
            IBlock <IAddressTransaction> block3 = new Block(2, keyStore, 3);
            IBlock <IAddressTransaction> block4 = new Block(3, keyStore, 3);

            AddTransactionsToBlocksAndCalculateHashes(block1, block2, block3, block4);

            BlockChain chain = new BlockChain();

            chain.AcceptBlock(block1);
            chain.AcceptBlock(block2);
            chain.AcceptBlock(block3);
            chain.AcceptBlock(block4);

            chain.VerifyChain();

            Console.WriteLine("");
            Console.WriteLine("");

            Console.WriteLine("=========================");
            Console.WriteLine($"{pubAddress1}' balance: {chain.GetBalance(pubAddress1)}");

            ((IClaimOutput)txn5.Outputs[0]).ClaimNumber = "weqwewe";
            chain.VerifyChain();

            Console.WriteLine();

            Console.WriteLine("=========================");
            Console.WriteLine($"Chain");
            Console.WriteLine(JsonConvert.SerializeObject(chain, Formatting.Indented));

            Console.ReadKey();
        }