mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #1117 from PR0M3TH3AN/fix-zap-signing-compatibility-17075194725684270757
Fix zap signing compatibility with nostr-tools v2
This commit is contained in:
2 files changed
+5
-14
No files matched your search
@@ -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 }) {
|
||||
|
||||
@@ -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 }) {
|
||||
|
||||
Reference in new issue
Block a user