From dd3f4465c5dfeec216536a3e9cb0423c648c42df Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Mon, 13 Oct 2025 16:27:15 -0700 Subject: [PATCH] put lightning address in balance card --- src/components/CashuWallet.tsx | 53 ++++-------------------- src/components/wallet/BalanceDisplay.tsx | 50 +++++++++++++++++++++- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/components/CashuWallet.tsx b/src/components/CashuWallet.tsx index 5ff2fcd..d6bd0a4 100644 --- a/src/components/CashuWallet.tsx +++ b/src/components/CashuWallet.tsx @@ -17,7 +17,6 @@ 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 { QrCode, Copy, Check } from 'lucide-react'; export function CashuWallet() { // ============================================================================ @@ -105,7 +104,6 @@ export function CashuWallet() { const [lightningQRCode, setLightningQRCode] = useState(''); const [showLightningAddressQR, setShowLightningAddressQR] = useState(false); const [lightningAddressQRCode, setLightningAddressQRCode] = useState(''); - const [lightningAddressCopied, setLightningAddressCopied] = useState(false); const [npubCashUserInfo, setNpubCashUserInfo] = useState(null); const [showInvoiceModal, setShowInvoiceModal] = useState(false); @@ -731,51 +729,16 @@ export function CashuWallet() { onRemoveMint={handleRemoveMintClick} onShowDenominations={handleShowDenominations} getCleanMintLabel={getCleanMintLabel} + userPubkey={user?.pubkey} + npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined} + onCopyToClipboard={copyToClipboard} + onShowLightningAddressQR={(qr) => { + setLightningAddressQRCode(qr); + setShowLightningAddressQR(true); + }} + generateQRCode={generateQRCode} /> - {/* ======================================================================== - SECTION: Lightning Address - ======================================================================== */} - {user?.pubkey && (() => { - // Use username if available, otherwise use npub - const identifier = npubCashUserInfo?.name || nip19.npubEncode(user.pubkey); - const lightningAddress = `${identifier}@npubx.cash`; - - return ( -
- - -
- ); - })()} - {/* ======================================================================== SECTION: Receive & Send Cards ======================================================================== */} diff --git a/src/components/wallet/BalanceDisplay.tsx b/src/components/wallet/BalanceDisplay.tsx index 10799e2..b64adaa 100644 --- a/src/components/wallet/BalanceDisplay.tsx +++ b/src/components/wallet/BalanceDisplay.tsx @@ -2,8 +2,9 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Wallet, ChevronDown, Plus, X, Zap, Coins, HelpCircle } from 'lucide-react'; +import { Wallet, ChevronDown, Plus, X, Zap, Coins, HelpCircle, QrCode, Copy, Check } from 'lucide-react'; import { useCashuBalances } from '@/hooks/cashu/useCashuBalances'; +import { useState } from 'react'; interface CashuMint { url: string; @@ -26,6 +27,12 @@ interface BalanceDisplayProps { onRemoveMint: (mint: CashuMint) => void; onShowDenominations: (mintUrl: string) => void; getCleanMintLabel: (mint: { name?: string; url: string }) => string; + // Lightning address props + userPubkey?: string; + npubCashUsername?: string; + onCopyToClipboard: (text: string) => Promise; + onShowLightningAddressQR: (qrCode: string) => void; + generateQRCode: (text: string) => Promise; } export function BalanceDisplay({ @@ -44,8 +51,14 @@ export function BalanceDisplay({ onRemoveMint, onShowDenominations, getCleanMintLabel, + userPubkey, + npubCashUsername, + onCopyToClipboard, + onShowLightningAddressQR, + generateQRCode, }: BalanceDisplayProps) { const { convertCurrency } = useCashuBalances(null); + const [lightningAddressCopied, setLightningAddressCopied] = useState(false); return (
@@ -187,6 +200,41 @@ export function BalanceDisplay({ )}
+ {/* Lightning Address */} + {userPubkey && ( +
+ + +
+ )} ); }