Implement BackupAsync
MODIFY
WalletWasabi.Tests/HwiTests/DeviceConnectedTests/Katas.cs
WalletWasabi.Tests/HwiTests/DeviceConnectedTests/Katas.cs
@@ -34,8 +34,6 @@ namespace WalletWasabi.Tests.HwiTests.DeviceConnectedTests
//
// Connect an already initialized device and unlock it.
// Run this test.
- // Setup request: refuse.
- // Restore request: refuse.
//
// --- USER INTERACTIONS ---
@@ -54,11 +52,17 @@ namespace WalletWasabi.Tests.HwiTests.DeviceConnectedTests
// USER: REFUSE
await Assert.ThrowsAsync<HwiException>(async () => await client.RestoreAsync(deviceType, devicePath, cts.Token));
- // ToDo: Backup
+ // Trezor doesn't support backup.
+ await Assert.ThrowsAsync<HwiException>(async () => await client.BackupAsync(deviceType, devicePath, cts.Token));
+
+ // ToDo: promptpin (Assert not working)
+ // ToDo: sendpin (Assert not working)
// ToDo: getxpub
// ToDo: displayaddress
// ToDo: signmessage
// ToDo: signtx
+ // ToDo: --fingerprint
+ // ToDo: --password
}
}
}

MODIFY
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/IMockHwiProcessBridge.cs
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/IMockHwiProcessBridge.cs
@@ -64,6 +64,24 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
return Task.FromResult((response, code));
}
}
+ else if (arguments == "--device-path \"webusb: 001:4\" --device-type \"trezor\" --interactive backup" || arguments == "--testnet --device-path \"webusb: 001:4\" --device-type \"trezor\" --interactive backup")
+ {
+ if (Model == HardwareWalletModels.TrezorT)
+ {
+ var response = "{\"error\": \"The Trezor does not support creating a backup via software\", \"code\": -9}";
+ var code = 0;
+ return Task.FromResult((response, code));
+ }
+ }
+ else if (arguments == "--device-path \"webusb: 001:4\" --device-type \"trezor\" backup" || arguments == "--testnet --device-path \"webusb: 001:4\" --device-type \"trezor\" backup")
+ {
+ if (Model == HardwareWalletModels.TrezorT)
+ {
+ var response = "{\"error\": \"The Trezor does not support creating a backup via software\", \"code\": -9}";
+ var code = 0;
+ return Task.FromResult((response, code));
+ }
+ }
throw new NotImplementedException($"Mocking is not implemented for '{arguments}'");
}

MODIFY
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/MockedDeviceTests.cs
WalletWasabi.Tests/HwiTests/NoDeviceConnectedTests/MockedDeviceTests.cs
@@ -48,6 +48,9 @@ namespace WalletWasabi.Tests.HwiTests.NoDeviceConnectedTests
await client.WipeAsync(deviceType, devicePath, cts.Token);
await client.SetupAsync(deviceType, devicePath, cts.Token);
await client.RestoreAsync(deviceType, devicePath, cts.Token);
+
+ // Trezor doesn't support backup.
+ await Assert.ThrowsAsync<HwiException>(async () => await client.BackupAsync(deviceType, devicePath, cts.Token));
}
}

MODIFY
WalletWasabi/Hwi2/HwiClient.cs
WalletWasabi/Hwi2/HwiClient.cs
@@ -95,6 +95,20 @@ namespace WalletWasabi.Hwi2
cancel).ConfigureAwait(false);
}
+ public async Task BackupAsync(HardwareWalletVendors deviceType, string devicePath, CancellationToken cancel)
+ {
+ if (deviceType == HardwareWalletVendors.Trezor)
+ {
+ // HWI would throw the same, don't need the roundtrip.
+ throw new HwiException(HwiErrorCode.UnavailableAction, "The Trezor does not support creating a backup via software");
+ }
+
+ await SendCommandAsync(
+ options: new[] { HwiOption.DevicePath(devicePath), HwiOption.DeviceType(deviceType), HwiOption.Interactive },
+ command: HwiCommands.Backup,
+ cancel).ConfigureAwait(false);
+ }
+
public async Task<Version> GetVersionAsync(CancellationToken cancel)
{
string responseString = await SendCommandAsync(options: new[] { HwiOption.Version }, command: null, cancel).ConfigureAwait(false);

Implement BackupAsync