bug: ignore zapperPubkey for forward zaps

This commit is contained in:
2023-04-05 12:36:12 +01:00
parent 5944cfd918
commit 8be0c7dd3d
3 changed files with 7 additions and 5 deletions

View File

@ -22,7 +22,7 @@ function getInvoice(zap: TaggedRawEvent): InvoiceDetails | undefined {
return decodeInvoice(bolt11);
}
export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
export function parseZap(zapReceipt: TaggedRawEvent, refNote?: TaggedRawEvent): ParsedZap {
let innerZapJson = findTag(zapReceipt, "description");
if (innerZapJson) {
try {
@ -35,6 +35,7 @@ export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
// old format, ignored
throw new Error("deprecated zap format");
}
const isForwardedZap = refNote?.tags.some(a => a[0] === "zap") ?? false;
const anonZap = findTag(zapRequest, "anon");
const metaHash = sha256(innerZapJson);
const ret: ParsedZap = {
@ -65,7 +66,7 @@ export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
ret.valid = false;
ret.errors.push("amount tag does not match invoice amount");
}
if (UserCache.getFromCache(ret.receiver)?.zapService !== ret.zapService) {
if (UserCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) {
ret.valid = false;
ret.errors.push("zap service pubkey doesn't match");
}