fix: receipt event (#68)
This commit is contained in:
parent
e3d0fb27e9
commit
98ff395c36
2 changed files with 5 additions and 9 deletions
|
|
@ -8,7 +8,7 @@ from cryptography.hazmat.primitives import padding
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||||
|
|
||||||
from . import bech32
|
from . import bech32
|
||||||
from .event import EncryptedDirectMessage, EventKind
|
from .event import EncryptedDirectMessage, Event
|
||||||
|
|
||||||
|
|
||||||
class PublicKey:
|
class PublicKey:
|
||||||
|
|
@ -118,9 +118,7 @@ class PrivateKey:
|
||||||
sig = sk.schnorr_sign(message_hash, None, raw=True)
|
sig = sk.schnorr_sign(message_hash, None, raw=True)
|
||||||
return sig.hex()
|
return sig.hex()
|
||||||
|
|
||||||
def sign_event(self, event: EncryptedDirectMessage) -> None:
|
def sign_event(self, event: Event) -> None:
|
||||||
if event.kind == EventKind.ENCRYPTED_DIRECT_MESSAGE and event.content is None:
|
|
||||||
self.encrypt_dm(event)
|
|
||||||
if event.public_key is None:
|
if event.public_key is None:
|
||||||
event.public_key = self.public_key.hex()
|
event.public_key = self.public_key.hex()
|
||||||
event.signature = self.sign_message_hash(bytes.fromhex(event.id))
|
event.signature = self.sign_message_hash(bytes.fromhex(event.id))
|
||||||
|
|
|
||||||
8
tasks.py
8
tasks.py
|
|
@ -14,7 +14,7 @@ from websocket import WebSocketApp
|
||||||
|
|
||||||
from .crud import get_or_create_lnurlp_settings, get_pay_link
|
from .crud import get_or_create_lnurlp_settings, get_pay_link
|
||||||
from .models import PayLink
|
from .models import PayLink
|
||||||
from .nostr.event import EncryptedDirectMessage
|
from .nostr.event import Event
|
||||||
|
|
||||||
|
|
||||||
async def wait_for_paid_invoices():
|
async def wait_for_paid_invoices():
|
||||||
|
|
@ -132,12 +132,10 @@ async def send_zap(payment: Payment):
|
||||||
|
|
||||||
pubkey = next((pk[1] for pk in tags if pk[0] == "p"), None)
|
pubkey = next((pk[1] for pk in tags if pk[0] == "p"), None)
|
||||||
assert pubkey, "Cannot create zap receipt. Recepient pubkey is missing."
|
assert pubkey, "Cannot create zap receipt. Recepient pubkey is missing."
|
||||||
zap_receipt = EncryptedDirectMessage(
|
zap_receipt = Event(
|
||||||
kind=9735,
|
kind=9735,
|
||||||
recipient_pubkey=pubkey,
|
|
||||||
tags=tags,
|
tags=tags,
|
||||||
content=payment.extra.get("comment") or "",
|
content="",
|
||||||
cleartext_content=payment.extra.get("comment") or "",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
settings = await get_or_create_lnurlp_settings()
|
settings = await get_or_create_lnurlp_settings()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue