Add secret and enable specifying wallet name
MODIFY
WalletWasabi.Gui/CommandLine/Daemon.cs
WalletWasabi.Gui/CommandLine/Daemon.cs
@@ -32,32 +32,9 @@ namespace WalletWasabi.Gui.CommandLine
}
Logger.LogStarting("Wasabi");
- KeyManager keyManager = null;
- if (walletName != null)
- {
- var walletFullPath = Global.GetWalletFullPath(walletName);
- var walletBackupFullPath = Global.GetWalletBackupFullPath(walletName);
- if (!File.Exists(walletFullPath) && !File.Exists(walletBackupFullPath))
- {
- // The selected wallet is not available any more (someone deleted it?).
- Logger.LogCritical("The selected wallet doesn't exsist, did you delete it?", nameof(Daemon));
- return;
- }
-
- try
- {
- keyManager = Global.LoadKeyManager(walletFullPath, walletBackupFullPath);
- }
- catch (Exception ex)
- {
- Logger.LogCritical(ex, nameof(Daemon));
- return;
- }
- }
-
+ KeyManager keyManager = TryGetKeymanagerFromWalletName(walletName);
if (keyManager is null)
{
- Logger.LogCritical("Wallet was not supplied. Add --wallet {WalletName}", nameof(Daemon));
return;
}
@@ -124,6 +101,48 @@ namespace WalletWasabi.Gui.CommandLine
await Global.ChaumianClient.DequeueAllCoinsFromMixAsync();
}
+ public static KeyManager TryGetKeymanagerFromWalletName(string walletName)
+ {
+ try
+ {
+ KeyManager keyManager = null;
+ if (walletName != null)
+ {
+ var walletFullPath = Global.GetWalletFullPath(walletName);
+ var walletBackupFullPath = Global.GetWalletBackupFullPath(walletName);
+ if (!File.Exists(walletFullPath) && !File.Exists(walletBackupFullPath))
+ {
+ // The selected wallet is not available any more (someone deleted it?).
+ Logger.LogCritical("The selected wallet doesn't exsist, did you delete it?", nameof(Daemon));
+ return null;
+ }
+
+ try
+ {
+ keyManager = Global.LoadKeyManager(walletFullPath, walletBackupFullPath);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogCritical(ex, nameof(Daemon));
+ return null;
+ }
+ }
+
+ if (keyManager is null)
+ {
+ Logger.LogCritical("Wallet was not supplied. Add --wallet:WalletName", nameof(Daemon));
+ return null;
+ }
+
+ return keyManager;
+ }
+ catch (Exception ex)
+ {
+ Logger.LogCritical(ex, nameof(Daemon));
+ return null;
+ }
+ }
+
private static async Task TryQueueCoinsToMixAsync(bool mixAll, string password)
{
try

MODIFY
WalletWasabi.Gui/CommandLine/MixerCommand.cs
WalletWasabi.Gui/CommandLine/MixerCommand.cs
@@ -19,10 +19,10 @@ namespace WalletWasabi.Gui.CommandLine
: base("mix", "Start mixing without the GUI with the specified wallet.")
{
Options = new OptionSet() {
- "usage: mix --wallet:wallet-file-path --mixall --keepalive loglevel:log-level",
+ "usage: mix --wallet:WalletName --mixall --keepalive --loglevel:log-level",
"",
"Start mixing without the GUI with the specified wallet.",
- "eg: mix --wallet:/home/user/.walletwasabi/client/Wallets/MyWallet.json --mixall --keepalive loglevel:info",
+ "eg: ./wassabee mix --wallet:MyWalletName --mixall --keepalive --loglevel:info",
{ "h|help", "Displays help page and exit.",
x => ShowHelp = x != null},
@@ -30,7 +30,7 @@ namespace WalletWasabi.Gui.CommandLine
x => Silent = x != null},
{ "l|loglevel=", "Sets the level of verbosity for the log TRACE|INFO|WARNING|DEBUG|ERROR.",
x => LoggingLevel = x },
- { "w|wallet=", "The specified wallet file.",
+ { "w|wallet=", "The name of the wallet file.",
x => WalletName = x?.ToLower() },
{ "mixall", "Mix once even if the coin reached the target anonymity set specified in the config file.",
x => MixAll = x != null},

MODIFY
WalletWasabi.Gui/CommandLine/PasswordFinderCommand.cs
WalletWasabi.Gui/CommandLine/PasswordFinderCommand.cs
@@ -2,13 +2,15 @@ using Mono.Options;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using WalletWasabi.Helpers;
using WalletWasabi.KeyManagement;
namespace WalletWasabi.Gui.CommandLine
{
internal class PasswordFinderCommand : Command
{
- public string Wallet { get; set; }
+ public string WalletName { get; set; }
+ public string EncryptedSecret { get; set; }
public string Language { get; set; }
public bool UseNumbers { get; set; }
public bool UseSymbols { get; set; }
@@ -20,13 +22,15 @@ namespace WalletWasabi.Gui.CommandLine
Language = "en";
Options = new OptionSet() {
- "usage: findpassword --secret:encrypted-secret --language:lang --numbers:[TRUE|FALSE] --symbold:[TRUE|FALSE]",
+ "usage: findpassword --wallet:WalletName --language:lang --numbers:[TRUE|FALSE] --symbold:[TRUE|FALSE]",
"",
"Tries to find typing mistakes in the user password by brute forcing it char by char.",
- "eg: .wassabee findpassword --wallet:/home/user/.wasabiwallet/client/Wallets/my-wallet.json --numbers:false --symbold:true",
+ "eg: ./wassabee findpassword --wallet:MyWalletName --numbers:false --symbold:true",
"",
- { "w|wallet=", "The path to the wallet file.",
- x => Wallet = x },
+ { "w|wallet=", "The name of the wallet file.",
+ x => WalletName = x?.ToLower() },
+ { "s|secret=", "You can specify an encrypted secret key instead of wallet. Example of encrypted secret: 6PYTMDmkxQrSv8TK4761tuKrV8yFwPyZDqjJafcGEiLBHiqBV6WviFxJV4",
+ x => EncryptedSecret = Guard.Correct(x) },
{ "l|language=", "The charset to use: en, es, it, fr, pt. Default=en.",
v => Language = v },
{ "n|numbers=", "Try passwords with numbers. Default=true.",
@@ -47,9 +51,9 @@ namespace WalletWasabi.Gui.CommandLine
{
Options.WriteOptionDescriptions(CommandSet.Out);
}
- else if (string.IsNullOrEmpty(Wallet))
+ else if (string.IsNullOrWhiteSpace(WalletName) && string.IsNullOrWhiteSpace(EncryptedSecret))
{
- Console.WriteLine("Missing required argument `--wallet=wallet-file-path`.");
+ Console.WriteLine("Missing required argument `--wallet=WalletName`.");
Console.WriteLine("Use `findpassword --help` for details.");
error = true;
}
@@ -59,11 +63,19 @@ namespace WalletWasabi.Gui.CommandLine
Console.WriteLine("Use `findpassword --help` for details.");
error = true;
}
- else
+ else if (!string.IsNullOrWhiteSpace(WalletName))
{
- var km = KeyManager.FromFile(Wallet);
+ 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)
{

Add secret and enable specifying wallet name