Anon zap when logged out

This commit is contained in:
2023-07-06 00:12:56 +01:00
parent 7971f7154a
commit ae4815de46
6 changed files with 40 additions and 41 deletions

View File

@ -3,6 +3,9 @@ import * as Dialog from "@radix-ui/react-dialog";
import { useEffect, useState, type ReactNode } from "react";
import { LNURL } from "@snort/shared";
import { NostrEvent, EventPublisher } from "@snort/system";
import { secp256k1 } from "@noble/curves/secp256k1";
import { bytesToHex } from "@noble/curves/abstract/utils";
import { formatSats } from "../number";
import { Icon } from "./icon";
import AsyncButton from "./async-button";
@ -69,8 +72,12 @@ export function SendZaps({
async function send() {
if (!svc) return;
const pub = await EventPublisher.nip7();
if (!pub) return;
let pub = await EventPublisher.nip7();
let isAnon = false;
if (!pub) {
pub = EventPublisher.privateKey(bytesToHex(secp256k1.utils.randomPrivateKey()));
isAnon = true;
}
const amountInSats = isFiat ? Math.floor((amount / UsdRate) * 1e8) : amount;
let zap: NostrEvent | undefined;
@ -88,6 +95,9 @@ export function SendZaps({
if (eTag) {
eb.tag(["e", eTag]);
}
if (isAnon) {
eb.tag(["anon", ""]);
}
return eb;
}
);