Delete CLI tools
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -10,7 +10,6 @@ using System.Threading.Tasks;
using WalletWasabi.Fluent.CrashReport;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Gui;
-using WalletWasabi.Gui.CommandLine;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
@@ -70,18 +69,11 @@ namespace WalletWasabi.Fluent.Desktop
// TODO only required due to statusbar vm... to be removed.
Locator.CurrentMutable.RegisterConstant(Global);
- if (args.Length != 0)
- {
- ProcessCliCommands(Global, args);
- }
- else
- {
Logger.LogSoftwareStarted("Wasabi GUI");
BuildAvaloniaApp(Global)
.AfterSetup(_ => ThemeHelper.ApplyTheme(Global.UiConfig.DarkModeEnabled))
.StartWithClassicDesktopLifetime(args);
}
- }
catch (OperationCanceledException ex)
{
Logger.LogDebug(ex);
@@ -138,16 +130,6 @@ namespace WalletWasabi.Fluent.Desktop
return new Global(dataDir, torLogsFile, config, uiConfig, walletManager);
}
- private static bool ProcessCliCommands(Global global, string[] args)
- {
- var daemon = new Daemon(global, TerminateService);
- var interpreter = new CommandInterpreter(Console.Out, Console.Error);
- var executionTask = interpreter.ExecuteCommandsAsync(
- args,
- new MixerCommand(daemon));
- return executionTask.GetAwaiter().GetResult();
- }
-
/// <summary>
/// Do not call this method it should only be called by TerminateService.
/// </summary>

DELETE
WalletWasabi.Gui/CommandLine/CommandInterpreter.cs
-using Mono.Options;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using WalletWasabi.Helpers;
-
-namespace WalletWasabi.Gui.CommandLine
-{
- public class CommandInterpreter
- {
- public CommandInterpreter(TextWriter outW, TextWriter errorW)
- {
- Out = outW;
- Error = errorW;
- }
-
- private TextWriter Out { get; }
- private TextWriter Error { get; }
-
- /// <returns>If the GUI should run or not.</returns>
- public async Task<bool> ExecuteCommandsAsync(string[] args, Command mixerCommand)
- {
- var showHelp = false;
- var showVersion = false;
-
- if (args.Length == 0)
- {
- return true;
- }
-
- var suite = new CommandSet("wassabee", Out, Error)
- {
- "Usage: wassabee [OPTIONS]+",
- "Launches Wasabi Wallet.",
- "",
- { "h|help", "Displays help page and exit.", x => showHelp = x is { } },
- { "v|version", "Displays Wasabi version and exit.", x => showVersion = x is { } },
- "",
- "Available commands are:",
- "",
- mixerCommand
- };
-
- EnsureBackwardCompatibilityWithOldParameters(ref args);
- if (await suite.RunAsync(args) == 0)
- {
- return false;
- }
- if (showHelp)
- {
- ShowVersion();
- await suite.RunAsync(new string[] { "--help" });
- return false;
- }
- else if (showVersion)
- {
- ShowVersion();
- return false;
- }
-
- return false;
- }
-
- private static void EnsureBackwardCompatibilityWithOldParameters(ref string[] args)
- {
- var listArgs = args.ToList();
- if (listArgs.Remove("--mix") || listArgs.Remove("-m"))
- {
- listArgs.Insert(0, "mix");
- }
- args = listArgs.ToArray();
- }
-
- private void ShowVersion()
- {
- Out.WriteLine($"Wasabi Client Version: {Constants.ClientVersion}");
- Out.WriteLine($"Compatible Coordinator Version: {Constants.ClientSupportBackendVersionText}");
- Out.WriteLine($"Compatible Bitcoin Core and Bitcoin Knots Versions: {Constants.BitcoinCoreVersion}");
- Out.WriteLine($"Compatible Hardware Wallet Interface Version: {Constants.HwiVersion}");
- }
- }
-}

DELETE
WalletWasabi.Gui/CommandLine/Daemon.cs
-using NBitcoin;
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using WalletWasabi.Blockchain.Keys;
-using WalletWasabi.Logging;
-using WalletWasabi.Services.Terminate;
-using WalletWasabi.Userfacing;
-using WalletWasabi.Wallets;
-
-namespace WalletWasabi.Gui.CommandLine
-{
- public class Daemon
- {
- public Daemon(Global global, TerminateService terminateService)
- {
- Global = global;
- TerminateService = terminateService;
- }
-
- private Global Global { get; }
- private TerminateService TerminateService { get; }
- private Wallet Wallet { get; set; }
-
- internal async Task RunAsync(string walletName, string destinationWalletName, bool keepMixAlive)
- {
- try
- {
- Logger.LogSoftwareStarted("Wasabi Daemon");
-
- KeyManager keyManager = Global.WalletManager.GetWalletByName(walletName).KeyManager;
-
- string password = null;
- var count = 3;
- string compatibilityPassword = null;
- do
- {
- if (password is { })
- {
- if (count > 0)
- {
- Logger.LogError($"Wrong password. {count} attempts left. Try again.");
- }
- else
- {
- Logger.LogCritical($"Wrong password. {count} attempts left. Exiting...");
- return;
- }
- count--;
- }
- Console.Write("Password: ");
-
- password = PasswordConsole.ReadPassword();
- if (PasswordHelper.IsTooLong(password, out password))
- {
- Console.WriteLine(PasswordHelper.PasswordTooLongMessage);
- }
- if (PasswordHelper.IsTrimmable(password, out password))
- {
- Console.WriteLine(PasswordHelper.TrimWarnMessage);
- }
- }
- while (!PasswordHelper.TryPassword(keyManager, password, out compatibilityPassword));
-
- if (compatibilityPassword is { })
- {
- password = compatibilityPassword;
- Logger.LogInfo(PasswordHelper.CompatibilityPasswordWarnMessage);
- }
-
- Logger.LogInfo("Correct password.");
-
- await Global.InitializeNoWalletAsync(TerminateService);
- if (TerminateService.IsTerminateRequested)
- {
- return;
- }
-
- Wallet = await Global.WalletManager.StartWalletAsync(keyManager);
- if (TerminateService.IsTerminateRequested)
- {
- return;
- }
-
- KeyManager destinationKeyManager = Global.WalletManager.GetWalletByName(destinationWalletName).KeyManager;
- bool isDifferentDestinationSpecified = keyManager.ExtPubKey != destinationKeyManager.ExtPubKey;
- if (isDifferentDestinationSpecified)
- {
- await Global.WalletManager.StartWalletAsync(destinationKeyManager);
- }
-
- do
- {
- if (TerminateService.IsTerminateRequested)
- {
- break;
- }
-
- // If no coins enqueued then try to enqueue the large anonset coins and mix to another wallet.
- if (isDifferentDestinationSpecified && !AnyCoinsQueued())
- {
- Wallet.ChaumianClient.DestinationKeyManager = destinationKeyManager;
- await TryQueueCoinsToMixAsync(password, minAnonset: Wallet.ServiceConfiguration.GetMixUntilAnonymitySetValue());
- }
-
- if (TerminateService.IsTerminateRequested)
- {
- break;
- }
-
- // If no coins were enqueued then try to enqueue coins those have less anonset and mix into the same wallet.
- if (!AnyCoinsQueued())
- {
- Wallet.ChaumianClient.DestinationKeyManager = Wallet.ChaumianClient.KeyManager;
- await TryQueueCoinsToMixAsync(password, maxAnonset: Wallet.ServiceConfiguration.GetMixUntilAnonymitySetValue() - 1);
- }
-
- if (TerminateService.IsTerminateRequested)
- {
- break;
- }
-
- await Task.Delay(3000);
- }
-
- // Keep this loop alive as long as a coin is enqueued or keepalive was specified.
- while (keepMixAlive || AnyCoinsQueued());
- }
- catch
- {
- if (!TerminateService.IsTerminateRequested)
- {
- throw;
- }
- }
- finally
- {
- Logger.LogInfo($"{nameof(Daemon)} stopped.");
- }
- }
-
- private bool AnyCoinsQueued() => Global.WalletManager.AnyCoinJoinInProgress();
-
- private async Task TryQueueCoinsToMixAsync(string password, int minAnonset = int.MinValue, int maxAnonset = int.MaxValue)
- {
- try
- {
- var coinsToMix = Wallet.Coins.Available().FilterBy(x => x.HdPubKey.AnonymitySet <= maxAnonset && minAnonset <= x.HdPubKey.AnonymitySet);
-
- var enqueuedCoins = await Wallet.ChaumianClient.QueueCoinsToMixAsync(password, coinsToMix.ToArray());
-
- if (enqueuedCoins.Any())
- {
- Logger.LogInfo($"Enqueued {Money.Satoshis(enqueuedCoins.Sum(x => x.Amount)).ToString(false, true)} BTC, {enqueuedCoins.Count()} coins with smallest anonset {enqueuedCoins.Min(x => x.HdPubKey.AnonymitySet)} and largest anonset {enqueuedCoins.Max(x => x.HdPubKey.AnonymitySet)}.");
- }
- }
- catch (Exception ex)
- {
- Logger.LogWarning(ex);
- }
- }
- }
-}

DELETE
WalletWasabi.Gui/CommandLine/MixerCommand.cs
-using Mono.Options;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using WalletWasabi.Logging;
-
-namespace WalletWasabi.Gui.CommandLine
-{
- public class MixerCommand : Command
- {
- public MixerCommand(Daemon daemon)
- : base("mix", "Start mixing without the GUI with the specified wallet.")
- {
- Daemon = daemon;
- Options = new OptionSet()
- {
- "usage: mix --wallet:WalletName --keepalive",
- "",
- "Start mixing without the GUI with the specified wallet.",
- "eg: ./wassabee mix --wallet:MyWalletName --keepalive",
- { "h|help", "Displays help page and exit.", x => ShowHelp = x is { } },
- { "w|wallet=", "The name of the wallet file.", x => WalletName = x },
- { "destination=", "The name of the destination wallet file.", x => DestinationWalletName = x },
- { "keepalive", "Do not exit the software after mixing has been finished, rather keep mixing when new money arrives.", x => KeepMixAlive = x is { } }
- };
- }
-
- public string? WalletName { get; set; }
- public string? DestinationWalletName { get; set; }
- public bool KeepMixAlive { get; set; }
- public bool ShowHelp { get; set; }
- public Daemon Daemon { get; }
-
- public override async Task<int> InvokeAsync(IEnumerable<string> args)
- {
- Options.Parse(args);
- if (ShowHelp)
- {
- Options.WriteOptionDescriptions(CommandSet.Out);
- }
- else
- {
- if (WalletName is null)
- {
- throw new ArgumentNullException($"Argument {nameof(WalletName)} must be set.");
- }
-
- await Daemon.RunAsync(WalletName, DestinationWalletName ?? WalletName, KeepMixAlive).ConfigureAwait(false);
- }
- return 0;
- }
- }
-}

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -11,7 +11,6 @@ using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
-using WalletWasabi.Gui.CommandLine;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
@@ -46,14 +45,9 @@ namespace WalletWasabi.Gui
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
- runGui = ProcessCliCommands(args);
-
- if (runGui)
- {
Logger.LogSoftwareStarted("Wasabi GUI");
BuildAvaloniaApp().StartShellApp("Wasabi Wallet", AppMainAsync, args);
}
- }
catch (Exception ex)
{
appException = ex;
@@ -78,16 +72,6 @@ namespace WalletWasabi.Gui
return new Global(dataDir, torLogsFile, config, uiConfig, walletManager);
}
- private static bool ProcessCliCommands(string[] args)
- {
- var daemon = new Daemon(Global, TerminateService);
- var interpreter = new CommandInterpreter(Console.Out, Console.Error);
- var executionTask = interpreter.ExecuteCommandsAsync(
- args,
- new MixerCommand(daemon));
- return executionTask.GetAwaiter().GetResult();
- }
-
private static void SetTheme() => AvalonStudio.Extensibility.Theme.ColorTheme.LoadTheme(AvalonStudio.Extensibility.Theme.ColorTheme.VisualStudioDark);
private static async void AppMainAsync(string[] args)

Delete CLI tools