fix: address code review — NWC key cleanup, CancellationException rethrow

- removeAccountFromStorage now deletes nwc_<npub> keychain entry
  (fixes orphaned wallet key on account removal)
- Rethrow CancellationException in loadSavedAccount and loginWithKey
  catch blocks (fixes broken structured cancellation)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
nrobi144
2026-05-15 11:33:16 +03:00
parent 46caa4d795
commit 325a1f6f6d
@@ -257,6 +257,8 @@ class AccountManager internal constructor(
is SignerType.Remote -> loadBunkerAccount((info.signerType as SignerType.Remote).bunkerUri, activeNpub)
is SignerType.ViewOnly -> loadReadOnlyAccount(activeNpub)
}
} catch (e: kotlin.coroutines.cancellation.CancellationException) {
throw e
} catch (e: Exception) {
Result.failure(e)
}
@@ -723,6 +725,10 @@ class AccountManager internal constructor(
secureStorage.deletePrivateKey(bunkerEphemeralKeyAlias(npub))
} catch (_: SecureStorageException) {
}
try {
secureStorage.deletePrivateKey(nwcKeyAlias(npub))
} catch (_: SecureStorageException) {
}
refreshAccountList()
@@ -819,6 +825,8 @@ class AccountManager internal constructor(
_nwcConnection.value = parsed
Result.success(parsed)
} catch (e: kotlin.coroutines.cancellation.CancellationException) {
throw e
} catch (e: Exception) {
Result.failure(e)
}