From b7a4f7c29eb5d91bfa7426f80042c2e67d72d1fa Mon Sep 17 00:00:00 2001
From: julian <julian@cypherstack.com>
Date: Tue, 4 Jun 2024 09:40:45 -0600
Subject: [PATCH] fix initial xmr/wow address not showing up on first wallet
 open

---
 lib/wallets/wallet/impl/monero_wallet.dart  | 12 ++++++++++++
 lib/wallets/wallet/impl/wownero_wallet.dart | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/lib/wallets/wallet/impl/monero_wallet.dart b/lib/wallets/wallet/impl/monero_wallet.dart
index 71dc2e238..9bcb4c3d7 100644
--- a/lib/wallets/wallet/impl/monero_wallet.dart
+++ b/lib/wallets/wallet/impl/monero_wallet.dart
@@ -126,6 +126,18 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
 
     await updateNode();
 
+    Address? currentAddress = await getCurrentReceivingAddress();
+    if (currentAddress == null) {
+      currentAddress = addressFor(index: 0);
+      await mainDB.updateOrPutAddresses([currentAddress]);
+    }
+    if (info.cachedReceivingAddress != currentAddress.value) {
+      await info.updateReceivingAddress(
+        newAddress: currentAddress.value,
+        isar: mainDB.isar,
+      );
+    }
+
     await CwBasedInterface.cwWalletBase?.startSync();
     unawaited(refresh());
     autoSaveTimer?.cancel();
diff --git a/lib/wallets/wallet/impl/wownero_wallet.dart b/lib/wallets/wallet/impl/wownero_wallet.dart
index e8d8c3646..ced514aa3 100644
--- a/lib/wallets/wallet/impl/wownero_wallet.dart
+++ b/lib/wallets/wallet/impl/wownero_wallet.dart
@@ -452,6 +452,18 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
 
     await updateNode();
 
+    Address? currentAddress = await getCurrentReceivingAddress();
+    if (currentAddress == null) {
+      currentAddress = addressFor(index: 0);
+      await mainDB.updateOrPutAddresses([currentAddress]);
+    }
+    if (info.cachedReceivingAddress != currentAddress.value) {
+      await info.updateReceivingAddress(
+        newAddress: currentAddress.value,
+        isar: mainDB.isar,
+      );
+    }
+
     await (CwBasedInterface.cwWalletBase as WowneroWalletBase?)?.startSync();
     unawaited(refresh());
     autoSaveTimer?.cancel();