diff --git a/Decred Wallet.xcodeproj/project.pbxproj b/Decred Wallet.xcodeproj/project.pbxproj index 1ddfd2436..9dbbb1aef 100644 --- a/Decred Wallet.xcodeproj/project.pbxproj +++ b/Decred Wallet.xcodeproj/project.pbxproj @@ -1369,7 +1369,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.3; PRODUCT_BUNDLE_IDENTIFIER = com.decred.dcrios.testnet3; PRODUCT_NAME = "$(TARGET_NAME) Testnet"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1453,7 +1453,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.3; PRODUCT_BUNDLE_IDENTIFIER = com.decred.dcrios.testnet3; PRODUCT_NAME = "$(TARGET_NAME) Testnet"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1598,7 +1598,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.3; PRODUCT_BUNDLE_IDENTIFIER = com.decred.dcrios.mainnet; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1625,7 +1625,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.3; PRODUCT_BUNDLE_IDENTIFIER = com.decred.dcrios.mainnet; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Decred Wallet/Features/App Launch/StartScreenViewController.swift b/Decred Wallet/Features/App Launch/StartScreenViewController.swift index 8aec334b6..d2f3c761e 100644 --- a/Decred Wallet/Features/App Launch/StartScreenViewController.swift +++ b/Decred Wallet/Features/App Launch/StartScreenViewController.swift @@ -29,6 +29,14 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { var startTimerWhenViewAppears = true var animationDurationSeconds: Double = 4.7 + let ONE_GB_VALUE: UInt64 = 1073741824 + var numberOfRam: Int { + return Int(ProcessInfo.processInfo.physicalMemory/(ONE_GB_VALUE)) + } + let appDataDir = NSHomeDirectory() + "/Documents/dcrlibwallet" + + var upgradedDB = false + override func viewDidLoad() { super.viewDidLoad() @@ -151,7 +159,8 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { let wallet = try WalletLoader.shared.multiWallet.createNewWallet(LocalizedStrings.myWallet, privatePassphrase: pinOrPassword, privatePassphraseType: type.type) Utils.renameDefaultAccountToLocalLanguage(wallet: wallet) - + UserDefaults.standard.set(true, forKey: "V1.5.3_DB") + UserDefaults.standard.synchronize() DispatchQueue.main.async { completion?.dismissDialog() NavigationMenuTabBarController.setupMenuAndLaunchApp(isNewWallet: true) @@ -178,7 +187,7 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { } if WalletLoader.shared.oneOrMoreWalletsExist { - self.checkStartupSecurityAndStartApp() + self.checkDBfile() } else if SingleToMultiWalletMigration.migrationNeeded { SingleToMultiWalletMigration.migrateExistingWallet() } else { @@ -236,6 +245,44 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { } } + func clearAppDir() { + do { + let filemgr = FileManager.default + try filemgr.removeItem(atPath: appDataDir) + self.displayWalletSetupScreen() + self.imageViewContainer.isUserInteractionEnabled = false + } catch let error { + Utils.showBanner(in: self.view, type: .error, text: error.localizedDescription) + print("Error: \(error.localizedDescription)") + } + } + + func checkDBfile() { + let isNewDB = UserDefaults.standard.bool(forKey: "V1.5.3_DB") + if numberOfRam < 4 && !isNewDB { + self.showRemoveWalletWarning { (ok) in + guard ok else { + self.checkStartupSecurityAndStartApp() + return + } + self.clearAppDir() + } + return + } else { + self.checkStartupSecurityAndStartApp() + } + } + + func showRemoveWalletWarning(callback: @escaping (Bool) -> Void) { + let message = LocalizedStrings.dataFileErrorMsg + SimpleOkCancelDialog.show(sender: self, + title: LocalizedStrings.dataFileErrorTitle, + message: message, + cancelButtonText: LocalizedStrings.no, + okButtonText: LocalizedStrings.yes, + callback: callback) + } + func displayWalletSetupScreen() { // update splash screen location UIView.animate(withDuration: 0, diff --git a/Decred Wallet/Features/Wallet Setup/RestoreExistingWalletViewController.swift b/Decred Wallet/Features/Wallet Setup/RestoreExistingWalletViewController.swift index f115cd1dc..f164e5b84 100644 --- a/Decred Wallet/Features/Wallet Setup/RestoreExistingWalletViewController.swift +++ b/Decred Wallet/Features/Wallet Setup/RestoreExistingWalletViewController.swift @@ -122,6 +122,8 @@ class RestoreExistingWalletViewController: UIViewController { let wallet = try WalletLoader.shared.multiWallet.restore(self.walletName, seedMnemonic: seed, privatePassphrase: pinOrPassword, privatePassphraseType: type.type) Utils.renameDefaultAccountToLocalLanguage(wallet: wallet) + UserDefaults.standard.set(true, forKey: "V1.5.3_DB") + UserDefaults.standard.synchronize() DispatchQueue.main.async { completion?.dismissDialog() diff --git a/Decred Wallet/Utils/LocalizedStrings.swift b/Decred Wallet/Utils/LocalizedStrings.swift index f057c8441..8cd861ec5 100644 --- a/Decred Wallet/Utils/LocalizedStrings.swift +++ b/Decred Wallet/Utils/LocalizedStrings.swift @@ -20,6 +20,10 @@ struct LocalizedStrings { static let myWallet = NSLocalizedString("myWallet", comment: "") static let default_ = NSLocalizedString("default_", comment: "") static let migratingWallet = NSLocalizedString("migratingWallet", comment: "") + static let dataFileErrorMsg = NSLocalizedString("dataFileErrorMsg", comment: "") + static let yes = NSLocalizedString("yes", comment: "") + static let no = NSLocalizedString("no", comment: "") + static let dataFileErrorTitle = NSLocalizedString("dataFileErrorTitle", comment: "") /* Create New Wallet(Seed display view) */ static let settingUpYourWallet = NSLocalizedString("settingUpYourWallet", comment: "") diff --git a/Decred Wallet/Wallet Utils/WalletLoader.swift b/Decred Wallet/Wallet Utils/WalletLoader.swift index c15ea1860..a49b7dea7 100644 --- a/Decred Wallet/Wallet Utils/WalletLoader.swift +++ b/Decred Wallet/Wallet Utils/WalletLoader.swift @@ -44,7 +44,7 @@ class WalletLoader: NSObject { func initMultiWallet() -> NSError? { var error: NSError? - self.multiWallet = DcrlibwalletNewMultiWallet(WalletLoader.appDataDir, "bdb", BuildConfig.NetType, &error) + self.multiWallet = DcrlibwalletNewMultiWallet(WalletLoader.appDataDir, "badgerdb", BuildConfig.NetType, &error) return error } } diff --git a/Decred Wallet/en.lproj/Localizable.strings b/Decred Wallet/en.lproj/Localizable.strings index cf57d8fe7..64ec56d5b 100644 --- a/Decred Wallet/en.lproj/Localizable.strings +++ b/Decred Wallet/en.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "mywallet"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"dataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "Setting Up Decred Wallet"; diff --git a/Decred Wallet/es.lproj/Localizable.strings b/Decred Wallet/es.lproj/Localizable.strings index d1964f538..d06f45016 100644 --- a/Decred Wallet/es.lproj/Localizable.strings +++ b/Decred Wallet/es.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "mywallet"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "Configurando Cartera Decred"; diff --git a/Decred Wallet/pl.lproj/Localizable.strings b/Decred Wallet/pl.lproj/Localizable.strings index 8eeb5e707..164b77ad0 100644 --- a/Decred Wallet/pl.lproj/Localizable.strings +++ b/Decred Wallet/pl.lproj/Localizable.strings @@ -17,7 +17,10 @@ "myWallet" = "mójportfel"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; - +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "Setting Up Decred Wallet"; diff --git a/Decred Wallet/pt-BR.lproj/Localizable.strings b/Decred Wallet/pt-BR.lproj/Localizable.strings index 36ce6f00d..27b3a591f 100644 --- a/Decred Wallet/pt-BR.lproj/Localizable.strings +++ b/Decred Wallet/pt-BR.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "mywallet"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "Preparando Carteira Decred"; diff --git a/Decred Wallet/ru-RU.lproj/Localizable.strings b/Decred Wallet/ru-RU.lproj/Localizable.strings index f42530fc4..feee759c0 100644 --- a/Decred Wallet/ru-RU.lproj/Localizable.strings +++ b/Decred Wallet/ru-RU.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "mywallet"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "НАСТРОЙКА КОШЕЛЬКА DECRED"; diff --git a/Decred Wallet/vi.lproj/Localizable.strings b/Decred Wallet/vi.lproj/Localizable.strings index 54974d3b0..c112d4108 100644 --- a/Decred Wallet/vi.lproj/Localizable.strings +++ b/Decred Wallet/vi.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "mywallet"; "default_" = "default"; "migratingWallet" = "Migrating wallet"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "Thiết lập Ví Decred"; diff --git a/Decred Wallet/zh-Hans.lproj/Localizable.strings b/Decred Wallet/zh-Hans.lproj/Localizable.strings index 615293f85..85e5fbcd5 100644 --- a/Decred Wallet/zh-Hans.lproj/Localizable.strings +++ b/Decred Wallet/zh-Hans.lproj/Localizable.strings @@ -17,6 +17,10 @@ "myWallet" = "我的钱包"; "default_" = "默认"; "migratingWallet" = "转移钱包"; +"dataFileErrorMsg" = "We have detected a problem with your data files from an older version. To fix it, you will need to re-enter your wallet seed phrase. Can you do this now?"; +"yes" = "Yes"; +"no" = "No"; +"DataFileErrorTitle" = "Data file error"; /* Create New Wallet(Seed display view) */ "settingUpYourWallet" = "设置Decred钱包"; diff --git a/Podfile.lock b/Podfile.lock index bed2b1268..b97e93c58 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -17,4 +17,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 64169a56707a1ecbb7c4d47f0d73f353f9e24ba6 -COCOAPODS: 1.9.1 +COCOAPODS: 1.9.3