public WalletHandler(FullWallet wallet, IBlockChainClient blockChainClient) { Wallet = wallet; BlockChainClient = blockChainClient; //new KeyValuePair<string, Action>("accounts",Accounts) Commands.Add("accounts", ViewAccounts); Commands.Add("send", Send); Commands.Add("close", CloseWallet); }
public static void PrintWalletAccounts(FullWallet wallet, IBlockChainClient blockChainClient) { var accounts = wallet.GetAccounts(); ulong totalBallance = 0; ulong totalUnconfirmedBallance = 0; for (int i = 0; i < accounts.Count; i++) { Console.WriteLine($"**** Account {i}"); Console.WriteLine($"PrivateKey: " + accounts[i].PrivateKey); Console.WriteLine($"Address: " + accounts[i].Address); try { ulong ballance = blockChainClient.GetBalance(accounts[i].Address); totalBallance += ballance; ulong unconfirmedBallance = blockChainClient.GetBalance(accounts[i].Address, true); totalUnconfirmedBallance += unconfirmedBallance; Console.WriteLine($"Balance: " + ballance.GetFormattedTokens()); if (ballance != unconfirmedBallance) { Console.WriteLine($"Unconfirmed: " + unconfirmedBallance.GetFormattedTokens()); } } catch (Exception) { Output.WriteError("Cannot retreive balance, could not connect to node"); } Console.WriteLine(); Console.WriteLine(); } Console.WriteLine($"Total balance: {totalBallance.GetFormattedTokens()}"); if (totalUnconfirmedBallance > 0 && totalUnconfirmedBallance != totalBallance) { Console.WriteLine($"Total Unconfirmed balance: {totalUnconfirmedBallance.GetFormattedTokens()}"); } }