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 + +