Catch correct result
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -687,7 +687,7 @@ namespace WalletWasabi.Gui
var prefix = customPrefix is null
? hwi is null
? "HardwareWallet"
- : hwi.Type.ToString()
+ : hwi.Model.ToString()
: customPrefix;
for (int i = 0; i < int.MaxValue; i++)

MODIFY
WalletWasabi.Gui/Models/LoadWalletEntry.cs
WalletWasabi.Gui/Models/LoadWalletEntry.cs
@@ -18,7 +18,7 @@ namespace WalletWasabi.Gui.Models
public LoadWalletEntry(HwiEnumerateEntry hwi)
{
- string typeString = hwi.Type.ToString();
+ string typeString = hwi.Model.ToString();
var walletNameBuilder = new StringBuilder(typeString);
if (!string.IsNullOrWhiteSpace(hwi.Error))

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -403,7 +403,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusBarStatus.SettingUpHardwareWallet);
// After HWI 1.0.1 the openconsole can be made false for Trezor T.
// HWI will start detecting the exact type of hardware wallets.
- await client.SetupAsync(selectedWallet.HardwareWalletInfo.Type, selectedWallet.HardwareWalletInfo.Path, true, cts.Token);
+ await client.SetupAsync(selectedWallet.HardwareWalletInfo.Model, selectedWallet.HardwareWalletInfo.Path, true, cts.Token);
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusBarStatus.ConnectingToHardwareWallet);
await EnumerateHardwareWalletsAsync();
@@ -418,7 +418,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
}
else if (selectedWallet.HardwareWalletInfo.NeedsPinSent is true)
{
- await client.PromptPinAsync(selectedWallet.HardwareWalletInfo.Type, selectedWallet.HardwareWalletInfo.Path, cts.Token);
+ await client.PromptPinAsync(selectedWallet.HardwareWalletInfo.Model, selectedWallet.HardwareWalletInfo.Path, cts.Token);
PinPadViewModel pinpad = IoC.Get<IShell>().Documents.OfType<PinPadViewModel>().FirstOrDefault();
if (pinpad is null)
@@ -435,12 +435,12 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
var maskedPin = pinpad.MaskedPin;
- await client.SendPinAsync(selectedWallet.HardwareWalletInfo.Type, selectedWallet.HardwareWalletInfo.Path, int.Parse(maskedPin), cts.Token);
+ await client.SendPinAsync(selectedWallet.HardwareWalletInfo.Model, selectedWallet.HardwareWalletInfo.Path, int.Parse(maskedPin), cts.Token);
var p = selectedWallet.HardwareWalletInfo.Path;
- var t = selectedWallet.HardwareWalletInfo.Type;
+ var t = selectedWallet.HardwareWalletInfo.Model;
await EnumerateHardwareWalletsAsync();
- selectedWallet = Wallets.FirstOrDefault(x => x.HardwareWalletInfo.Type == t && x.HardwareWalletInfo.Path == p);
+ selectedWallet = Wallets.FirstOrDefault(x => x.HardwareWalletInfo.Model == t && x.HardwareWalletInfo.Path == p);
if (selectedWallet is null)
{
SetValidationMessage("Could not find the hardware wallet you are working with. Did you disconnect it?");

MODIFY
WalletWasabi.Tests/IntegrationTests/HwiKatas.cs
WalletWasabi.Tests/IntegrationTests/HwiKatas.cs
@@ -51,11 +51,11 @@ namespace WalletWasabi.Tests.IntegrationTests.Hwi
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
Assert.NotNull(entry.Path);
- Assert.Equal(HardwareWalletModels.Trezor_T, entry.Type);
+ Assert.Equal(HardwareWalletModels.Trezor_T, entry.Model);
Assert.True(entry.Fingerprint.HasValue);
string devicePath = entry.Path;
- HardwareWalletModels deviceType = entry.Type;
+ HardwareWalletModels deviceType = entry.Model;
HDFingerprint fingerprint = entry.Fingerprint.Value;
await Assert.ThrowsAsync<HwiException>(async () => await client.SetupAsync(deviceType, devicePath, false, cts.Token));
@@ -124,13 +124,13 @@ namespace WalletWasabi.Tests.IntegrationTests.Hwi
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
Assert.NotNull(entry.Path);
- Assert.Equal(HardwareWalletModels.Trezor_1, entry.Type);
+ Assert.Equal(HardwareWalletModels.Trezor_1, entry.Model);
Assert.True(entry.NeedsPinSent);
Assert.Equal(HwiErrorCode.DeviceNotReady, entry.Code);
Assert.Null(entry.Fingerprint);
string devicePath = entry.Path;
- HardwareWalletModels deviceType = entry.Type;
+ HardwareWalletModels deviceType = entry.Model;
await Assert.ThrowsAsync<HwiException>(async () => await client.SetupAsync(deviceType, devicePath, false, cts.Token));
@@ -187,11 +187,11 @@ namespace WalletWasabi.Tests.IntegrationTests.Hwi
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
Assert.NotNull(entry.Path);
- Assert.Equal(HardwareWalletModels.Coldcard, entry.Type);
+ Assert.Equal(HardwareWalletModels.Coldcard, entry.Model);
Assert.True(entry.Fingerprint.HasValue);
string devicePath = entry.Path;
- HardwareWalletModels deviceType = entry.Type;
+ HardwareWalletModels deviceType = entry.Model;
HDFingerprint fingerprint = entry.Fingerprint.Value;
// ColdCard doesn't support it.
@@ -267,7 +267,7 @@ namespace WalletWasabi.Tests.IntegrationTests.Hwi
var enumerate = await client.EnumerateAsync(cts.Token);
HwiEnumerateEntry entry = Assert.Single(enumerate);
Assert.NotNull(entry.Path);
- Assert.Equal(HardwareWalletModels.Ledger_Nano_S, entry.Type);
+ Assert.Equal(HardwareWalletModels.Ledger_Nano_S, entry.Model);
Assert.True(entry.Fingerprint.HasValue);
Assert.Null(entry.Code);
Assert.Null(entry.Error);
@@ -276,7 +276,7 @@ namespace WalletWasabi.Tests.IntegrationTests.Hwi
Assert.False(entry.NeedsPinSent);
string devicePath = entry.Path;
- HardwareWalletModels deviceType = entry.Type;
+ HardwareWalletModels deviceType = entry.Model;
HDFingerprint fingerprint = entry.Fingerprint.Value;
await Assert.ThrowsAsync<HwiException>(async () => await client.SetupAsync(deviceType, devicePath, false, cts.Token));

MODIFY
WalletWasabi.Tests/UnitTests/Hwi/HwiProcessBridgeMock.cs
WalletWasabi.Tests/UnitTests/Hwi/HwiProcessBridgeMock.cs
@@ -25,27 +25,27 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
throw new NotImplementedException($"Cannot mock {nameof(openConsole)} mode.");
}
- string type;
+ string model;
string rawPath;
if (Model == HardwareWalletModels.Trezor_T)
{
- type = "trezor_t";
+ model = "trezor_t";
rawPath = "webusb: 001:4";
}
else if (Model == HardwareWalletModels.Trezor_1)
{
- type = "trezor_1";
+ model = "trezor_1";
rawPath = "hid:\\\\\\\\?\\\\hid#vid_534c&pid_0001&mi_00#7&6f0b727&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
}
else if (Model == HardwareWalletModels.Coldcard)
{
- type = "coldcard";
+ model = "coldcard";
rawPath = @"\\\\?\\hid#vid_d13e&pid_cc10&mi_00#7&1b239988&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
}
else if (Model == HardwareWalletModels.Ledger_Nano_S)
{
- type = "ledger_nano_s";
+ model = "ledger_nano_s";
rawPath = "\\\\\\\\?\\\\hid#vid_2c97&pid_0001&mi_00#7&e45ae20&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
}
else
@@ -54,7 +54,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
}
string path = HwiParser.NormalizeRawDevicePath(rawPath);
- string devicePathAndTypeArgumentString = $"--device-path \"{path}\" --device-type \"{type}\"";
+ string devicePathAndTypeArgumentString = $"--device-path \"{path}\" --device-type \"{model}\"";
const string successTrueResponse = "{\"success\": true}\r\n";
@@ -65,19 +65,19 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
{
if (Model == HardwareWalletModels.Trezor_T)
{
- response = $"[{{\"type\": \"{type}\", \"path\": \"{rawPath}\", \"needs_pin_sent\": false, \"needs_passphrase_sent\": false, \"error\": \"Not initialized\"}}]";
+ response = $"[{{\"model\": \"{model}\", \"path\": \"{rawPath}\", \"needs_pin_sent\": false, \"needs_passphrase_sent\": false, \"error\": \"Not initialized\"}}]";
}
else if (Model == HardwareWalletModels.Trezor_1)
{
- response = $"[{{\"type\": \"{type}\", \"path\": \"{rawPath}\", \"needs_pin_sent\": true, \"needs_passphrase_sent\": false, \"error\": \"Could not open client or get fingerprint information: Trezor is locked. Unlock by using 'promptpin' and then 'sendpin'.\", \"code\": -12}}]\r\n";
+ response = $"[{{\"model\": \"{model}\", \"path\": \"{rawPath}\", \"needs_pin_sent\": true, \"needs_passphrase_sent\": false, \"error\": \"Could not open client or get fingerprint information: Trezor is locked. Unlock by using 'promptpin' and then 'sendpin'.\", \"code\": -12}}]\r\n";
}
else if (Model == HardwareWalletModels.Coldcard)
{
- response = $"[{{\"type\": \"{type}\", \"path\": \"{rawPath}\", \"needs_passphrase\": false, \"fingerprint\": \"a3d0d797\"}}]\r\n";
+ response = $"[{{\"model\": \"{model}\", \"path\": \"{rawPath}\", \"needs_passphrase\": false, \"fingerprint\": \"a3d0d797\"}}]\r\n";
}
else if (Model == HardwareWalletModels.Ledger_Nano_S)
{
- response = $"[{{\"type\": \"{type}\", \"path\": \"{rawPath}\", \"fingerprint\": \"4054d6f6\", \"needs_pin_sent\": false, \"needs_passphrase_sent\": false}}]\r\n";
+ response = $"[{{\"model\": \"{model}\", \"path\": \"{rawPath}\", \"fingerprint\": \"4054d6f6\", \"needs_pin_sent\": false, \"needs_passphrase_sent\": false}}]\r\n";
}
}
else if (CompareArguments(arguments, $"{devicePathAndTypeArgumentString} wipe"))

MODIFY
WalletWasabi.Tests/UnitTests/Hwi/MockedDeviceTests.cs
WalletWasabi.Tests/UnitTests/Hwi/MockedDeviceTests.cs
@@ -36,7 +36,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
IEnumerable<HwiEnumerateEntry> enumerate = await client.EnumerateAsync(cts.Token);
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
- Assert.Equal(HardwareWalletModels.Trezor_T, entry.Type);
+ Assert.Equal(HardwareWalletModels.Trezor_T, entry.Model);
Assert.Equal("webusb: 001:4", entry.Path);
Assert.False(entry.NeedsPassphraseSent);
Assert.False(entry.NeedsPinSent);
@@ -46,7 +46,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
Assert.False(entry.IsInitialized());
Assert.Null(entry.Fingerprint);
- var deviceType = entry.Type;
+ var deviceType = entry.Model;
var devicePath = entry.Path;
await client.WipeAsync(deviceType, devicePath, cts.Token);
@@ -112,7 +112,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
IEnumerable<HwiEnumerateEntry> enumerate = await client.EnumerateAsync(cts.Token);
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
- Assert.Equal(HardwareWalletModels.Trezor_1, entry.Type);
+ Assert.Equal(HardwareWalletModels.Trezor_1, entry.Model);
string rawPath = "hid:\\\\\\\\?\\\\hid#vid_534c&pid_0001&mi_00#7&6f0b727&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
string normalizedPath = HwiParser.NormalizeRawDevicePath(rawPath);
Assert.Equal(normalizedPath, entry.Path);
@@ -123,7 +123,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
Assert.Null(entry.Fingerprint);
Assert.True(entry.IsInitialized());
- var deviceType = entry.Type;
+ var deviceType = entry.Model;
var devicePath = entry.Path;
await client.WipeAsync(deviceType, devicePath, cts.Token);
@@ -188,7 +188,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
IEnumerable<HwiEnumerateEntry> enumerate = await client.EnumerateAsync(cts.Token);
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
- Assert.Equal(HardwareWalletModels.Coldcard, entry.Type);
+ Assert.Equal(HardwareWalletModels.Coldcard, entry.Model);
string rawPath = "\\\\\\\\?\\\\hid#vid_d13e&pid_cc10&mi_00#7&1b239988&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
string normalizedPath = HwiParser.NormalizeRawDevicePath(rawPath);
Assert.Equal(normalizedPath, entry.Path);
@@ -199,7 +199,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
Assert.Equal("a3d0d797", entry.Fingerprint.ToString());
Assert.True(entry.IsInitialized());
- var deviceType = entry.Type;
+ var deviceType = entry.Model;
var devicePath = entry.Path;
HDFingerprint fingerprint = entry.Fingerprint.Value;
@@ -277,7 +277,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
IEnumerable<HwiEnumerateEntry> enumerate = await client.EnumerateAsync(cts.Token);
Assert.Single(enumerate);
HwiEnumerateEntry entry = enumerate.Single();
- Assert.Equal(HardwareWalletModels.Ledger_Nano_S, entry.Type);
+ Assert.Equal(HardwareWalletModels.Ledger_Nano_S, entry.Model);
Assert.Equal(@"\\?\hid#vid_2c97&pid_0001&mi_00#7&e45ae20&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}", entry.Path);
Assert.False(entry.NeedsPassphraseSent);
Assert.False(entry.NeedsPinSent);
@@ -286,7 +286,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
Assert.True(entry.IsInitialized());
Assert.Equal("4054d6f6", entry.Fingerprint.ToString());
- var deviceType = entry.Type;
+ var deviceType = entry.Model;
var devicePath = entry.Path;
var wipe = await Assert.ThrowsAsync<HwiException>(async () => await client.WipeAsync(deviceType, devicePath, cts.Token));

MODIFY
WalletWasabi/Hwi/Models/HwiEnumerateEntry.cs
WalletWasabi/Hwi/Models/HwiEnumerateEntry.cs
@@ -9,7 +9,7 @@ namespace WalletWasabi.Hwi.Models
{
public class HwiEnumerateEntry
{
- public HardwareWalletModels Type { get; }
+ public HardwareWalletModels Model { get; }
public string Path { get; }
public string SerialNumber { get; }
public HDFingerprint? Fingerprint { get; }
@@ -26,7 +26,7 @@ namespace WalletWasabi.Hwi.Models
}
public HwiEnumerateEntry(
- HardwareWalletModels type,
+ HardwareWalletModels model,
string path,
string serialNumber,
HDFingerprint? fingerprint,
@@ -35,7 +35,7 @@ namespace WalletWasabi.Hwi.Models
string error,
HwiErrorCode? code)
{
- Type = type;
+ Model = model;
Path = path;
SerialNumber = serialNumber;
Fingerprint = fingerprint;

MODIFY
WalletWasabi/Hwi/Parsers/HwiParser.cs
WalletWasabi/Hwi/Parsers/HwiParser.cs
@@ -212,12 +212,12 @@ namespace WalletWasabi.Hwi.Parsers
public static HwiEnumerateEntry ParseHwiEnumerateEntry(JObject json)
{
- JToken typeToken = json["type"];
- var pathString = json["path"]?.ToString().Trim();
- var serialNumberString = json["serial_number"]?.ToString().Trim();
- var fingerprintString = json["fingerprint"]?.ToString().Trim();
- var needsPinSentString = json["needs_pin_sent"]?.ToString().Trim();
- var needsPassphraseSentString = json["needs_passphrase_sent"]?.ToString().Trim();
+ JToken modelToken = json["model"];
+ var pathString = json["path"]?.ToString()?.Trim();
+ var serialNumberString = json["serial_number"]?.ToString()?.Trim();
+ var fingerprintString = json["fingerprint"]?.ToString()?.Trim();
+ var needsPinSentString = json["needs_pin_sent"]?.ToString()?.Trim();
+ var needsPassphraseSentString = json["needs_passphrase_sent"]?.ToString()?.Trim();
HDFingerprint? fingerprint = null;
if (fingerprintString != null)
@@ -233,13 +233,13 @@ namespace WalletWasabi.Hwi.Parsers
}
bool? needsPinSent = null;
- if (needsPinSentString != null)
+ if (!string.IsNullOrEmpty(needsPinSentString))
{
needsPinSent = bool.Parse(needsPinSentString);
}
bool? needsPassphraseSent = null;
- if (needsPassphraseSentString != null)
+ if (!string.IsNullOrEmpty(needsPassphraseSentString))
{
needsPassphraseSent = bool.Parse(needsPassphraseSentString);
}
@@ -252,14 +252,14 @@ namespace WalletWasabi.Hwi.Parsers
errorString = err.Message;
}
- HardwareWalletModels type = HardwareWalletModels.Unknown;
- if (TryParseHardwareWalletVendor(typeToken, out HardwareWalletModels t))
+ HardwareWalletModels model = HardwareWalletModels.Unknown;
+ if (TryParseHardwareWalletVendor(modelToken, out HardwareWalletModels t))
{
- type = t;
+ model = t;
}
return new HwiEnumerateEntry(
- type: type,
+ model: model,
path: pathString,
serialNumber: serialNumberString,
fingerprint: fingerprint,

Catch correct result