refactor: no node behind a recovery phrase (wallet removal, Phase 6)
PhraseKeys derives a phrase's nostr key (NIP-06, m/44'/1237'/0'/0/0) and its profile id (hash160 of m/50'/0', the old node key) with bitcoin-kmp's DeterministicWallet. ForkCompatibilityTest's Phase 0 pins pass unchanged through it, so the same phrase is the same person with the same preference files. No profile starts a node: Identity.business, startupNode and its state machine, the platform start/schedule/stop actuals, LightningApplication, BusinessManager.initialize, the NFC hooks and POST_NOTIFICATIONS go. A switch is clearing the identity and nothing else. Copy that promised funds or a wallet is reworded, and the switcher's badge says Recovery phrase. Forgetting a phrase profile is still refused (now PhraseAttached): the phrase would derive the key again, and offering it is new UI. iosMain was edited without an iOS build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9c2cbf0295
commit
84be1c5beb
40 files changed
+255
-618
No files matched your search
@@ -4,8 +4,6 @@
|
||||
<!-- To connect with relays -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<application
|
||||
android:name=".GizaApplication"
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -6,15 +6,13 @@ import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import fr.acinq.phoenix.PhoenixGlobal
|
||||
import fr.acinq.phoenix.android.BusinessManager
|
||||
import fr.acinq.phoenix.android.LightningApplication
|
||||
import fr.acinq.phoenix.utils.PlatformContext
|
||||
import fr.acinq.phoenix.utils.preferences.GlobalPrefs
|
||||
|
||||
/** This datastore persists preferences across node ids. */
|
||||
val Context.globalPrefs: DataStore<Preferences> by preferencesDataStore(name = "globalprefs")
|
||||
|
||||
class GizaApplication: Application(), LightningApplication {
|
||||
class GizaApplication: Application() {
|
||||
private lateinit var globalPrefs: GlobalPrefs
|
||||
private lateinit var phoenixGlobal: PhoenixGlobal
|
||||
|
||||
@@ -23,15 +21,13 @@ class GizaApplication: Application(), LightningApplication {
|
||||
|
||||
phoenixGlobal = PhoenixGlobal(PlatformContext(applicationContext))
|
||||
globalPrefs = GlobalPrefs(applicationContext.globalPrefs)
|
||||
BusinessManager.initialize(this)
|
||||
|
||||
}
|
||||
|
||||
override fun getGlobalPrefs(): GlobalPrefs {
|
||||
fun getGlobalPrefs(): GlobalPrefs {
|
||||
return globalPrefs
|
||||
}
|
||||
|
||||
override fun getPhoenixGlobal(): PhoenixGlobal {
|
||||
fun getPhoenixGlobal(): PhoenixGlobal {
|
||||
return phoenixGlobal
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,16 @@
|
||||
package mobi.giza.android
|
||||
|
||||
import android.content.Intent
|
||||
import android.nfc.NfcAdapter
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import fr.acinq.phoenix.NFCActivity
|
||||
import mobi.giza.compose.PlatformContext
|
||||
import mobi.giza.compose.GizaApp
|
||||
import mobi.giza.compose.GizaGlobal
|
||||
import fr.acinq.phoenix.PhoenixGlobal
|
||||
import fr.acinq.phoenix.android.services.HceService
|
||||
|
||||
class MainActivity : ComponentActivity(), NFCActivity {
|
||||
|
||||
private var nfcAdapter: NfcAdapter? = null
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
@@ -41,17 +35,4 @@ class MainActivity : ComponentActivity(), NFCActivity {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun stopHceService() {
|
||||
stopService(Intent(this@MainActivity, HceService::class.java))
|
||||
}
|
||||
|
||||
override fun stopNfcReader() {
|
||||
if (com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.isReading()) {
|
||||
com.machankura.compose.ui.composable.widgets.nfc.NfcStateRepository.updateState(
|
||||
com.machankura.compose.ui.composable.widgets.nfc.NfcState.Inactive)
|
||||
}
|
||||
nfcAdapter?.disableReaderMode(this@MainActivity)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,9 @@ package mobi.giza.compose.extensions
|
||||
|
||||
import mobi.giza.android.GizaApplication
|
||||
import fr.acinq.phoenix.PhoenixGlobal
|
||||
import fr.acinq.phoenix.android.BusinessManager
|
||||
import fr.acinq.phoenix.android.services.ChannelsWatcher
|
||||
import fr.acinq.phoenix.android.services.ContactsPhotoCleaner
|
||||
import fr.acinq.phoenix.data.StartBusinessResult
|
||||
import fr.acinq.phoenix.utils.preferences.GlobalPrefs
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
actual suspend fun platformStartupLogic(words: List<String>): StartBusinessResult {
|
||||
return withContext(Dispatchers.Default) {
|
||||
BusinessManager.startNewBusiness(words, isHeadless = false)
|
||||
}
|
||||
}
|
||||
|
||||
actual fun schedulePlatformLogic(phoenixGlobal: PhoenixGlobal) {
|
||||
ChannelsWatcher.schedule(phoenixGlobal.ctx.applicationContext)
|
||||
ContactsPhotoCleaner.schedule(phoenixGlobal.ctx.applicationContext)
|
||||
}
|
||||
actual fun getShowIntroFlow(phoenixGlobal: PhoenixGlobal): Flow<Boolean> {
|
||||
val machankuraApplication = phoenixGlobal.ctx.applicationContext as GizaApplication
|
||||
return machankuraApplication.getGlobalPrefs().getShowIntro
|
||||
|
||||
-7
@@ -2,20 +2,13 @@ package mobi.giza.compose.ui.view.model
|
||||
|
||||
import mobi.giza.android.GizaApplication
|
||||
import fr.acinq.phoenix.PhoenixGlobal
|
||||
import fr.acinq.phoenix.android.BusinessManager
|
||||
import fr.acinq.phoenix.data.DecryptSeedResult
|
||||
import fr.acinq.phoenix.data.WalletId
|
||||
import fr.acinq.phoenix.managers.SeedManager
|
||||
import fr.acinq.phoenix.utils.preferences.UserWalletMetadata
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
actual fun updateBusinessActiveInUI(walletId: WalletId) {
|
||||
BusinessManager.updateBusinessActiveInUI(walletId)
|
||||
}
|
||||
|
||||
actual fun stopPlatformBusiness(walletId: WalletId) {
|
||||
BusinessManager.stopBusiness(walletId)
|
||||
}
|
||||
|
||||
actual fun loadAndDecryptSeed(phoenixGlobal: PhoenixGlobal): DecryptSeedResult {
|
||||
return SeedManager.loadAndDecrypt(
|
||||
|
||||
Reference in new issue
Block a user