Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: receipt event #68

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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