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

@@ -6,6 +6,7 @@ import { useProfile, invalidateProfileCache } from "../../hooks/useProfile";
import { fetchUserNotes, publishProfile } from "../../lib/nostr";
import { shortenPubkey } from "../../lib/utils";
import { NoteCard } from "../feed/NoteCard";
import { ZapModal } from "../zap/ZapModal";
function EditProfileForm({ pubkey, onSaved }: { pubkey: string; onSaved: () => void }) {
const { profile, fetchOwnProfile } = useUserStore();
@@ -108,6 +109,7 @@ export function ProfileView() {
const [loading, setLoading] = useState(true);
const [editing, setEditing] = useState(false);
const [followPending, setFollowPending] = useState(false);
const [showZap, setShowZap] = useState(false);
const isFollowing = follows.includes(pubkey);
@@ -161,17 +163,25 @@ export function ProfileView() {
</button>
)}
{!isOwn && loggedIn && (
<button
onClick={handleFollowToggle}
disabled={followPending}
className={`text-[11px] px-3 py-1 border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${
isFollowing
? "border-border text-text-muted hover:text-danger hover:border-danger/40"
: "border-accent/60 text-accent hover:bg-accent hover:text-white"
}`}
>
{followPending ? "…" : isFollowing ? "unfollow" : "follow"}
</button>
<div className="flex items-center gap-2">
<button
onClick={() => setShowZap(true)}
className="text-[11px] px-3 py-1 border border-border text-zap hover:border-zap/40 hover:bg-zap/5 transition-colors"
>
zap
</button>
<button
onClick={handleFollowToggle}
disabled={followPending}
className={`text-[11px] px-3 py-1 border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${
isFollowing
? "border-border text-text-muted hover:text-danger hover:border-danger/40"
: "border-accent/60 text-accent hover:bg-accent hover:text-white"
}`}
>
{followPending ? "…" : isFollowing ? "unfollow" : "follow"}
</button>
</div>
)}
</header>
@@ -219,6 +229,14 @@ export function ProfileView() {
</div>
)}
{showZap && (
<ZapModal
target={{ type: "profile", pubkey }}
recipientName={name}
onClose={() => setShowZap(false)}
/>
)}
{/* Notes */}
{loading && <div className="px-4 py-8 text-text-dim text-[12px] text-center">Loading notes</div>}
{!loading && notes.length === 0 && <div className="px-4 py-8 text-text-dim text-[12px] text-center">No notes found.</div>}