Add oneliner exc
MODIFY
WalletWasabi/Helpers/ImportWalletHelper.cs
WalletWasabi/Helpers/ImportWalletHelper.cs
@@ -52,17 +52,12 @@ public static class ImportWalletHelper
private static KeyManager GetKeyManagerByColdcardJson(WalletManager manager, JObject jsonWallet, string walletFullPath)
{
- var xpubString = jsonWallet["ExtPubKey"]?.ToString();
- if (xpubString is null)
- {
- throw new ArgumentNullException($"Can't get KeyManager, ExtPubKey was null.");
- }
+ var xpubString = jsonWallet["ExtPubKey"]?.ToString()
+ ?? throw new ArgumentNullException($"Can't get KeyManager, ExtPubKey was null.");
+
+ var mfpString = jsonWallet["MasterFingerprint"]?.ToString()
+ ?? throw new ArgumentNullException($"Can't get KeyManager, MasterFingerprint was null.");
- var mfpString = jsonWallet["MasterFingerprint"]?.ToString();
- if (mfpString is null)
- {
- throw new ArgumentNullException($"Can't get KeyManager, MasterFingerprint was null.");
- }
// https://github.com/zkSNACKs/WalletWasabi/pull/1663#issuecomment-508073066
// Coldcard 2.1.0 improperly implemented Wasabi skeleton fingerprint at first, so we must reverse byte order.
// The solution was to add a ColdCardFirmwareVersion json field from 2.1.1 and correct the one generated by 2.1.0.

MODIFY
WalletWasabi/Hwi/Parsers/HwiParser.cs
WalletWasabi/Hwi/Parsers/HwiParser.cs
@@ -220,16 +220,12 @@ public static class HwiParser
public static HwiEnumerateEntry ParseHwiEnumerateEntry(JObject json)
{
- JToken? modelToken = json["model"];
- if (modelToken == null)
- {
- throw new ArgumentNullException($"{nameof(modelToken)} can't be null;");
- }
- var pathString = json["path"]?.ToString().Trim();
- if (pathString == null)
- {
- throw new ArgumentNullException($"Path can't be null;");
- }
+ JToken? modelToken = json["model"]
+ ?? throw new ArgumentNullException($"{nameof(modelToken)} can't be null;");
+
+ var pathString = json["path"]?.ToString().Trim()
+ ?? throw new ArgumentNullException($"Path can't be null;");
+
var serialNumberString = json["serial_number"]?.ToString()?.Trim();
var fingerprintString = json["fingerprint"]?.ToString()?.Trim();
var needsPinSentString = json["needs_pin_sent"]?.ToString()?.Trim();

Add oneliner exc