From 325a1f6f6d9f72583ea6ead1a1aa9dfd9d47a319 Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Fri, 15 May 2026 11:33:16 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20NW?= =?UTF-8?q?C=20key=20cleanup,=20CancellationException=20rethrow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - removeAccountFromStorage now deletes nwc_ 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) --- .../amethyst/desktop/account/AccountManager.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt index c8311ea6b..9b580b467 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt @@ -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) }