Add icon to walletfile
MODIFY
WalletWasabi.Fluent/Converters/WalletTypeImageConverter.cs
WalletWasabi.Fluent/Converters/WalletTypeImageConverter.cs
@@ -4,7 +4,7 @@ using Avalonia.Media.Imaging;
using Avalonia.Platform;
using System;
using System.Globalization;
-using WalletWasabi.Fluent.ViewModels.AddWallet;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.Converters
{

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
@@ -81,10 +81,10 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
return;
}
- var (isColdCardJson, keyManager) = await ImportWalletHelper.ImportWalletAsync(walletManager, WalletName, filePath);
+ var keyManager = await ImportWalletHelper.ImportWalletAsync(walletManager, WalletName, filePath);
// TODO: get the type from the wallet file
- Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager, isColdCardJson ? WalletType.Coldcard : WalletType.Normal));
+ Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager));
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/AddedWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/AddedWalletPageViewModel.cs
+using System;
using System.Linq;
using ReactiveUI;
using WalletWasabi.Blockchain.Keys;
@@ -9,11 +10,16 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
public class AddedWalletPageViewModel : RoutableViewModel
{
- public AddedWalletPageViewModel(WalletManager walletManager, KeyManager keyManager, WalletType type)
+ public AddedWalletPageViewModel(WalletManager walletManager, KeyManager keyManager)
{
Title = "Success";
WalletName = keyManager.WalletName;
- Type = type;
+
+ Type = Enum.TryParse(typeof(WalletType), keyManager.Icon, true, out var typ) && typ is { }
+ ? (WalletType)typ
+ : keyManager.IsHardwareWallet
+ ? WalletType.Hardware
+ : WalletType.Normal;
NextCommand = ReactiveCommand.Create(
() =>

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/Create/ConfirmRecoveryWordsViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/Create/ConfirmRecoveryWordsViewModel.cs
@@ -34,7 +34,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.Create
NextCommand = ReactiveCommand.Create(
() =>
{
- Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager, WalletType.Normal));
+ Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager));
},
nextCommandCanExecute);

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/DetectedHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/DetectedHardwareWalletViewModel.cs
@@ -5,6 +5,7 @@ using WalletWasabi.Extensions;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Hwi.Models;
using WalletWasabi.Logging;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
{
@@ -15,27 +16,13 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
Title = "Hardware Wallet";
WalletName = walletName;
- switch (hardwareWalletOperations.SelectedDevice!.Model)
+ Type = hardwareWalletOperations.SelectedDevice!.Model switch
{
- case HardwareWalletModels.Coldcard:
- case HardwareWalletModels.Coldcard_Simulator:
- Type = WalletType.Coldcard;
- break;
-
- case HardwareWalletModels.Ledger_Nano_S:
- Type = WalletType.Ledger;
- break;
-
- case HardwareWalletModels.Trezor_1:
- case HardwareWalletModels.Trezor_1_Simulator:
- case HardwareWalletModels.Trezor_T:
- case HardwareWalletModels.Trezor_T_Simulator:
- Type = WalletType.Trezor;
- break;
- default:
- Type = WalletType.Hardware;
- break;
- }
+ HardwareWalletModels.Coldcard or HardwareWalletModels.Coldcard_Simulator => WalletType.Coldcard,
+ HardwareWalletModels.Ledger_Nano_S => WalletType.Ledger,
+ HardwareWalletModels.Trezor_1 or HardwareWalletModels.Trezor_1_Simulator or HardwareWalletModels.Trezor_T or HardwareWalletModels.Trezor_T_Simulator => WalletType.Trezor,
+ _ => WalletType.Hardware,
+ };
TypeName = hardwareWalletOperations.SelectedDevice.Model.FriendlyName();
@@ -48,8 +35,9 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
var km = await hardwareWalletOperations.GenerateWalletAsync(WalletName);
var walletManager = hardwareWalletOperations.WalletManager;
hardwareWalletOperations.Dispose();
+ km.SetIcon(Type);
- Navigate().To(new AddedWalletPageViewModel(walletManager, km, Type));
+ Navigate().To(new AddedWalletPageViewModel(walletManager, km));
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -107,7 +107,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
return result;
});
- Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager, WalletType.Normal));
+ Navigate().To(new AddedWalletPageViewModel(walletManager, keyManager));
return;
}

MODIFY
WalletWasabi/Blockchain/Keys/KeyManager.cs
WalletWasabi/Blockchain/Keys/KeyManager.cs
@@ -11,6 +11,7 @@ using WalletWasabi.Helpers;
using WalletWasabi.JsonConverters;
using WalletWasabi.Logging;
using WalletWasabi.Models;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Blockchain.Keys
{
@@ -118,6 +119,9 @@ namespace WalletWasabi.Blockchain.Keys
[JsonProperty(Order = 9)]
private List<HdPubKey> HdPubKeys { get; }
+ [JsonProperty(Order = 10, PropertyName = "Icon")]
+ public string? Icon { get; private set; }
+
private object BlockchainStateLock { get; }
private object HdPubKeysLock { get; }
@@ -763,6 +767,20 @@ namespace WalletWasabi.Blockchain.Keys
}
}
+ public void SetIcon(string icon)
+ {
+ lock (BlockchainStateLock)
+ {
+ Icon = icon;
+ ToFileNoBlockchainStateLock();
+ }
+ }
+
+ public void SetIcon(WalletType type)
+ {
+ SetIcon(type.ToString());
+ }
+
public void AssertNetworkOrClearBlockState(Network expectedNetwork)
{
lock (BlockchainStateLock)

RENAME
WalletWasabi.Fluent/ViewModels/AddWallet/WalletType.cs
WalletWasabi/Wallets/WalletType.cs
-namespace WalletWasabi.Fluent.ViewModels.AddWallet
+namespace WalletWasabi.Wallets
{
public enum WalletType
{

Add icon to walletfile