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, QrCode, Copy, Check } from 'lucide-react'; import { useState, useEffect } from 'react'; import { exchangeRateService } from '@/lib/exchangeRateService'; interface CashuMint { url: string; name?: string; } interface BalanceDisplayProps { totalBalance: number; balances: { [key: string]: number }; showSats: boolean; setShowSats: (showSats: boolean) => void; mode: 'tokens' | 'lightning'; setMode: (mode: 'tokens' | 'lightning') => void; activeMintUrl: string | null; setActiveMintUrl: (url: string | null) => void; mints: CashuMint[]; mintUrl: string; setMintUrl: (url: string) => void; onAddMint: () => void; 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({ totalBalance, balances, showSats, setShowSats, mode, setMode, activeMintUrl, setActiveMintUrl, mints, mintUrl, setMintUrl, onAddMint, onRemoveMint, onShowDenominations, getCleanMintLabel, userPubkey, npubCashUsername, onCopyToClipboard, onShowLightningAddressQR, generateQRCode, }: BalanceDisplayProps) { const [lightningAddressCopied, setLightningAddressCopied] = useState(false); const [btcUsdRate, setBtcUsdRate] = useState(null); useEffect(() => { exchangeRateService.getBtcUsdRate() .then(rate => setBtcUsdRate(rate)) .catch(() => setBtcUsdRate(null)); }, []); const convertCurrency = (sats: number, showSats: boolean): string => { if (showSats) { return `${sats.toLocaleString()} sats`; } else if (btcUsdRate) { const btcAmount = sats / 100000000; const usd = btcAmount * btcUsdRate; return `$${usd.toFixed(2)}`; } else { return `${sats.toLocaleString()} sats`; } }; return (
{/* Main Mode Toggle */}
{/* Active Mint Dropdown and Balance */}
{mints.length === 0 && ( No mints connected )} {mints .filter((mint) => mint.url) .map((mint, index) => ( setActiveMintUrl(mint.url)} >
{getCleanMintLabel(mint)}
))}
setMintUrl(e.target.value)} className="h-8" />
{/* Active Mint Balance */} {activeMintUrl && (
{/* Help button */} What is a Mint?

A mint is a server that issues and manages Cashu tokens. Think of it like a bank for digital cash.

Key features:

  • Issues tokens when you deposit Lightning payments
  • Redeems tokens when you receive them
  • Manages your token balance
  • Enables Lightning ↔ Cashu conversions

Note: Each mint maintains its own separate balance. You can add multiple mints to diversify your holdings and swap balances between them.

)}
{/* Lightning Address */} {userPubkey && (
)}
); }