From 1c8b2406963197aad0d190e689b46429d7ce4474 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Jan 2026 15:22:16 +0000 Subject: [PATCH] feat(wallet): add copy NWC connection string button to header Adds a copy button (Copy/Check icons) in the wallet header before the refresh button that copies the NWC connection string to clipboard for easy sharing or backup. https://claude.ai/code/session_01CnJgjFMvZHZWs2ujAiWAiQ --- src/components/WalletViewer.tsx | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/components/WalletViewer.tsx b/src/components/WalletViewer.tsx index 0393e91..7b5a8c8 100644 --- a/src/components/WalletViewer.tsx +++ b/src/components/WalletViewer.tsx @@ -452,6 +452,9 @@ export default function WalletViewer() { const [showRawTransaction, setShowRawTransaction] = useState(false); const [copiedRawTx, setCopiedRawTx] = useState(false); + // Copy NWC connection string state + const [copiedNwc, setCopiedNwc] = useState(false); + // Reset state when connection changes useEffect(() => { // Detect connection state changes @@ -604,6 +607,24 @@ export default function WalletViewer() { } } + function copyNwcString() { + if (!state.nwcConnection) return; + + const { service, relays, secret, lud16 } = state.nwcConnection; + const params = new URLSearchParams(); + relays.forEach((relay) => params.append("relay", relay)); + params.append("secret", secret); + if (lud16) params.append("lud16", lud16); + + const nwcString = `nostr+walletconnect://${service}?${params.toString()}`; + + navigator.clipboard.writeText(nwcString).then(() => { + setCopiedNwc(true); + toast.success("Connection string copied"); + setTimeout(() => setCopiedNwc(false), 2000); + }); + } + async function handleConfirmSend() { if (!sendInvoice.trim()) { toast.error("Please enter an invoice or Lightning address"); @@ -1091,6 +1112,23 @@ export default function WalletViewer() { )} + + + + + Copy Connection String + +