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:
+8
@@ -257,6 +257,8 @@ class AccountManager internal constructor(
|
|||||||
is SignerType.Remote -> loadBunkerAccount((info.signerType as SignerType.Remote).bunkerUri, activeNpub)
|
is SignerType.Remote -> loadBunkerAccount((info.signerType as SignerType.Remote).bunkerUri, activeNpub)
|
||||||
is SignerType.ViewOnly -> loadReadOnlyAccount(activeNpub)
|
is SignerType.ViewOnly -> loadReadOnlyAccount(activeNpub)
|
||||||
}
|
}
|
||||||
|
} catch (e: kotlin.coroutines.cancellation.CancellationException) {
|
||||||
|
throw e
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
@@ -723,6 +725,10 @@ class AccountManager internal constructor(
|
|||||||
secureStorage.deletePrivateKey(bunkerEphemeralKeyAlias(npub))
|
secureStorage.deletePrivateKey(bunkerEphemeralKeyAlias(npub))
|
||||||
} catch (_: SecureStorageException) {
|
} catch (_: SecureStorageException) {
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
secureStorage.deletePrivateKey(nwcKeyAlias(npub))
|
||||||
|
} catch (_: SecureStorageException) {
|
||||||
|
}
|
||||||
|
|
||||||
refreshAccountList()
|
refreshAccountList()
|
||||||
|
|
||||||
@@ -819,6 +825,8 @@ class AccountManager internal constructor(
|
|||||||
|
|
||||||
_nwcConnection.value = parsed
|
_nwcConnection.value = parsed
|
||||||
Result.success(parsed)
|
Result.success(parsed)
|
||||||
|
} catch (e: kotlin.coroutines.cancellation.CancellationException) {
|
||||||
|
throw e
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user