From 746e9eb83ab4d5eab7cbcbd05670dbe573b65d6a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Jan 2026 17:57:49 +0000 Subject: [PATCH] fix: prevent wallet from auto-reconnecting after disconnect The bug was in the useWallet hook which automatically restores the wallet if nwcConnection exists in state but the wallet instance is null. When disconnecting, it only cleared the wallet instance but left nwcConnection in state, causing an immediate reconnection. Fix: - Call disconnectNWCFromState() to clear nwcConnection from Grimoire state - Then call disconnect() to clear the wallet service - This prevents the auto-restore logic from triggering Now when you disconnect the wallet, it stays disconnected until you manually reconnect. --- src/components/WalletViewer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/WalletViewer.tsx b/src/components/WalletViewer.tsx index 393417a..8e73a60 100644 --- a/src/components/WalletViewer.tsx +++ b/src/components/WalletViewer.tsx @@ -185,7 +185,7 @@ function parseInvoice(invoice: string): InvoiceDetails | null { } export default function WalletViewer() { - const { state } = useGrimoire(); + const { state, disconnectNWC: disconnectNWCFromState } = useGrimoire(); const { wallet, balance, @@ -616,6 +616,9 @@ export default function WalletViewer() { } function handleDisconnect() { + // Clear NWC connection from Grimoire state first + disconnectNWCFromState(); + // Then clear the wallet service disconnect(); setDisconnectDialogOpen(false); toast.success("Wallet disconnected");