Handle ColdCardFirmwareVersion
MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -114,7 +114,26 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
var json = JObject.Parse(jsonString);
var xpubString = json["ExtPubKey"].ToString();
var mfpString = json["MasterFingerprint"].ToString();
- HDFingerprint mfp = NBitcoinHelpers.BetterParseHDFingerprint(mfpString, reverseByteOrder: true); // Coldcard improperly implemented Wasabi skeleton fingerpring, so we must reverse byte order.
+
+ // https://github.com/zkSNACKs/WalletWasabi/pull/1663#issuecomment-508073066
+ // Coldcard 2.1.0 improperly implemented Wasabi skeleton fingerpring 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.
+ var coldCardVersionString = json["ColdCardFirmwareVersion"]?.ToString();
+ var reverseByteOrder = false;
+ if (coldCardVersionString is null)
+ {
+ reverseByteOrder = true;
+ }
+ else
+ {
+ Version coldCardVersion = new Version(coldCardVersionString);
+
+ if (coldCardVersion == new Version("2.1.0")) // Should never happen though.
+ {
+ reverseByteOrder = true;
+ }
+ }
+ HDFingerprint mfp = NBitcoinHelpers.BetterParseHDFingerprint(mfpString, reverseByteOrder: reverseByteOrder);
ExtPubKey extPubKey = NBitcoinHelpers.BetterParseExtPubKey(xpubString);
Logger.LogInfo<LoadWalletViewModel>("Creating new wallet file.");
var walletName = Global.GetNextHardwareWalletName(customPrefix: "Coldcard");

Handle ColdCardFirmwareVersion