@@ -83,7 +83,12 @@ class MigrationService @Inject constructor(
8383 _isShowingMigrationLoading .value = value
8484 }
8585
86- var pendingChannelMigration: PendingChannelMigration ? = null
86+ @Volatile
87+ private var pendingChannelMigration: PendingChannelMigration ? = null
88+
89+ fun consumePendingChannelMigration (): PendingChannelMigration ? {
90+ return pendingChannelMigration.also { pendingChannelMigration = null }
91+ }
8792
8893 private val rnNetworkString: String
8994 get() = when (Env .network) {
@@ -97,7 +102,14 @@ class MigrationService @Inject constructor(
97102 get() = File (context.filesDir, " ldk" )
98103
99104 private val rnLdkAccountPath: File
100- get() = File (rnLdkBasePath, " ${Companion .RN_WALLET_NAME }${rnNetworkString} ldkaccountv3" )
105+ get() {
106+ val accountName = buildString {
107+ append(RN_WALLET_NAME )
108+ append(rnNetworkString)
109+ append(" ldkaccountv3" )
110+ }
111+ return File (rnLdkBasePath, accountName)
112+ }
101113
102114 private val rnMmkvPath: File
103115 get() = File (context.filesDir, " mmkv/mmkv.default" )
@@ -281,7 +293,9 @@ class MigrationService @Inject constructor(
281293 } else {
282294 markMigrationChecked()
283295 setShowingMigrationLoading(false )
284- throw to.bitkit.utils.AppError (" RN keychain data not found" )
296+ throw to.bitkit.utils.AppError (
297+ " Migration data unavailable. Please restore your wallet using your recovery phrase."
298+ )
285299 }
286300 } catch (e: Exception ) {
287301 Logger .error(" RN migration failed: $e " , e, context = TAG )
@@ -300,7 +314,9 @@ class MigrationService @Inject constructor(
300314
301315 val words = mnemonic.split(" " ).filter { it.isNotBlank() }
302316 if (words.size != MNEMONIC_WORD_COUNT_12 && words.size != MNEMONIC_WORD_COUNT_24 ) {
303- throw to.bitkit.utils.AppError (" Invalid mnemonic: ${words.size} words" )
317+ throw to.bitkit.utils.AppError (
318+ " Recovery phrase format is invalid. Please use your 12 or 24 word recovery phrase to restore manually."
319+ )
304320 }
305321
306322 keychain.saveString(Keychain .Key .BIP39_MNEMONIC .name, mnemonic)
@@ -311,9 +327,9 @@ class MigrationService @Inject constructor(
311327 val hasWallet0Alias = keystore.containsAlias(" wallet0" )
312328
313329 return if (hasWallet0Alias) {
314- " RN keychain data not found "
330+ " Migration data unavailable. Please restore your wallet using your recovery phrase. "
315331 } else {
316- " No RN mnemonic found"
332+ " No migration data found. Please restore your wallet using your recovery phrase. "
317333 }
318334 }
319335
0 commit comments