import { useState } from "react"; import { useLightningStore } from "../../stores/lightning"; import { useUserStore } from "../../stores/user"; import { isValidNwcUri, parseNwcUri } from "../../lib/lightning/nwc"; // ── Wallet catalogue ───────────────────────────────────────────────────────── interface WalletDef { id: string; name: string; tagline: string; setupUrl: string; steps: string[]; detect: (relay: string) => boolean; } const WALLETS: WalletDef[] = [ { id: "alby-hub", name: "Alby Hub", tagline: "Self-hosted · full control", setupUrl: "https://albyhub.com", steps: [ "Open your Alby Hub dashboard", 'Go to Connections → "Add connection"', "Copy the Nostr Wallet Connect URI", "Paste it below", ], detect: (r) => r.includes("albyhub") || (r.includes("getalby") && r.includes("hub")), }, { id: "alby", name: "Alby Extension", tagline: "Browser extension", setupUrl: "https://getalby.com/apps/new", steps: [ "Go to getalby.com/apps/new", "Create a new app connection", "Copy the Nostr Wallet Connect URI", "Paste it below", ], detect: (r) => r.includes("getalby") && !r.includes("albyhub"), }, { id: "mutiny", name: "Mutiny", tagline: "Web-based wallet", setupUrl: "https://app.mutinywallet.com/#/settings/connections", steps: [ "Open Mutiny Wallet", "Go to Settings → Nostr Wallet Connect", "Create a new connection", "Copy the URI and paste it below", ], detect: (r) => r.includes("mutiny"), }, { id: "phoenix", name: "Phoenix", tagline: "Mobile · self-custodial", setupUrl: "https://phoenix.acinq.co", steps: [ "Open Phoenix on your phone", "Go to Settings → Nostr Wallet Connect", "Tap 'Link a new wallet'", "Copy the URI and paste it below", ], detect: (r) => r.includes("phoenix") || r.includes("acinq"), }, ]; const GENERIC: WalletDef = { id: "generic", name: "Other wallet", tagline: "", setupUrl: "", steps: [ "Open your Lightning wallet", "Find the Nostr Wallet Connect section", "Generate a new NWC connection URI", "Paste it below", ], detect: () => true, }; function detectWallet(nwcUri: string): WalletDef { try { const { relayUrl } = parseNwcUri(nwcUri); return WALLETS.find((w) => w.detect(relayUrl)) ?? GENERIC; } catch { return GENERIC; } } // ── Connected state ─────────────────────────────────────────────────────────── function ConnectedState({ nwcUri, onDisconnect }: { nwcUri: string; onDisconnect: () => void }) { const wallet = detectWallet(nwcUri); let relay = ""; try { relay = parseNwcUri(nwcUri).relayUrl; const u = new URL(relay); relay = u.hostname; } catch { /* keep raw */ } return (
Your NWC connection is active. You can zap notes and profiles.
Choose your Lightning wallet to get a Nostr Wallet Connect (NWC) URI.