Make HasLabel a property.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -105,7 +105,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
_addresses?.Clear();
foreach (HdPubKey key in Global.WalletService.KeyManager.GetKeys(x =>
- x.HasLabel()
+ x.HasLabel
&& !x.IsInternal
&& x.KeyState == KeyState.Clean)
.Reverse())

MODIFY
WalletWasabi/KeyManagement/HdPubKey.cs
WalletWasabi/KeyManagement/HdPubKey.cs
@@ -18,8 +18,20 @@ namespace WalletWasabi.KeyManagement
[JsonConverter(typeof(KeyPathJsonConverter))]
public KeyPath FullKeyPath { get; }
+ private string _label;
+
[JsonProperty(Order = 3)]
- public string Label { get; private set; }
+ public string Label
+ {
+ get => _label; private set
+ {
+ if (value != _label)
+ {
+ _label = value;
+ HasLabel = !string.IsNullOrEmpty(value);
+ }
+ }
+ }
[JsonProperty(Order = 4)]
public KeyState KeyState { get; private set; }
@@ -82,14 +94,14 @@ namespace WalletWasabi.KeyManagement
public KeyPath NonHardenedKeyPath { get; }
public bool IsInternal { get; }
+ public bool HasLabel { get; private set; }
+
public BitcoinPubKeyAddress GetP2pkhAddress(Network network) => PubKey.GetAddress(network);
public BitcoinWitPubKeyAddress GetP2wpkhAddress(Network network) => PubKey.GetSegwitAddress(network);
public BitcoinScriptAddress GetP2shOverP2wpkhAddress(Network network) => P2wpkhScript.GetScriptAddress(network);
- public bool HasLabel() => !string.IsNullOrEmpty(Label);
-
#region Equality
public override bool Equals(object obj) => obj is HdPubKey && this == (HdPubKey)obj;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -351,7 +351,7 @@ namespace WalletWasabi.Services
}
}
- var foundLabelless = keys.FirstOrDefault(x => !x.HasLabel()); // Return the first labelless.
+ var foundLabelless = keys.FirstOrDefault(x => !x.HasLabel); // Return the first labelless.
HdPubKey ret = foundLabelless ?? keys.RandomElement(); // Return the first, because that's the oldest.
ret.SetLabel(label, KeyManager);

Make HasLabel a property.