Skip to content

Commit

Permalink
(android) Use new language parameter for mnemonics
Browse files Browse the repository at this point in the history
Always use English for now. See #233 for details.
  • Loading branch information
dpad85 committed Apr 3, 2024
1 parent 1f8d4b2 commit c93cd9a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import fr.acinq.phoenix.android.security.SeedManager
import fr.acinq.phoenix.android.utils.logger
import fr.acinq.phoenix.controllers.init.Initialization
import fr.acinq.phoenix.legacy.utils.LegacyPrefsDatastore
import fr.acinq.phoenix.utils.MnemonicLanguage


@Composable
Expand Down Expand Up @@ -72,7 +73,7 @@ fun CreateWalletView(
val entropy = remember { Lightning.randomBytes(16) }
LaunchedEffect(key1 = entropy) {
log.debug("generating new wallet...")
postIntent(Initialization.Intent.GenerateWallet(entropy))
postIntent(Initialization.Intent.GenerateWallet(entropy, MnemonicLanguage.English))
}
}
is Initialization.Model.GeneratedWallet -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import fr.acinq.phoenix.android.security.SeedManager
import fr.acinq.phoenix.android.utils.logger
import fr.acinq.phoenix.android.utils.negativeColor
import fr.acinq.phoenix.controllers.init.RestoreWallet
import fr.acinq.phoenix.utils.MnemonicLanguage

sealed class RestoreWalletViewState {
object Disclaimer : RestoreWalletViewState()
Expand Down Expand Up @@ -195,7 +196,7 @@ private fun SeedInputView(
WordInputView(
wordIndex = enteredWords.size + 1,
filteredWords = filteredWords,
onInputChange = { postIntent(RestoreWallet.Intent.FilterWordList(it)) },
onInputChange = { postIntent(RestoreWallet.Intent.FilterWordList(it, MnemonicLanguage.English)) },
onWordSelected = { vm.appendWordToMnemonic(it) },
)
}
Expand Down Expand Up @@ -246,7 +247,7 @@ private fun SeedInputView(
icon = R.drawable.ic_check_circle,
onClick = {
focusManager.clearFocus()
postIntent(RestoreWallet.Intent.Validate(vm.mnemonics.filterNotNull()))
postIntent(RestoreWallet.Intent.Validate(vm.mnemonics.filterNotNull(), MnemonicLanguage.English))
},
enabled = isSeedValid == true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import fr.acinq.phoenix.legacy.utils.LegacyAppStatus
import fr.acinq.phoenix.legacy.utils.LegacyPrefsDatastore
import fr.acinq.phoenix.managers.AppConnectionsDaemon
import fr.acinq.phoenix.managers.NotificationsManager
import fr.acinq.phoenix.utils.MnemonicLanguage
import fr.acinq.phoenix.utils.PlatformContext
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
Expand Down Expand Up @@ -70,7 +71,7 @@ class ChannelsWatcher(context: Context, workerParams: WorkerParameters) : Corout
notificationsManager = business.notificationsManager
when (val encryptedSeed = SeedManager.loadSeedFromDisk(applicationContext)) {
is EncryptedSeed.V2.NoAuth -> {
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(encryptedSeed.decrypt()))
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(encryptedSeed.decrypt()), wordList = MnemonicLanguage.English.wordlist())
business.walletManager.loadWallet(seed)

val isTorEnabled = UserPrefs.getIsTorEnabled(applicationContext).first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import fr.acinq.phoenix.legacy.utils.LegacyAppStatus
import fr.acinq.phoenix.legacy.utils.LegacyPrefsDatastore
import fr.acinq.phoenix.managers.AppConfigurationManager
import fr.acinq.phoenix.managers.AppConnectionsDaemon
import fr.acinq.phoenix.utils.MnemonicLanguage
import fr.acinq.phoenix.utils.PlatformContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -226,7 +227,7 @@ class InflightPaymentsWatcher(context: Context, workerParams: WorkerParameters)
val preferredFiatCurrency = UserPrefs.getFiatCurrency(applicationContext).first()

// preparing business
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(mnemonics))
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(mnemonics), wordList = MnemonicLanguage.English.wordlist())
business.walletManager.loadWallet(seed)
business.appConfigurationManager.updateElectrumConfig(electrumServer)
business.appConfigurationManager.updatePreferredFiatCurrencies(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import fr.acinq.phoenix.managers.AppConfigurationManager
import fr.acinq.phoenix.managers.CurrencyManager
import fr.acinq.phoenix.managers.NodeParamsManager
import fr.acinq.phoenix.managers.PeerManager
import fr.acinq.phoenix.utils.MnemonicLanguage
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -259,7 +260,7 @@ class NodeService : Service() {
monitorInFlightPaymentsJob = serviceScope.launch { monitorInFlightPayments(business.peerManager) }

// preparing business
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(decryptedMnemonics))
val seed = business.walletManager.mnemonicsToSeed(EncryptedSeed.toMnemonics(decryptedMnemonics), wordList = MnemonicLanguage.English.wordlist())
business.walletManager.loadWallet(seed)
business.appConfigurationManager.updateElectrumConfig(electrumServer)
business.appConfigurationManager.updatePreferredFiatCurrencies(
Expand Down

0 comments on commit c93cd9a

Please sign in to comment.