public bool LoadWallet()
        {
            SeedWords = Guard.Correct(SeedWords);
            Password  = Guard.Correct(Password);            // Do not let whitespaces to the beginning and to the end.

            string walletFilePath = Path.Combine(Global.WalletManager.WalletDirectories.WalletsDir, $"{Global.Network}.json");
            bool   isLoadSuccessful;

            try
            {
                KeyPath.TryParse(ACCOUNT_KEY_PATH, out KeyPath keyPath);

                var mnemonic = new Mnemonic(SeedWords);
                var km       = KeyManager.Recover(mnemonic, Password, filePath: null, keyPath, MIN_GAP_LIMIT);
                km.SetNetwork(Global.Network);
                km.SetFilePath(walletFilePath);
                Global.WalletManager.AddWallet(km);
                Hsm.SetAsync($"{Global.Network}-seedWords", SeedWords.ToString());                 // PROMPT
                Global.UiConfig.HasSeed = true;
                Global.UiConfig.ToFile();
                isLoadSuccessful = true;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                isLoadSuccessful = false;
            }
            return(isLoadSuccessful);
        }
Пример #2
0
 /// <summary>
 /// Seeds the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="host">The host.</param>
 /// <param name="builder">The builder.</param>
 private static void Seed(SpellingContext context, IHostingEnvironment host, IApplicationBuilder builder)
 {
     SeedUsers.Seed(context);
     SeedWords.Seed(context);
 }