Add zaps: NWC wallet connect + NIP-57 zap flow

- NWC client (nwc.ts): parse URI, encrypt/send kind 23194, await kind 23195 response
- Lightning store: persist NWC URI to localStorage, zap() via NDKZapper + lnPay callback
- ZapModal: amount presets (21/100/500/1000/5000 sats), custom amount, optional comment,
  paying/success/error states, prompts to Settings if no wallet connected
-  zap button on NoteCard (action row) and ProfileView (header, next to follow)
- Settings > Lightning Wallet section: paste NWC URI, connect/disconnect

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jure
2026-03-09 17:45:39 +01:00
parent b324db6bac
commit 8fcabac450
6 changed files with 458 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import { useUIStore } from "../../stores/ui";
import { timeAgo, shortenPubkey } from "../../lib/utils";
import { publishReaction, publishReply } from "../../lib/nostr";
import { NoteContent } from "./NoteContent";
import { ZapModal } from "../zap/ZapModal";
interface NoteCardProps {
event: NDKEvent;
@@ -35,6 +36,7 @@ export function NoteCard({ event }: NoteCardProps) {
const [replyError, setReplyError] = useState<string | null>(null);
const [replySent, setReplySent] = useState(false);
const replyRef = useRef<HTMLTextAreaElement>(null);
const [showZap, setShowZap] = useState(false);
const handleLike = async () => {
if (!loggedIn || liked || liking) return;
@@ -139,9 +141,23 @@ export function NoteCard({ event }: NoteCardProps) {
>
{liked ? "♥" : "♡"}{reactionCount !== null && reactionCount > 0 ? ` ${reactionCount}` : liked ? " liked" : " like"}
</button>
<button
onClick={() => setShowZap(true)}
className="text-[11px] text-text-dim hover:text-zap transition-colors"
>
zap
</button>
</div>
)}
{showZap && (
<ZapModal
target={{ type: "note", event, recipientPubkey: event.pubkey }}
recipientName={name}
onClose={() => setShowZap(false)}
/>
)}
{/* Inline reply box */}
{showReply && (
<div className="mt-2 border-l-2 border-border pl-3">