Bring over PasswordFinderCommand stuff.
Fix wallet name logging.
Beautify wallet finder code.
MODIFY
WalletWasabi.Gui/CommandLine/CommandInterpreter.cs
WalletWasabi.Gui/CommandLine/CommandInterpreter.cs
@@ -35,7 +35,7 @@ namespace WalletWasabi.Gui.CommandLine
"Available commands are:",
"",
new MixerCommand(daemon),
- new PasswordFinderCommand(daemon)
+ new PasswordFinderCommand(global.WalletManager)
};
EnsureBackwardCompatibilityWithOldParameters(ref args);

MODIFY
WalletWasabi.Gui/CommandLine/PasswordFinderCommand.cs
WalletWasabi.Gui/CommandLine/PasswordFinderCommand.cs
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.CommandLine
{
@@ -12,16 +13,16 @@ namespace WalletWasabi.Gui.CommandLine
{
public string WalletName { get; set; }
public string EncryptedSecret { get; set; }
- public Daemon Daemon { get; }
+ public WalletManager WalletManager { get; }
public string Language { get; set; }
public bool UseNumbers { get; set; }
public bool UseSymbols { get; set; }
public bool ShowHelp { get; set; }
- public PasswordFinderCommand(Daemon daemon)
+ public PasswordFinderCommand(WalletManager walletManager)
: base("findpassword", "Try to find typos in provided password.")
{
- Daemon = daemon;
+ WalletManager = Guard.NotNull(nameof(walletManager), walletManager);
Language = "en";
Options = new OptionSet()
@@ -64,11 +65,7 @@ namespace WalletWasabi.Gui.CommandLine
}
else if (!string.IsNullOrWhiteSpace(WalletName))
{
- KeyManager km = Daemon.TryGetKeyManagerFromWalletName(WalletName);
- if (km is null)
- {
- error = true;
- }
+ KeyManager km = WalletManager.GetWalletByName(WalletName).KeyManager;
PasswordFinder.Find(km.EncryptedSecret.ToWif(), Language, UseNumbers, UseSymbols);
}
else if (!string.IsNullOrWhiteSpace(EncryptedSecret))

MODIFY
WalletWasabi/Wallets/WalletManager.cs
WalletWasabi/Wallets/WalletManager.cs
@@ -360,16 +360,20 @@ namespace WalletWasabi.Wallets
public Wallet GetWalletByName(string walletName)
{
- Wallet wallet = null;
+ Wallet wallet;
lock (Lock)
{
wallet = Wallets.Keys.FirstOrDefault(x => x.KeyManager.WalletName == walletName);
}
+
if (wallet is null)
{
- throw new FileNotFoundException($"Wallet name:{wallet} not found.");
+ throw new FileNotFoundException($"Wallet name:{wallet.WalletName} not found.");
}
+ else
+ {
return wallet;
}
}
}
+}

Bring over PasswordFinderCommand stuff.
Fix wallet name logging.
Beautify wallet finder code.