public Form1() { InitializeComponent(); wallet = new Wallet(Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%") + "\\thyme\\wallet"); //wallet.Accounts.Add(new Account()); //bindingSource.DataSource = wallet.Accounts;//.Select(item => new { Address = item.Address, Label = item.Label, Amount = 0 }).ToArray(); //bindingSource.AllowNew = false; //dataGridView1.DataSource = bindingSource; //dataGridView1.AutoGenerateColumns = false; this.dataGridView1.DataSource = wallet.Accounts.Select(item => new { Address = item.Address, Label = item.Label, Amount = 0 }).ToArray(); //this.dataGridView1.Columns[0]. wallet.Save(); }
static void Main(string[] args) { Console.WriteLine(DateTime.Now); const int difficulty = 12; Wallet w = new Wallet(Environment.ExpandEnvironmentVariables(@"C:\Users\ico\thyme\wallet")); w.Accounts.Clear(); for (int i = 0; i < 5; ++i) { w.Accounts.Add(new Account()); } Random rnd = new Random(); //setup consensus Consensus consensus = new Consensus(); Block block = new Block(); //initialize genesis block var finderIndex = rnd.Next(5); block.data.finderAddress = w.Accounts[finderIndex].Address; block.data.transactionsList = new Tx[] {}; block.data.register = w.Accounts.Select(i => new RegisterRecord() {address = i.Address, amount = 0}).ToArray(); block.data.register[finderIndex].amount = 25; block.data.prevHash = new byte[] { }; consensus.Work(block, difficulty); Console.WriteLine(DateTime.Now); printRegister(consensus, w.Accounts.Select(i => i.Address).ToList()); while (true) { Console.WriteLine(" ------ "); block = new Block(consensus.Blocks[consensus.Blocks.Count - 1].data.getHash); block.data.finderAddress = w.Accounts[rnd.Next(5)].Address; List<Tx> txList = new List<Tx>(); foreach (var acc in w.Accounts) { foreach (var reciever in w.Accounts) { ulong money = (ulong)rnd.Next((int)consensus.QueryMoney(acc.Address) / 5); if (money > 0 && acc != reciever) { Transaction t = new Transaction(acc.Address, reciever.Address, money, DateTime.Now); Tx tx = new Tx(); tx.t = t; tx.senderPublicKey = acc.PublicKey; tx.Sign(acc.keyPair.Private); txList.Add(tx); } } } block.data.transactionsList = txList.ToArray(); consensus.Work(block, difficulty); Console.WriteLine(DateTime.Now); for (int i = 0; i < block.data.transactionsList.Length; ++i) { Console.WriteLine("{0} transferred {1} to {2}", block.data.transactionsList[i].t.sender, block.data.transactionsList[i].t.money, block.data.transactionsList[i].t.reciever); } Console.WriteLine("{0} recieved 25 for finding a block\n", block.data.finderAddress); printRegister(consensus, w.Accounts.Select(i => i.Address).ToList()); } Console.WriteLine("Something went wrong"); }