From 500fa13cbdc32b26014cd647551963cb3315cfbd Mon Sep 17 00:00:00 2001 From: Kevin Gorham Date: Sun, 20 Dec 2020 10:59:14 -0500 Subject: [PATCH] Fix: repair the upgrade flow. Existing users of seed-only wallets were getting stuck because the birthday is now stored differently. The previous fix was attempting to just load the latest checkpoint as the birthday but this does not work because the birthday determines how far back the wallet will rewind during a reorg. The end result prevented the wallet from going back as far as it needed. When the birthday isn't known, it makes logical sense to set it to the lowest possible number: Sapling Activation. This also happens to fix the problem because now wallets that are upgrading can rewind beyond the latest checkpoint. --- .../java/cash/z/ecc/android/ui/setup/WalletSetupViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cash/z/ecc/android/ui/setup/WalletSetupViewModel.kt b/app/src/main/java/cash/z/ecc/android/ui/setup/WalletSetupViewModel.kt index f075f3e..66b5710 100644 --- a/app/src/main/java/cash/z/ecc/android/ui/setup/WalletSetupViewModel.kt +++ b/app/src/main/java/cash/z/ecc/android/ui/setup/WalletSetupViewModel.kt @@ -10,6 +10,7 @@ import cash.z.ecc.android.feedback.Report import cash.z.ecc.android.lockbox.LockBox import cash.z.ecc.android.sdk.Initializer import cash.z.ecc.android.sdk.exception.InitializerException +import cash.z.ecc.android.sdk.ext.ZcashSdk import cash.z.ecc.android.sdk.ext.twig import cash.z.ecc.android.sdk.tool.DerivationTool import cash.z.ecc.android.sdk.tool.WalletBirthdayTool @@ -140,7 +141,8 @@ class WalletSetupViewModel @Inject constructor() : ViewModel() { } private fun onMissingBirthday(): Int = failWith(InitializerException.MissingBirthdayException) { - loadNearestBirthday().height + twig("Recover Birthday: falling back to sapling birthday") + loadNearestBirthday(ZcashSdk.SAPLING_ACTIVATION_HEIGHT).height } private fun loadNearestBirthday(birthdayHeight: Int? = null) =