mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
another nip57 helper and bump version.
This commit is contained in:
34
nip57.ts
34
nip57.ts
@@ -71,3 +71,37 @@ export function makeZapRequest({
|
|||||||
|
|
||||||
return zr
|
return zr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function makeZapReceipt({
|
||||||
|
zapRequest,
|
||||||
|
preimage,
|
||||||
|
bolt11,
|
||||||
|
paidAt
|
||||||
|
}: {
|
||||||
|
zapRequest: string
|
||||||
|
preimage: string | null
|
||||||
|
bolt11: string
|
||||||
|
paidAt: Date
|
||||||
|
}): EventTemplate {
|
||||||
|
let zr: Event = JSON.parse(zapRequest)
|
||||||
|
let tagsFromZapRequest = zr.tags.filter(
|
||||||
|
([t]) => t === 'e' || t === 'p' || t === 'a'
|
||||||
|
)
|
||||||
|
|
||||||
|
let zap = {
|
||||||
|
kind: 9735,
|
||||||
|
created_at: Math.round(paidAt.getTime() / 1000),
|
||||||
|
content: '',
|
||||||
|
tags: [
|
||||||
|
...tagsFromZapRequest,
|
||||||
|
['bolt11', bolt11],
|
||||||
|
['description', zapRequest]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preimage) {
|
||||||
|
zap.tags.push(['preimage', preimage])
|
||||||
|
}
|
||||||
|
|
||||||
|
return zap
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user