Faster hardware wallet load
MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -348,8 +348,8 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
{
if (walletFile?.Extension?.Equals(".json", StringComparison.OrdinalIgnoreCase) is true)
{
- var km = KeyManager.FromFile(walletFile.FullName);
- if (km.ExtPubKey == extPubKey) // We already had it.
+ var epk = KeyManager.ExtPubKeyFromFile(walletFile.FullName);
+ if (epk == extPubKey) // We already had it.
{
walletName = walletFile.Name;
break;

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -132,7 +132,7 @@ namespace NBitcoin
return requester.BlindMessage(msg, RPubKey, signerPubKey);
}
- public static Signer Create(this Signer signer, SchnorrKey schnorrKey)
+ public static Signer CreateSigner(this SchnorrKey schnorrKey)
{
var k = Guard.NotNull(nameof(schnorrKey.SignerKey), schnorrKey.SignerKey);
var r = Guard.NotNull(nameof(schnorrKey.Rkey), schnorrKey.Rkey);

MODIFY
WalletWasabi/Helpers/NBitcoinHelpers.cs
WalletWasabi/Helpers/NBitcoinHelpers.cs
@@ -53,5 +53,22 @@ namespace WalletWasabi.Helpers
var vSize = (int)Math.Ceiling(((3 * newTxSize) + origTxSize) / 4m);
return vSize;
}
+
+ public static ExtPubKey BetterParseExtPubKey(string extPubKeyString)
+ {
+ extPubKeyString = Guard.NotNullOrEmptyOrWhitespace(nameof(extPubKeyString), extPubKeyString, trim: true);
+
+ ExtPubKey epk;
+ try
+ {
+ epk = ExtPubKey.Parse(extPubKeyString); // Starts with "ExtPubKey": "xpub...
+ }
+ catch
+ {
+ // Try hex, Old wallet format was like this.
+ epk = new ExtPubKey(ByteHelpers.FromHex(extPubKeyString)); // Starts with "ExtPubKey": "hexbytes...
+ }
+ return epk;
+ }
}
}

MODIFY
WalletWasabi/Hwi/HwiProcessManager.cs
WalletWasabi/Hwi/HwiProcessManager.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Hwi
JObject json = jtok as JObject;
string xpub = json.Value<string>("xpub");
- ExtPubKey extpub = ExtPubKey.Parse(xpub);
+ ExtPubKey extpub = NBitcoinHelpers.BetterParseExtPubKey(xpub);
return extpub;
}

MODIFY
WalletWasabi/KeyManagement/KeyManager.cs
WalletWasabi/KeyManagement/KeyManager.cs
@@ -274,17 +274,7 @@ namespace WalletWasabi.KeyManagement
var xpub = parts[1].TrimEnd(',', '"');
- ExtPubKey epk;
-
- try
- {
- epk = ExtPubKey.Parse(xpub); // Starts with "ExtPubKey": "xpub...
- }
- catch
- {
- // Try hex, Old wallet format was like this.
- epk = new ExtPubKey(ByteHelpers.FromHex(xpub)); // Starts with "ExtPubKey": "hexbytes...
- }
+ var epk = NBitcoinHelpers.BetterParseExtPubKey(xpub);
return epk;
}

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/MixingLevel.cs
WalletWasabi/Models/ChaumianCoinJoin/MixingLevel.cs
@@ -29,7 +29,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
rKey = Guard.NotNull(nameof(rKey), rKey);
SchnorrKey = new SchnorrKey(signerKey, rKey);
- Signer = Signer.Create(SchnorrKey);
+ Signer = SchnorrKey.CreateSigner();
}
[JsonConstructor]
@@ -38,7 +38,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
Denomination = Guard.NotNull(nameof(denomination), denomination);
SchnorrKey = Guard.NotNull(nameof(schnorrKey), schnorrKey);
- Signer = Signer.Create(SchnorrKey);
+ Signer = SchnorrKey.CreateSigner();
}
public Signer Signer { get; }

Faster hardware wallet load