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.
This commit is contained in:
Claude
2026-01-18 17:57:49 +00:00
parent b41dc65aeb
commit 746e9eb83a

View File

@@ -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");