use finishEvent instead of signEvent

This commit is contained in:
hzrd149 2023-06-29 11:49:18 -05:00
parent 4e59a0e586
commit 13d79fec4a

View File

@ -1,7 +1,7 @@
import { DraftNostrEvent, NostrEvent } from "../types/nostr-event";
import { Account } from "./account";
import db from "./db";
import { nip04, signEvent, getEventHash, getPublicKey } from "nostr-tools";
import { nip04, getPublicKey, finishEvent } from "nostr-tools";
const decryptedKeys = new Map<string, string>();
@ -85,12 +85,7 @@ class SigningService {
} else if (account?.secKey) {
const secKey = await this.decryptSecKey(account);
const tmpDraft = { ...draft, pubkey: getPublicKey(secKey) };
const signature = signEvent(tmpDraft, secKey);
const event: NostrEvent = {
...tmpDraft,
id: getEventHash(tmpDraft),
sig: signature,
};
const event = finishEvent(tmpDraft, secKey) as NostrEvent;
return event;
} else throw new Error("No signing method");