Пример #1
0
        public static void LoadWallet(out Safe safe)
        {
            safe = null;
            string path;
            bool   @continue = true;
            string password;

            Console.WriteLine();
            RecoverWalletHelper.GetPassword(out password);
            do
            {
                Console.WriteLine("Please enter the full file path of the wallet json file:");
                path      = Console.ReadLine();
                @continue = !CommonWalletHelper.CheckDirectory(path);
            } while (@continue);
            Console.WriteLine("Please enter the name of the wallet: ");
            var name = Console.ReadLine();

            RecoverWalletHelper.LoadFromExistingWalletFile(password, string.Format("{0}\\{1}", path, name), out safe);
            _safe = safe;
            var sha256Public = CryptoHelper.GetSHA256(safe.GetBitcoinExtPubKey().ToString());

            if (!CommonWalletHelper.IsWalletSavedInConfig(_config, sha256Public))
            {
                CommonWalletHelper.AddNewRecordInWalletConfig(_config, sha256Public);
            }
        }
Пример #2
0
 private static void RecoverWallet(out Safe safe)
 {
     safe = null;
     try
     {
         Mnemonic mnemonic;
         string   password;
         byte     selectedWay;
         Console.WriteLine("IMPORTANT!: The wallet cannot check if the password you passed is correct", ConsoleColor.Red);
         Console.WriteLine("Recovery required valid password and mnemonic phrase");
         RecoverWalletHelper.GetPassword(out password);
         RecoverWalletHelper.GetSelectedWayOfMnemonicInput(out selectedWay);
         if (selectedWay == 0)
         {
             RecoverWalletHelper.LoadMnemonicFromFile(out mnemonic);
         }
         else
         {
             RecoverWalletHelper.LoadMnemonicFromInput(out mnemonic);
         }
         Network network;
         CommonWalletHelper.SelectNetwork(out network);
         string directoryPath;
         CommonWalletHelper.GetDirectoryPath(out directoryPath);
         RecoverWalletHelper.TryRecoverWallet(password, mnemonic, directoryPath, network, out safe);
         Console.WriteLine("Wallet successfuly recoverd!");
         _safe = safe;
         var sha256Public = CryptoHelper.GetSHA256(safe.GetBitcoinExtPubKey().ToString());
         if (!CommonWalletHelper.IsWalletSavedInConfig(_config, sha256Public))
         {
             CommonWalletHelper.AddNewRecordInWalletConfig(_config, sha256Public);
         }
     }
     catch (Exception)
     {
         Console.WriteLine("Recovery FAILED!");
     }
 }