コード例 #1
0
 public override Task <int> InvokeAsync(IEnumerable <string> args)
 {
     try
     {
         Options.Parse(args);
         if (ShowHelp)
         {
             Options.WriteOptionDescriptions(CommandSet.Out);
         }
         else if (string.IsNullOrWhiteSpace(WalletName) && string.IsNullOrWhiteSpace(EncryptedSecret))
         {
             throw new InvalidOperationException("Missing required argument `--wallet=WalletName`. Use `findpassword --help` for details.");
         }
         else if (!PasswordFinder.Charsets.ContainsKey(Language))
         {
             throw new InvalidOperationException($"`{Language}` is not available language, try with `en, es, pt, it or fr`. Use `findpassword --help` for details.");
         }
         else if (!string.IsNullOrWhiteSpace(WalletName))
         {
             KeyManager km = WalletManager.GetWalletByName(WalletName).KeyManager;
             PasswordFinder.Find(km.EncryptedSecret.ToWif(), Language, UseNumbers, UseSymbols);
         }
         else if (!string.IsNullOrWhiteSpace(EncryptedSecret))
         {
             PasswordFinder.Find(EncryptedSecret, Language, UseNumbers, UseSymbols);
         }
     }
     catch (Exception ex)
     {
         return(Task.FromException <int>(ex));
     }
     return(Task.FromResult(0));
 }
コード例 #2
0
        public override Task <int> InvokeAsync(IEnumerable <string> args)
        {
            var error = false;

            try
            {
                var extra = Options.Parse(args);
                if (ShowHelp)
                {
                    Options.WriteOptionDescriptions(CommandSet.Out);
                }
                else if (string.IsNullOrWhiteSpace(WalletName) && string.IsNullOrWhiteSpace(EncryptedSecret))
                {
                    Logging.Logger.LogCritical <PasswordFinderCommand>("Missing required argument `--wallet=WalletName`.");
                    Logging.Logger.LogCritical <PasswordFinderCommand>("Use `findpassword --help` for details.");
                    error = true;
                }
                else if (!PasswordFinder.Charsets.ContainsKey(Language))
                {
                    Logging.Logger.LogCritical <PasswordFinderCommand>($"`{Language}` is not available language try with `en, es, pt, it or fr`.");
                    Logging.Logger.LogCritical <PasswordFinderCommand>("Use `findpassword --help` for details.");
                    error = true;
                }
                else if (!string.IsNullOrWhiteSpace(WalletName))
                {
                    KeyManager km = Daemon.TryGetKeyManagerFromWalletName(WalletName);
                    if (km is null)
                    {
                        error = true;
                    }
                    PasswordFinder.Find(km.EncryptedSecret.ToWif(), Language, UseNumbers, UseSymbols);
                }
                else if (!string.IsNullOrWhiteSpace(EncryptedSecret))
                {
                    PasswordFinder.Find(EncryptedSecret, Language, UseNumbers, UseSymbols);
                }
            }
            catch (Exception)
            {
                Logging.Logger.LogCritical <PasswordFinderCommand>($"There was a problem interpreting the command, please review it.");
                error = true;
            }
            Environment.Exit(error ? 1 : 0);
            return(Task.FromResult(0));
        }