mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-13 08:57:04 +02:00
Implements the foundational structure for sending Lightning zaps (NIP-57) to Nostr users and events. This commit adds the command interface, UI components, and routing logic. The actual LNURL resolution and zap request creation will be implemented in follow-up commits. Components Added: - ZapWindow: Full-featured UI for zapping with amount presets, custom amounts, wallet integration, and QR code fallback - parseZapCommand: Parser supporting multiple formats (npub, nprofile, nevent, naddr, NIP-05, $me alias) - Command registration in man pages with examples - Window routing and title generation Features: - Preset amount buttons (21, 100, 500, 1000, 5000, 10000 sats) - Custom amount input - Amount usage tracking (remembers most-used amounts) - Comment field for zap messages - Event context rendering (shows zapped event in UI) - Dual payment methods: NWC wallet or QR code/invoice copy - Dynamic recipient resolution (from event author if zapping event) Usage: zap fiatjaf.com # Zap a user by NIP-05 zap npub1... # Zap a user by npub zap nevent1... # Zap an event (recipient = author) zap npub1... nevent1... # Zap specific user for specific event Next Steps: - Implement LNURL-pay resolution (fetch callback URL and nostrPubkey) - Create kind 9734 zap request event with applesauce factory - Implement invoice generation via LNURL callback - Integrate NWC wallet payment - Add zap action to event context menus - Implement zap receipt listening (kind 9735)
121 lines
2.4 KiB
TypeScript
121 lines
2.4 KiB
TypeScript
import {
|
|
Book,
|
|
Podcast,
|
|
FileText,
|
|
HelpCircle,
|
|
List,
|
|
BookOpen,
|
|
ExternalLink,
|
|
User,
|
|
Lock,
|
|
Unlock,
|
|
Radio,
|
|
Rss,
|
|
Layout,
|
|
Bug,
|
|
Wifi,
|
|
MessageSquare,
|
|
Hash,
|
|
Zap,
|
|
type LucideIcon,
|
|
} from "lucide-react";
|
|
|
|
/**
|
|
* Icon mapping for all commands/apps
|
|
* Each command has an icon and optional tooltip description
|
|
*/
|
|
export interface CommandIcon {
|
|
icon: LucideIcon;
|
|
description: string;
|
|
}
|
|
|
|
export const COMMAND_ICONS: Record<string, CommandIcon> = {
|
|
// Documentation commands
|
|
nip: {
|
|
icon: Book,
|
|
description: "View Nostr Implementation Possibility specification",
|
|
},
|
|
kind: {
|
|
icon: FileText,
|
|
description: "View information about a Nostr event kind",
|
|
},
|
|
kinds: {
|
|
icon: List,
|
|
description: "Display all supported Nostr event kinds",
|
|
},
|
|
man: {
|
|
icon: BookOpen,
|
|
description: "Display manual page for a command",
|
|
},
|
|
help: {
|
|
icon: HelpCircle,
|
|
description: "Display general help information",
|
|
},
|
|
|
|
// Nostr commands
|
|
req: {
|
|
icon: Podcast,
|
|
description: "Active subscription to Nostr relays with filters",
|
|
},
|
|
count: {
|
|
icon: Hash,
|
|
description: "Count events on relays using NIP-45 COUNT verb",
|
|
},
|
|
open: {
|
|
icon: ExternalLink,
|
|
description: "Open and view a Nostr event",
|
|
},
|
|
profile: {
|
|
icon: User,
|
|
description: "View a Nostr user profile",
|
|
},
|
|
relay: {
|
|
icon: Radio,
|
|
description: "View relay information and statistics",
|
|
},
|
|
feed: {
|
|
icon: Rss,
|
|
description: "View event feed",
|
|
},
|
|
chat: {
|
|
icon: MessageSquare,
|
|
description: "Join and participate in NIP-29 relay-based group chats",
|
|
},
|
|
zap: {
|
|
icon: Zap,
|
|
description: "Send a Lightning zap to a Nostr user or event",
|
|
},
|
|
|
|
// Utility commands
|
|
encode: {
|
|
icon: Lock,
|
|
description: "Encode data to NIP-19 format",
|
|
},
|
|
decode: {
|
|
icon: Unlock,
|
|
description: "Decode NIP-19 encoded identifiers",
|
|
},
|
|
|
|
// System commands
|
|
win: {
|
|
icon: Layout,
|
|
description: "View all open windows",
|
|
},
|
|
debug: {
|
|
icon: Bug,
|
|
description: "Display application state for debugging",
|
|
},
|
|
conn: {
|
|
icon: Wifi,
|
|
description: "View relay pool connection and authentication status",
|
|
},
|
|
};
|
|
|
|
export function getCommandIcon(command: string): LucideIcon {
|
|
return COMMAND_ICONS[command]?.icon || FileText;
|
|
}
|
|
|
|
export function getCommandDescription(command: string): string {
|
|
return COMMAND_ICONS[command]?.description || "";
|
|
}
|