public static void GetPassword(out string password) { password = string.Empty; string inputPassword = string.Empty; string confirmPassword = string.Empty; bool shouldContinue = true; do { Console.WriteLine("Plase Enter Password: Password must be at least 6 symbols long .Do not forget the password!\n"); while (true) { var key = System.Console.ReadKey(true); if (key.Key == ConsoleKey.Enter) { break; } inputPassword += key.KeyChar; } CommonWalletHelper.CheckForSpecialCommand(inputPassword.ToLower()); shouldContinue = inputPassword.Length > 6; } while (shouldContinue); Console.WriteLine("Write password again to confirm: "); shouldContinue = true; do { while (true) { var key = System.Console.ReadKey(true); if (key.Key == ConsoleKey.Enter) { break; } confirmPassword += key.KeyChar; } CommonWalletHelper.CheckForSpecialCommand(confirmPassword.ToLower()); shouldContinue = !inputPassword.Equals(confirmPassword); if (shouldContinue) { Console.WriteLine("Password does not match !\n"); } else { Console.WriteLine("Password set!Do not forget it !\n Console will be cleared after 3 seconds"); Thread.Sleep(3000); Console.Clear(); } } while (shouldContinue); password = CryptoHelper.GetSHA256(inputPassword); }
public static void SelectNetwork(out Network network) { network = null; bool shouldContinue = true; Console.WriteLine(); string bitcoinNetworkInput; while (shouldContinue) { Console.WriteLine("Please enter 0 for test bitcoin network and 1 for real network\n"); bitcoinNetworkInput = Console.ReadLine(); CommonWalletHelper.CheckForSpecialCommand(bitcoinNetworkInput.ToLower()); byte selectedNetwordId = byte.MaxValue; if (bitcoinNetworkInput.ToLower() == "\\exit") { Console.WriteLine("Exiting Wallet..."); Thread.Sleep(1000); break; } try { selectedNetwordId = byte.Parse(bitcoinNetworkInput); switch (selectedNetwordId) { case 0: network = Network.TestNet; shouldContinue = false; Console.WriteLine("You successfuly selected TEST bitcoin network\n", ConsoleColor.DarkGreen); break; case 1: network = Network.Main; Console.WriteLine("You successfuly selected MAIN bitcoin network. Using Main network is at your own risk!\n", ConsoleColor.DarkRed); shouldContinue = false; break; default: Console.WriteLine("Invalid Input!"); break; } } catch (Exception) { Console.WriteLine("Invalid input format format!\n"); } } }
public static void PrintInformation(Safe safe, string filePath, Mnemonic mnemonic, string password) { Console.WriteLine("Wallet file location: {0}\n", filePath); Console.WriteLine("Password: {0}\n", password); Console.WriteLine("Please write down the mnemonic phrases!If you lose your .json file\nthe only way to recover it is mnemonic + password!"); Console.WriteLine("Mnemonic: {0}\n", mnemonic); var address = CommonWalletHelper.GenerateBitcointAddress(safe); var privateKey = CommonWalletHelper.GetPrivateKey(safe, address); Console.WriteLine("IMPORTANT! This is your private key! Do not lose it\nand do not show it to anyone!If your private key\nis compromised, you will lose all of your bitcoins!\n"); Console.WriteLine("PRIVATE KEY: {0}\n", privateKey); Console.WriteLine("This is your first bitcoin address! : {0}\n", address); Console.WriteLine("Network : {0}\n", safe.Network); var publicKey = safe.GetBitcoinExtPubKey(); Console.WriteLine("This is your public key: {0}", publicKey); }