From fb2d05eadd924544e5a8ee229e2bb6f19f7031b7 Mon Sep 17 00:00:00 2001
From: ryleedavis <rylee@cypherstack.com>
Date: Wed, 25 Jan 2023 16:48:50 -0700
Subject: [PATCH 1/5] desktop exchange toggle color fix

---
 lib/utilities/theme/fruit_sorbet_colors.dart | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/utilities/theme/fruit_sorbet_colors.dart b/lib/utilities/theme/fruit_sorbet_colors.dart
index 6f0a81e82..3394b3a9c 100644
--- a/lib/utilities/theme/fruit_sorbet_colors.dart
+++ b/lib/utilities/theme/fruit_sorbet_colors.dart
@@ -327,7 +327,7 @@ class FruitSorbetColors extends StackColorTheme {
   @override
   Color get rateTypeToggleDesktopColorOn => const Color(0xFFFFD8CE);
   @override
-  Color get rateTypeToggleDesktopColorOff => buttonBackSecondary;
+  Color get rateTypeToggleDesktopColorOff => popupBG;
 
   @override
   BoxShadow get standardBoxShadow => BoxShadow(

From ffda21f51387e678d7dd558033bd559f5c3370d2 Mon Sep 17 00:00:00 2001
From: julian <julian@cypherstack.com>
Date: Wed, 25 Jan 2023 17:42:20 -0600
Subject: [PATCH 2/5] desktop xmr/wow single wallet opening bug fix

---
 .../my_stack_view/wallet_summary_table.dart           | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart
index b638d72a1..9b98d4aa8 100644
--- a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart
+++ b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart
@@ -46,10 +46,15 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
 
               VoidCallback? expandOverride;
               if (providers.length == 1) {
-                expandOverride = () {
-                  Navigator.of(context).pushNamed(
+                expandOverride = () async {
+                  final manager = ref.read(providers.first);
+                  if (manager.coin == Coin.monero ||
+                      manager.coin == Coin.wownero) {
+                    await manager.initializeExisting();
+                  }
+                  await Navigator.of(context).pushNamed(
                     DesktopWalletView.routeName,
-                    arguments: ref.read(providers.first).walletId,
+                    arguments: manager.walletId,
                   );
                 };
               }

From b49a1942a644c887f00cd98451772c2b9863474b Mon Sep 17 00:00:00 2001
From: julian <julian@cypherstack.com>
Date: Thu, 26 Jan 2023 09:18:07 -0600
Subject: [PATCH 3/5] update to versioned desktop secure storage and login key
 blob

---
 crypto_plugins/flutter_libmonero            |  2 +-
 lib/utilities/desktop_password_service.dart | 59 +++++++++++++++++++--
 pubspec.lock                                |  4 +-
 pubspec.yaml                                |  2 +-
 4 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero
index c1b403ccf..af88796d5 160000
--- a/crypto_plugins/flutter_libmonero
+++ b/crypto_plugins/flutter_libmonero
@@ -1 +1 @@
-Subproject commit c1b403ccf6f4fffc9f7c233038c3df40f997c2b3
+Subproject commit af88796d5e4988c03422320c3842af5cf6c049ef
diff --git a/lib/utilities/desktop_password_service.dart b/lib/utilities/desktop_password_service.dart
index 9ef83932b..6263eb33b 100644
--- a/lib/utilities/desktop_password_service.dart
+++ b/lib/utilities/desktop_password_service.dart
@@ -4,9 +4,12 @@ import 'package:stackwallet/hive/db.dart';
 import 'package:stackwallet/utilities/logger.dart';
 
 const String _kKeyBlobKey = "swbKeyBlobKeyStringID";
+const String _kKeyBlobVersionKey = "swbKeyBlobVersionKeyStringID";
+
+const int kLatestBlobVersion = 2;
 
 String _getMessageFromException(Object exception) {
-  if (exception is IncorrectPassphrase) {
+  if (exception is IncorrectPassphraseOrVersion) {
     return exception.errMsg();
   }
   if (exception is BadDecryption) {
@@ -18,6 +21,9 @@ String _getMessageFromException(Object exception) {
   if (exception is EncodingError) {
     return exception.errMsg();
   }
+  if (exception is VersionError) {
+    return exception.errMsg();
+  }
 
   return exception.toString();
 }
@@ -41,7 +47,10 @@ class DPS {
     }
 
     try {
-      _handler = await StorageCryptoHandler.fromNewPassphrase(passphrase);
+      _handler = await StorageCryptoHandler.fromNewPassphrase(
+        passphrase,
+        kLatestBlobVersion,
+      );
 
       final box = await Hive.openBox<String>(DB.boxNameDesktopData);
       await DB.instance.put<String>(
@@ -49,6 +58,7 @@ class DPS {
         key: _kKeyBlobKey,
         value: await _handler!.getKeyBlob(),
       );
+      await _updateStoredKeyBlobVersion(kLatestBlobVersion);
       await box.close();
     } catch (e, s) {
       Logging.instance.log(
@@ -78,7 +88,24 @@ class DPS {
     }
 
     try {
-      _handler = await StorageCryptoHandler.fromExisting(passphrase, keyBlob);
+      final blobVersion = await _getStoredKeyBlobVersion();
+      _handler = await StorageCryptoHandler.fromExisting(
+        passphrase,
+        keyBlob,
+        blobVersion,
+      );
+      if (blobVersion < kLatestBlobVersion) {
+        // update blob
+        await _handler!.resetPassphrase(passphrase, kLatestBlobVersion);
+        final box = await Hive.openBox<String>(DB.boxNameDesktopData);
+        await DB.instance.put<String>(
+          boxName: DB.boxNameDesktopData,
+          key: _kKeyBlobKey,
+          value: await _handler!.getKeyBlob(),
+        );
+        await _updateStoredKeyBlobVersion(kLatestBlobVersion);
+        await box.close();
+      }
     } catch (e, s) {
       Logging.instance.log(
         "${_getMessageFromException(e)}\n$s",
@@ -102,7 +129,8 @@ class DPS {
     }
 
     try {
-      await StorageCryptoHandler.fromExisting(passphrase, keyBlob);
+      final blobVersion = await _getStoredKeyBlobVersion();
+      await StorageCryptoHandler.fromExisting(passphrase, keyBlob, blobVersion);
       // existing passphrase matches key blob
       return true;
     } catch (e, s) {
@@ -135,8 +163,10 @@ class DPS {
       return false;
     }
 
+    final blobVersion = await _getStoredKeyBlobVersion();
+
     try {
-      await _handler!.resetPassphrase(passphraseNew);
+      await _handler!.resetPassphrase(passphraseNew, blobVersion);
 
       final box = await Hive.openBox<String>(DB.boxNameDesktopData);
       await DB.instance.put<String>(
@@ -144,6 +174,7 @@ class DPS {
         key: _kKeyBlobKey,
         value: await _handler!.getKeyBlob(),
       );
+      await _updateStoredKeyBlobVersion(blobVersion);
       await box.close();
 
       // successfully updated passphrase
@@ -164,4 +195,22 @@ class DPS {
     );
     return keyBlob != null;
   }
+
+  Future<int> _getStoredKeyBlobVersion() async {
+    final box = await Hive.openBox<String>(DB.boxNameDesktopData);
+    final keyBlobVersionString = DB.instance.get<String>(
+      boxName: DB.boxNameDesktopData,
+      key: _kKeyBlobVersionKey,
+    );
+    await box.close();
+    return int.tryParse(keyBlobVersionString ?? "1") ?? 1;
+  }
+
+  Future<void> _updateStoredKeyBlobVersion(int version) async {
+    await DB.instance.put<String>(
+      boxName: DB.boxNameDesktopData,
+      key: _kKeyBlobVersionKey,
+      value: version.toString(),
+    );
+  }
 }
diff --git a/pubspec.lock b/pubspec.lock
index 8364e6ec9..43c38602b 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1408,8 +1408,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: "6ada1204a4e0cf84d932b568e6150550478db69b"
-      resolved-ref: "6ada1204a4e0cf84d932b568e6150550478db69b"
+      ref: "93e2687bcc10fc7258c7dab038c363fc9ff8ba5d"
+      resolved-ref: "93e2687bcc10fc7258c7dab038c363fc9ff8ba5d"
       url: "https://github.com/cypherstack/stack_wallet_backup.git"
     source: git
     version: "0.0.1"
diff --git a/pubspec.yaml b/pubspec.yaml
index ccaa53a4f..05701de28 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -54,7 +54,7 @@ dependencies:
   stack_wallet_backup:
     git:
       url: https://github.com/cypherstack/stack_wallet_backup.git
-      ref: 6ada1204a4e0cf84d932b568e6150550478db69b
+      ref: 93e2687bcc10fc7258c7dab038c363fc9ff8ba5d
 
   bip47:
     git:

From bb94ad107076ed65fbe279a4b1353de3dd99f452 Mon Sep 17 00:00:00 2001
From: julian <julian@cypherstack.com>
Date: Thu, 26 Jan 2023 10:05:49 -0600
Subject: [PATCH 4/5] update swb ref

---
 pubspec.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pubspec.yaml b/pubspec.yaml
index 05701de28..0d20f2f7e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -54,7 +54,7 @@ dependencies:
   stack_wallet_backup:
     git:
       url: https://github.com/cypherstack/stack_wallet_backup.git
-      ref: 93e2687bcc10fc7258c7dab038c363fc9ff8ba5d
+      ref: e4b08d2b8965a5ae49bd57f598fa9011dd0c25e9
 
   bip47:
     git:

From 1d9120419ed4f62f47ccf662b17a738b4e6e4a71 Mon Sep 17 00:00:00 2001
From: ryleedavis <rylee@cypherstack.com>
Date: Fri, 27 Jan 2023 09:22:07 -0700
Subject: [PATCH 5/5] fixed sw default theme color

---
 lib/main.dart | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/main.dart b/lib/main.dart
index 8296d739a..493347263 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -344,12 +344,12 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
       case "oceanBreeze":
         colorTheme = OceanBreezeColors();
         break;
-      case "light":
-        colorTheme = LightColors();
-        break;
       case "fruitSorbet":
-      default:
         colorTheme = FruitSorbetColors();
+        break;
+      case "light":
+      default:
+        colorTheme = LightColors();
     }
     loadingCompleter = Completer();
     WidgetsBinding.instance.addObserver(this);