Fix db getting deleted on iOS (#2736)

* Fix db getting deleted on iOS * Fix db getting deleted on iOS and add a patch for users who updated * remove prints [skip ci]

Omar Hatem committed Dec 15, 2025 at 04:49 UTC aea855d0232f3d4cc60237b2c2bef5cbe4dc98cb
11 files changed +36 -15
assets/text/Monerocom_Release_Notes.txt
-2
@@ -1,3 +1 @@
1 -Fix QR scanning
2 -UI enhancements
1 Bug fixes
\ No newline at end of file
assets/text/Release_Notes.txt
-2
@@ -1,3 +1 @@
1 -Fix QR scanning
2 -UI enhancements
1 Bug fixes
\ No newline at end of file
cw_bitcoin/lib/bitcoin_wallet.dart
+9
@@ -224,6 +224,15 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
224 snp?.derivationPath ?? electrum_path;
225 derivationInfo.derivationType ??=
226 snp?.derivationType ?? DerivationType.electrum;
227 + if (derivationInfo.derivationType == DerivationType.unknown) {
228 + if (snp?.derivationPath == electrum_path || snp?.derivationType == DerivationType.electrum) {
229 + derivationInfo.derivationPath = electrum_path;
230 + derivationInfo.derivationType = DerivationType.electrum;
231 + } else {
232 + derivationInfo.derivationPath = segwit_path;
233 + derivationInfo.derivationType = DerivationType.bip39;
234 + }
235 + }
236 await derivationInfo.save();
237
238 Uint8List? seedBytes = null;
cw_bitcoin/lib/electrum_derivations.dart
+1
@@ -115,3 +115,4 @@ Map<DerivationType, List<DerivationInfo>> electrum_derivations = {
115 };
116
117 String electrum_path = electrum_derivations[DerivationType.electrum]!.first.derivationPath!;
118 +String segwit_path = "m/84'/0'/0'";
cw_bitcoin/lib/litecoin_wallet.dart
+9
@@ -283,6 +283,15 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
283 // set the default if not present:
284 derivationInfo.derivationPath ??= snp?.derivationPath ?? electrum_path;
285 derivationInfo.derivationType ??= snp?.derivationType ?? DerivationType.electrum;
286 + if (derivationInfo.derivationType == DerivationType.unknown) {
287 + if (snp?.derivationPath == electrum_path || snp?.derivationType == DerivationType.electrum) {
288 + derivationInfo.derivationPath = electrum_path;
289 + derivationInfo.derivationType = DerivationType.electrum;
290 + } else {
291 + derivationInfo.derivationPath = segwit_path;
292 + derivationInfo.derivationType = DerivationType.bip39;
293 + }
294 + }
295
296 Uint8List? seedBytes = null;
297 final mnemonic = keysData.mnemonic;
cw_core/lib/db/sqlite.dart
+1 -1
@@ -15,7 +15,7 @@ Future<void> initDb({String? pathOverride}) async {
15 final dbFileOld = File("${await getDatabasesPath()}/cake.db");
16 final dbFile = File("${(await getAppDir()).path}/cake.db");
17
18 - if (dbFileOld.existsSync()) {
18 + if (Platform.isAndroid && dbFileOld.existsSync() && dbFileOld.path != dbFile.path) {
19 final copied = dbFileOld.copySync(dbFile.path);
20 if (copied.existsSync()) {
21 dbFileOld.deleteSync();
cw_nano/lib/nano_wallet.dart
+7
@@ -436,6 +436,13 @@ abstract class NanoWalletBase
436
437 final derivationInfo = await walletInfo.getDerivationInfo();
438 derivationInfo.derivationType ??= derivationType;
439 + if (derivationInfo.derivationType == DerivationType.unknown) {
440 + if (data?['derivationType'] != null) {
441 + derivationInfo.derivationType = derivationType;
442 + } else {
443 + derivationInfo.derivationType = DerivationType.bip39;
444 + }
445 + }
446 derivationInfo.save();
447
448 return NanoWallet(
lib/src/screens/new_wallet/new_wallet_page.dart
+1 -1
@@ -360,7 +360,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
360 alertContent: S.of(context).wallet_name_exists,
361 buttonText: S.of(context).ok,
362 buttonAction: () {
363 - if (Navigator.of(context).canPop()) {
363 + if (mounted && Navigator.of(context).canPop()) {
364 Navigator.of(context).pop();
365 }
366 });
lib/src/screens/restore/wallet_restore_choose_derivation.dart
-1
@@ -17,7 +17,6 @@ class WalletRestoreChooseDerivationPage extends BasePage {
17 );
18
19 final WalletRestoreChooseDerivationViewModel walletRestoreChooseDerivationViewModel;
20 - DerivationType derivationType = DerivationType.unknown;
20
21 @override
22 Widget body(BuildContext context) {
scripts/android/app_env.sh
+4 -4
@@ -14,15 +14,15 @@ TYPES=($MONERO_COM $CAKEWALLET)
14 APP_ANDROID_TYPE=$1
15
16 MONERO_COM_NAME="Monero.com"
17 -MONERO_COM_VERSION="5.6.3"
18 -MONERO_COM_BUILD_NUMBER=4148
17 +MONERO_COM_VERSION="5.6.4"
18 +MONERO_COM_BUILD_NUMBER=4149
19 MONERO_COM_BUNDLE_ID="com.monero.app"
20 MONERO_COM_PACKAGE="com.monero.app"
21 MONERO_COM_SCHEME="monero.com"
22
23 CAKEWALLET_NAME="Cake Wallet"
24 -CAKEWALLET_VERSION="5.6.3"
25 -CAKEWALLET_BUILD_NUMBER=4294
24 +CAKEWALLET_VERSION="5.6.4"
25 +CAKEWALLET_BUILD_NUMBER=4295
26 CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
27 CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
28 CAKEWALLET_SCHEME="cakewallet"
scripts/ios/app_env.sh
+4 -4
@@ -12,13 +12,13 @@ TYPES=($MONERO_COM $CAKEWALLET)
12 APP_IOS_TYPE=$1
13
14 MONERO_COM_NAME="Monero.com"
15 -MONERO_COM_VERSION="5.6.3"
16 -MONERO_COM_BUILD_NUMBER=151
15 +MONERO_COM_VERSION="5.6.4"
16 +MONERO_COM_BUILD_NUMBER=152
17 MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
18
19 CAKEWALLET_NAME="Cake Wallet"
20 -CAKEWALLET_VERSION="5.6.3"
21 -CAKEWALLET_BUILD_NUMBER=357
20 +CAKEWALLET_VERSION="5.6.4"
21 +CAKEWALLET_BUILD_NUMBER=359
22 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
23
24