bug: catch invalid zaps (missing tag)
This commit is contained in:
parent
7c6c944c82
commit
b11ab51ba8
@ -23,6 +23,10 @@ function findTag(e: TaggedRawEvent, tag: string) {
|
|||||||
|
|
||||||
function getInvoice(zap: TaggedRawEvent) {
|
function getInvoice(zap: TaggedRawEvent) {
|
||||||
const bolt11 = findTag(zap, "bolt11");
|
const bolt11 = findTag(zap, "bolt11");
|
||||||
|
if (!bolt11) {
|
||||||
|
console.debug("Invalid zap: ", zap);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
const decoded = invoiceDecode(bolt11);
|
const decoded = invoiceDecode(bolt11);
|
||||||
|
|
||||||
const amount = decoded.sections.find(section => section.name === "amount")?.value;
|
const amount = decoded.sections.find(section => section.name === "amount")?.value;
|
||||||
@ -66,6 +70,7 @@ export interface ParsedZap {
|
|||||||
content: string;
|
content: string;
|
||||||
zapper?: HexKey;
|
zapper?: HexKey;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
|
zapService: HexKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
||||||
@ -81,6 +86,7 @@ export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
|||||||
zapper: zapper.pubkey,
|
zapper: zapper.pubkey,
|
||||||
content: zap.content,
|
content: zap.content,
|
||||||
valid: zapper.isValid,
|
valid: zapper.isValid,
|
||||||
|
zapService: zap.pubkey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user