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.
This commit is contained in:
Kevin Gorham 2020-12-20 10:59:14 -05:00
parent 245a265770
commit 500fa13cbd
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
1 changed files with 3 additions and 1 deletions

View File

@ -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) =