Generate keys
MODIFY
WalletWasabi.Packager/ArgsProcessor.cs
WalletWasabi.Packager/ArgsProcessor.cs
@@ -24,7 +24,7 @@ public class ArgsProcessor
public bool IsSign() => IsOneOf("sign");
- public bool IsGeneratePrivateKey() => IsOneOf("generateprivatekey");
+ public bool IsGeneratePrivateKey() => IsOneOf("generatekeys");
private bool IsOneOf(params string[] values)
{

MODIFY
WalletWasabi.Packager/Program.cs
WalletWasabi.Packager/Program.cs
@@ -65,7 +65,7 @@ public static class Program
if (argsProcessor.IsGeneratePrivateKey())
{
- await WasabiSignerHelpers.SavePrivateKeyToFileAsync().ConfigureAwait(false);
+ await WasabiSignerHelpers.GeneratePrivateAndPublicKeyToFileAsync().ConfigureAwait(false);
return;
}

MODIFY
WalletWasabi.Packager/Properties/launchSettings.json
WalletWasabi.Packager/Properties/launchSettings.json
"profiles": {
"WalletWasabi.Packager": {
"commandName": "Project",
- "commandLineArgs": "generateprivatekey"
+ "commandLineArgs": "generatekeys"
}
}
}
\ No newline at end of file

MODIFY
WalletWasabi/Helpers/WasabiSignerHelpers.cs
WalletWasabi/Helpers/WasabiSignerHelpers.cs
@@ -8,8 +8,8 @@ namespace WalletWasabi.Helpers;
public class WasabiSignerHelpers
{
- private const string WasabiKeyHeadline = "WASABI PRIVATE KEY";
private const string WasabiPrivateKeyFilePath = @"C:\wasabi\Wasabi.privkey";
+ private const string WasabiPublicKeyFilePath = @"C:\wasabi\Wasabi.pubkey";
public static async Task SignSha256SumsFileAsync(string sha256sumsFilePath, Key wasabiPrivateKey)
{
@@ -25,37 +25,25 @@ public class WasabiSignerHelpers
await File.WriteAllTextAsync(wasabiSignatureFilePath, base64Signature).ConfigureAwait(false);
}
- public static async Task SavePrivateKeyToFileAsync()
+ public static async Task GeneratePrivateAndPublicKeyToFileAsync()
{
using Key key = new();
- var destinationFilePath = WasabiPrivateKeyFilePath;
- if (File.Exists(destinationFilePath))
+ if (File.Exists(WasabiPrivateKeyFilePath))
{
throw new ArgumentException("Private key file already exists.");
}
- IoHelpers.EnsureContainingDirectoryExists(destinationFilePath);
- using StreamWriter streamWriter = new(destinationFilePath);
- await streamWriter.WriteLineAsync($"-----BEGIN {WasabiKeyHeadline}-----").ConfigureAwait(false);
- await streamWriter.WriteLineAsync(key.ToString(Network.Main)).ConfigureAwait(false);
- await streamWriter.WriteLineAsync($"-----END {WasabiKeyHeadline}-----").ConfigureAwait(false);
+ IoHelpers.EnsureContainingDirectoryExists(WasabiPrivateKeyFilePath);
+
+ await File.WriteAllTextAsync(WasabiPrivateKeyFilePath, key.ToString()).ConfigureAwait(false);
+ await File.WriteAllTextAsync(WasabiPublicKeyFilePath, key.PubKey.ToString()).ConfigureAwait(false);
}
public static async Task<Key> GetPrivateKeyFromFileAsync()
{
string fileName = WasabiPrivateKeyFilePath;
- string[] keyFileContent = await File.ReadAllLinesAsync(fileName).ConfigureAwait(false);
- bool isHeadlineBeginValid = keyFileContent[0] == $"-----BEGIN {WasabiKeyHeadline}-----";
- bool isHeadlineEndValid = keyFileContent[2] == $"-----END {WasabiKeyHeadline}-----";
-
- if (!isHeadlineBeginValid || !isHeadlineEndValid)
- {
- throw new ArgumentException("Wasabi private key file's content was invalid.");
- }
-
- string wif = keyFileContent[1];
- BitcoinSecret secret = new(wif, Network.Main);
-
+ string keyFileContent = await File.ReadAllTextAsync(fileName).ConfigureAwait(false);
+ BitcoinSecret secret = new(keyFileContent, Network.Main);
return secret.PrivateKey;
}
}

Generate keys