From 3adc9bdfc33687809e0bf04547bea08835963d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20G=C3=B3mez?= Date: Mon, 19 Jan 2026 13:54:45 +0100 Subject: [PATCH] feat: add invoice description fallback for wallet transactions Add fallback to lightning invoice description when transaction description is not available. Improves transaction list readability by showing invoice descriptions instead of generic "Payment" labels. - Add getInvoiceDescription helper with applesauce caching pattern - Update TransactionLabel to check invoice description - Update detail dialog to show invoice description as fallback - Maintains zap detection logic and UI Co-Authored-By: Claude Sonnet 4.5 --- src/components/WalletViewer.tsx | 45 +++++++++++++++++++-------------- src/lib/wallet-utils.ts | 34 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/components/WalletViewer.tsx b/src/components/WalletViewer.tsx index 23e7e8e..acf0d0f 100644 --- a/src/components/WalletViewer.tsx +++ b/src/components/WalletViewer.tsx @@ -52,7 +52,7 @@ import { } from "@/components/ui/tooltip"; import ConnectWalletDialog from "./ConnectWalletDialog"; import { RelayLink } from "@/components/nostr/RelayLink"; -import { parseZapRequest } from "@/lib/wallet-utils"; +import { parseZapRequest, getInvoiceDescription } from "@/lib/wallet-utils"; import { Zap } from "lucide-react"; import { useNostrEvent } from "@/hooks/useNostrEvent"; import { KindRenderer } from "./nostr/kinds"; @@ -312,14 +312,14 @@ function ZapTransactionDetail({ transaction }: { transaction: Transaction }) { function TransactionLabel({ transaction }: { transaction: Transaction }) { const zapInfo = parseZapRequest(transaction); - // Not a zap - use original description or default label + // Not a zap - use original description, invoice description, or default label if (!zapInfo) { - return ( - - {transaction.description || - (transaction.type === "incoming" ? "Received" : "Payment")} - - ); + const description = + transaction.description || + getInvoiceDescription(transaction) || + (transaction.type === "incoming" ? "Received" : "Payment"); + + return {description}; } // It's a zap! Show username + message on one line @@ -1260,17 +1260,24 @@ export default function WalletViewer() {
- {selectedTransaction.description && - !parseZapRequest(selectedTransaction) && ( -
- -

- {selectedTransaction.description} -

-
- )} + {(() => { + const description = + selectedTransaction.description || + getInvoiceDescription(selectedTransaction); + const isZap = parseZapRequest(selectedTransaction); + + return ( + description && + !isZap && ( +
+ +

{description}

+
+ ) + ); + })()}