diff --git a/js/payments/nwcClient.js b/js/payments/nwcClient.js index 752d8250..451691ea 100644 --- a/js/payments/nwcClient.js +++ b/js/payments/nwcClient.js @@ -1,6 +1,7 @@ // js/payments/nwcClient.js import { nostrToolsReady } from "../nostrToolsBootstrap.js"; +import { signEventWithPrivateKey } from "../nostr/publishHelpers.js"; import { userLogger } from "../utils/logger.js"; import { isZapAllowanceExhaustedError } from "./zapSharedState.js"; @@ -1288,7 +1289,6 @@ export async function ensureWallet({ settings } = {}) { } async function encryptRequestPayload(context, payload) { - const tools = assertNostrTools(["getEventHash", "signEvent"]); const encryption = await ensureEncryption(context); const plaintext = JSON.stringify(payload); @@ -1307,10 +1307,7 @@ async function encryptRequestPayload(context, payload) { tags, }; - event.id = tools.getEventHash(event); - event.sig = tools.signEvent(event, context.secretKey); - - return event; + return signEventWithPrivateKey(event, context.secretKey); } function registerPendingRequest(eventId, payloadId, { resolve, reject, timeoutMs }) { diff --git a/js/payments/zapSplit.js b/js/payments/zapSplit.js index d9109855..8363c618 100644 --- a/js/payments/zapSplit.js +++ b/js/payments/zapSplit.js @@ -12,6 +12,7 @@ import { import { ensureWallet, sendPayment } from "./nwcClient.js"; import { getPlatformLightningAddress } from "./platformAddress.js"; import { RELAY_URLS } from "../nostr/toolkit.js"; +import { signEventWithPrivateKey } from "../nostr/publishHelpers.js"; import { userLogger } from "../utils/logger.js"; import { validateZapReceipt } from "./zapReceiptValidator.js"; import { @@ -346,11 +347,6 @@ function buildZapRequest({ comment, lnurl, }) { - const tools = getNostrTools(); - if (!tools?.getEventHash || !tools?.signEvent) { - throw new Error("NostrTools is required to sign zap requests."); - } - const tags = []; if (recipientPubkey) { tags.push(["p", recipientPubkey]); @@ -385,10 +381,8 @@ function buildZapRequest({ pubkey: wallet?.clientPubkey || "", }; - event.id = tools.getEventHash(event); - event.sig = tools.signEvent(event, wallet?.secretKey); - - return JSON.stringify(event); + const signedEvent = signEventWithPrivateKey(event, wallet?.secretKey); + return JSON.stringify(signedEvent); } function determineRecipientPubkey({ recipientType, metadata, videoEvent }) {