Skip to content

Commit

Permalink
fix: receipt event (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
motorina0 authored Sep 13, 2024
1 parent e3d0fb2 commit 98ff395
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions nostr/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

from . import bech32
from .event import EncryptedDirectMessage, EventKind
from .event import EncryptedDirectMessage, Event


class PublicKey:
Expand Down Expand Up @@ -118,9 +118,7 @@ def sign_message_hash(self, message_hash: bytes) -> str:
sig = sk.schnorr_sign(message_hash, None, raw=True)
return sig.hex()

def sign_event(self, event: EncryptedDirectMessage) -> None:
if event.kind == EventKind.ENCRYPTED_DIRECT_MESSAGE and event.content is None:
self.encrypt_dm(event)
def sign_event(self, event: Event) -> None:
if event.public_key is None:
event.public_key = self.public_key.hex()
event.signature = self.sign_message_hash(bytes.fromhex(event.id))
Expand Down
8 changes: 3 additions & 5 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from .crud import get_or_create_lnurlp_settings, get_pay_link
from .models import PayLink
from .nostr.event import EncryptedDirectMessage
from .nostr.event import Event


async def wait_for_paid_invoices():
Expand Down Expand Up @@ -132,12 +132,10 @@ def get_tag(event_json, tag):

pubkey = next((pk[1] for pk in tags if pk[0] == "p"), None)
assert pubkey, "Cannot create zap receipt. Recepient pubkey is missing."
zap_receipt = EncryptedDirectMessage(
zap_receipt = Event(
kind=9735,
recipient_pubkey=pubkey,
tags=tags,
content=payment.extra.get("comment") or "",
cleartext_content=payment.extra.get("comment") or "",
content="",
)

settings = await get_or_create_lnurlp_settings()
Expand Down

0 comments on commit 98ff395

Please sign in to comment.