From 1701cce6b0b81475f238af6588f91a5185896f22 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Mon, 13 Oct 2025 12:46:17 -0700 Subject: [PATCH] add lightning address and qr modal --- src/components/CashuWallet.tsx | 59 ++++++++++++++++++++++++++++++++++ src/components/ui/qr-modal.tsx | 4 ++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/components/CashuWallet.tsx b/src/components/CashuWallet.tsx index 2a5e212..9525481 100644 --- a/src/components/CashuWallet.tsx +++ b/src/components/CashuWallet.tsx @@ -1,8 +1,10 @@ import { useState, useEffect, useCallback, useRef } from 'react'; +import { nip19 } from 'nostr-tools'; import { useCashu, type HistoryEntry } from '@/hooks/useCashu'; import { useCashuMints } from '@/hooks/cashu/useCashuMints'; import { useLightningAddress } from '@/hooks/useLightningAddress'; import { useNpubCash } from '@/hooks/useNpubCash'; +import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useToast } from '@/hooks/useToast'; import { useQRCode } from '@/hooks/useQRCode'; import { useCopyToClipboard } from '@/hooks/useCopyToClipboard'; @@ -15,6 +17,8 @@ import { TransactionHistory } from '@/components/wallet/TransactionHistory'; import { ProofBreakdownModal } from '@/components/wallet/ProofBreakdownModal'; import { RemoveMintModal } from '@/components/wallet/RemoveMintModal'; import { LoginArea } from '@/components/auth/LoginArea'; +import { Button } from '@/components/ui/button'; +import { QrCode, Copy, Check } from 'lucide-react'; export function CashuWallet() { // ============================================================================ @@ -47,6 +51,8 @@ export function CashuWallet() { const { getCleanMintLabel } = useCashuMints(null); const { setMint: setNpubCashMint, isLoggedIn: isNpubCashLoggedIn } = useNpubCash(); + + const { user } = useCurrentUser(); const { getInvoice: getLightningInvoice, isLoading: isResolvingAddress } = useLightningAddress(); @@ -98,6 +104,9 @@ export function CashuWallet() { const [showLightningQR, setShowLightningQR] = useState(false); const [lightningQRCode, setLightningQRCode] = useState(''); + const [showLightningAddressQR, setShowLightningAddressQR] = useState(false); + const [lightningAddressQRCode, setLightningAddressQRCode] = useState(''); + const [lightningAddressCopied, setLightningAddressCopied] = useState(false); const [showInvoiceModal, setShowInvoiceModal] = useState(false); const [currentInvoice, setCurrentInvoice] = useState<{ @@ -666,6 +675,46 @@ export function CashuWallet() { getCleanMintLabel={getCleanMintLabel} /> + {/* ======================================================================== + SECTION: Lightning Address + ======================================================================== */} + {user?.pubkey && ( +
+ + +
+ )} {/* ======================================================================== SECTION: Receive & Send Cards @@ -747,6 +796,16 @@ export function CashuWallet() { icon="qr" /> + setShowLightningAddressQR(false)} + title="Lightning Address" + description="Scan this QR code to send payments to your Lightning address" + qrCodeUrl={lightningAddressQRCode} + content={user?.pubkey ? `${nip19.npubEncode(user.pubkey)}@npub.cash` : ''} + icon="zap" + /> + {currentInvoice && ( - {content.length > 20 ? `${content.substring(0, 20)}...` : content} + {content.length > 33 + ? `${content.substring(0, 15)}...${content.substring(content.length - 15)}` + : content}
{copied ? (