put lightning address in balance card

This commit is contained in:
lemonknowsall committed 2025-10-13 16:27:15 -07:00
1 parent c8ad3b1a36
commit dd3f4465c5
2 files changed
+57 -46

No files matched your search

+8 -45
View File
@@ -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<string>('');
const [showLightningAddressQR, setShowLightningAddressQR] = useState(false);
const [lightningAddressQRCode, setLightningAddressQRCode] = useState<string>('');
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(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 (
<div className="mb-4 flex items-center justify-center gap-2">
<button
onClick={async () => {
await copyToClipboard(lightningAddress);
setLightningAddressCopied(true);
setTimeout(() => setLightningAddressCopied(false), 2000);
}}
className="flex items-center gap-2 px-3 py-1.5 bg-muted hover:bg-muted/80 rounded-md border text-sm font-mono transition-colors h-[34px]"
title="Click to copy Lightning address"
>
<span className="truncate max-w-[250px] sm:max-w-none">
{lightningAddress}
</span>
{lightningAddressCopied ? (
<Check className="h-4 w-4 text-green-600 flex-shrink-0" />
) : (
<Copy className="h-4 w-4 text-muted-foreground flex-shrink-0" />
)}
</button>
<button
onClick={async () => {
const qr = await generateQRCode(lightningAddress);
setLightningAddressQRCode(qr);
setShowLightningAddressQR(true);
}}
className="flex items-center justify-center px-2 py-1.5 hover:bg-muted rounded-md transition-colors h-[34px]"
title="Show QR Code"
>
<QrCode className="h-4 w-4" />
</button>
</div>
);
})()}
{/* ========================================================================
SECTION: Receive & Send Cards
======================================================================== */}
+49 -1
View File
@@ -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<void>;
onShowLightningAddressQR: (qrCode: string) => void;
generateQRCode: (text: string) => Promise<string>;
}
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 (
<div className="text-center py-2">
@@ -187,6 +200,41 @@ export function BalanceDisplay({
)}
</div>
{/* Lightning Address */}
{userPubkey && (
<div className="mt-3 flex items-center justify-center gap-2">
<button
onClick={async () => {
const lightningAddress = `${npubCashUsername}@npubx.cash`;
await onCopyToClipboard(lightningAddress);
setLightningAddressCopied(true);
setTimeout(() => setLightningAddressCopied(false), 2000);
}}
className="flex items-center gap-2 px-3 py-1.5 bg-muted hover:bg-muted/80 rounded-md border text-sm font-mono transition-colors h-[34px]"
title="Click to copy Lightning address"
>
<span className="truncate max-w-[250px] sm:max-w-none">
{npubCashUsername}@npubx.cash
</span>
{lightningAddressCopied ? (
<Check className="h-4 w-4 text-green-600 flex-shrink-0" />
) : (
<Copy className="h-4 w-4 text-muted-foreground flex-shrink-0" />
)}
</button>
<button
onClick={async () => {
const lightningAddress = `${npubCashUsername}@npubx.cash`;
const qr = await generateQRCode(lightningAddress);
onShowLightningAddressQR(qr);
}}
className="flex items-center justify-center px-2 py-1.5 hover:bg-muted rounded-md transition-colors h-[34px]"
title="Show QR Code"
>
<QrCode className="h-4 w-4" />
</button>
</div>
)}
</div>
);
}