Exemplo n.º 1
0
        static void Main(string[] args)
        {
            P2PClient client = new P2PClient()
            {
                Signer = new ECDSASignatureProvider()
            };

            #region Connection.

            client.Connect("ws://" + Dns.GetHostName() + ":8900/simplecoin");

            Thread.Sleep(4000);

            #endregion

            #region Block sending.

            Block block = new Block(
                new byte[] { randomByte(), randomByte(), randomByte() },
                new byte[] { randomByte(), randomByte(), randomByte() },
                new Transaction[]
            {
                new Transaction
                (
                    new byte[] { randomByte(), randomByte(), randomByte() },
                    new byte[] { randomByte(), randomByte(), randomByte() },
                    random.Next(1, 100),
                    new TransactionHashFactory()
                ),
                new Transaction
                (
                    new byte[] { randomByte(), randomByte(), randomByte() },
                    new byte[] { randomByte(), randomByte(), randomByte() },
                    random.Next(1, 100),
                    new TransactionHashFactory()
                )
            },
                new KeccakFactory(512, 64)
                );

            client.SendBlock(block);

            Thread.Sleep(1000);

            #endregion

            #region Transaction sending.

            Transaction transaction = new Transaction
                                      (
                new byte[] { randomByte(), randomByte(), randomByte() },
                new byte[] { randomByte(), randomByte(), randomByte() },
                random.Next(1, 100),
                new TransactionHashFactory()
                                      );

            client.SendTransaction(transaction);

            Thread.Sleep(1000);

            #endregion

            client.Disconnect();

            client.Connect("ws://" + Dns.GetHostName() + ":8900/simplecoin");

            Thread.Sleep(1000);

            client.SendTransaction(transaction);
        }