This commit is contained in:
parent
0cef163eb9
commit
9eb029e1dc
@ -45,33 +45,47 @@ export class Zapper {
|
|||||||
* Create targets from Event
|
* Create targets from Event
|
||||||
*/
|
*/
|
||||||
static fromEvent(ev: NostrEvent) {
|
static fromEvent(ev: NostrEvent) {
|
||||||
return ev.tags
|
if (ev.tags.some(a => a[0] === "zap")) {
|
||||||
.filter(a => a[0] === "zap")
|
return ev.tags
|
||||||
.map(v => {
|
.filter(a => a[0] === "zap")
|
||||||
if (v[1].length === 64 && isHex(v[1]) && v.length === 4) {
|
.map(v => {
|
||||||
// NIP-57.G
|
if (v[1].length === 64 && isHex(v[1]) && v.length === 4) {
|
||||||
return {
|
// NIP-57.G
|
||||||
type: "pubkey",
|
return {
|
||||||
value: v[1],
|
type: "pubkey",
|
||||||
weight: Number(v[3] ?? 0),
|
value: v[1],
|
||||||
zap: {
|
weight: Number(v[3] ?? 0),
|
||||||
pubkey: v[1],
|
zap: {
|
||||||
event: NostrLink.fromEvent(ev),
|
pubkey: v[1],
|
||||||
},
|
event: NostrLink.fromEvent(ev),
|
||||||
} as ZapTarget;
|
},
|
||||||
} else {
|
} as ZapTarget;
|
||||||
// assume event specific zap target
|
} else {
|
||||||
return {
|
// assume event specific zap target
|
||||||
type: "lnurl",
|
return {
|
||||||
value: v[1],
|
type: "lnurl",
|
||||||
weight: 1,
|
value: v[1],
|
||||||
zap: {
|
weight: 1,
|
||||||
pubkey: ev.pubkey,
|
zap: {
|
||||||
event: NostrLink.fromEvent(ev),
|
pubkey: ev.pubkey,
|
||||||
},
|
event: NostrLink.fromEvent(ev),
|
||||||
} as ZapTarget;
|
},
|
||||||
}
|
} as ZapTarget;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: "pubkey",
|
||||||
|
value: ev.pubkey,
|
||||||
|
weight: 1,
|
||||||
|
zap: {
|
||||||
|
pubkey: ev.pubkey,
|
||||||
|
event: NostrLink.fromEvent(ev),
|
||||||
|
},
|
||||||
|
} as ZapTarget,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async send(wallet: LNWallet | undefined, targets: Array<ZapTarget>, amount: number) {
|
async send(wallet: LNWallet | undefined, targets: Array<ZapTarget>, amount: number) {
|
||||||
|
@ -63,10 +63,10 @@ export function parseZap(zapReceipt: NostrEvent, userCache: FeedCache<MetadataCa
|
|||||||
ret.valid = false;
|
ret.valid = false;
|
||||||
ret.errors.push("amount tag does not match invoice amount");
|
ret.errors.push("amount tag does not match invoice amount");
|
||||||
}
|
}
|
||||||
if (userCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) {
|
/*if (userCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) {
|
||||||
ret.valid = false;
|
ret.valid = false;
|
||||||
ret.errors.push("zap service pubkey doesn't match");
|
ret.errors.push("zap service pubkey doesn't match");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!ret.valid) {
|
if (!ret.valid) {
|
||||||
Log("Invalid zap %O", ret);
|
Log("Invalid zap %O", ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user