diff --git a/src/components/ZapWindow.tsx b/src/components/ZapWindow.tsx index d3a94a9..b4eb3c4 100644 --- a/src/components/ZapWindow.tsx +++ b/src/components/ZapWindow.tsx @@ -21,10 +21,14 @@ import { Loader2, CheckCircle2, LogIn, + EyeOff, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { Checkbox } from "@/components/ui/checkbox"; +import { PrivateKeySigner } from "applesauce-signers"; +import { generateSecretKey } from "nostr-tools"; import QRCode from "qrcode"; import { useProfile } from "@/hooks/useProfile"; import { use$ } from "applesauce-react/hooks"; @@ -138,6 +142,7 @@ export function ZapWindow({ const [showQrDialog, setShowQrDialog] = useState(false); const [showLogin, setShowLogin] = useState(false); const [paymentTimedOut, setPaymentTimedOut] = useState(false); + const [zapAnonymously, setZapAnonymously] = useState(false); // Editor ref and search functions const editorRef = useRef(null); @@ -356,6 +361,13 @@ export function ZapWindow({ } // Step 3: Create and sign zap request event (kind 9734) + // If zapping anonymously, create a throwaway signer + let anonymousSigner; + if (zapAnonymously) { + const throwawayKey = generateSecretKey(); + anonymousSigner = new PrivateKeySigner(throwawayKey); + } + const zapRequest = await createZapRequest({ recipientPubkey, amountMillisats, @@ -366,6 +378,7 @@ export function ZapWindow({ lnurl: lud16 || undefined, emojiTags, customTags, + signer: anonymousSigner, }); const serializedZapRequest = serializeZapRequest(zapRequest); @@ -657,6 +670,26 @@ export function ZapWindow({ className="rounded-md border border-input bg-background px-3 py-1 text-base md:text-sm min-h-9" /> )} + + {/* Anonymous zap checkbox */} + {hasLightningAddress && ( +
+ + setZapAnonymously(checked === true) + } + /> + +
+ )} {/* No Lightning Address Warning */} @@ -667,7 +700,7 @@ export function ZapWindow({ )} {/* Payment Button */} - {!canSign ? ( + {!canSign && !zapAnonymously ? (