allowNostr vs alllowsNostr
This commit is contained in:
parent
54ca4476cc
commit
50f9b505cd
2 changed files with 20 additions and 14 deletions
27
lnurl.py
27
lnurl.py
|
|
@ -48,15 +48,15 @@ async def api_lnurl_callback(
|
|||
min = link.min * 1000
|
||||
max = link.max * 1000
|
||||
|
||||
amount_received = amount
|
||||
if amount_received < min:
|
||||
amount = amount
|
||||
if amount < min:
|
||||
return LnurlErrorResponse(
|
||||
reason=f"Amount {amount_received} is smaller than minimum {min}."
|
||||
reason=f"Amount {amount} is smaller than minimum {min}."
|
||||
).dict()
|
||||
|
||||
elif amount_received > max:
|
||||
elif amount > max:
|
||||
return LnurlErrorResponse(
|
||||
reason=f"Amount {amount_received} is greater than maximum {max}."
|
||||
reason=f"Amount {amount} is greater than maximum {max}."
|
||||
).dict()
|
||||
|
||||
comment = request.query_params.get("comment")
|
||||
|
|
@ -79,21 +79,22 @@ async def api_lnurl_callback(
|
|||
extra["comment"] = (comment,)
|
||||
|
||||
nostr = request.query_params.get("nostr")
|
||||
nostr_description = ""
|
||||
if nostr:
|
||||
extra["nostr"] = nostr
|
||||
# print("HASHING THIS")
|
||||
nostr_description = json.dumps(nostr)[1:-1] # remove leading and trailing "
|
||||
# print(nostr_description)
|
||||
import hashlib
|
||||
|
||||
print(hashlib.sha256(nostr_description.encode()).hexdigest())
|
||||
|
||||
if lnaddress and link.username and link.domain:
|
||||
extra["lnaddress"] = f"{link.username}@{link.domain}"
|
||||
|
||||
print("HASHING THIS")
|
||||
nostr_description = json.dumps(nostr)[1:-1] # remove leading and trailing "
|
||||
print(nostr_description)
|
||||
import hashlib
|
||||
|
||||
print(hashlib.sha256(nostr_description.encode()).hexdigest())
|
||||
payment_hash, payment_request = await create_invoice(
|
||||
wallet_id=link.wallet,
|
||||
amount=int(amount_received / 1000),
|
||||
amount=int(amount / 1000),
|
||||
memo=link.description,
|
||||
unhashed_description=nostr_description.encode()
|
||||
if nostr
|
||||
|
|
@ -149,7 +150,7 @@ async def api_lnurl_response(request: Request, link_id, lnaddress=False):
|
|||
if link.comment_chars > 0:
|
||||
params["commentAllowed"] = link.comment_chars
|
||||
|
||||
params["allowNostr"] = True
|
||||
params["allowsNostr"] = True
|
||||
params[
|
||||
"nostrPubkey"
|
||||
] = "749b4d4dfc6b00a5e6c9a88d8a220c46c069ff8f027dcf312f040475e059554a" # private: de1af06647137d49b2277faa86f96effc94257a7b7efd6f5dcc52bea08a4746b
|
||||
|
|
|
|||
7
tasks.py
7
tasks.py
|
|
@ -65,6 +65,7 @@ async def on_invoice_paid(payment: Payment):
|
|||
payment.payment_hash, -1, False, "Unexpected Error", str(ex)
|
||||
)
|
||||
|
||||
# NIP-57
|
||||
nostr = payment.extra.get("nostr")
|
||||
if nostr:
|
||||
from ..nostrclient.nostr.event import Event
|
||||
|
|
@ -92,11 +93,15 @@ async def on_invoice_paid(payment: Payment):
|
|||
tags.append([t, tag])
|
||||
tags.append(["bolt11", payment.bolt11])
|
||||
tags.append(["description", nostr])
|
||||
zap_receipt = Event(kind=9735, tags=tags, content="asd")
|
||||
zap_receipt = Event(
|
||||
kind=9735, tags=tags, content=payment.extra.get("comment") or ""
|
||||
)
|
||||
private_key.sign_event(zap_receipt)
|
||||
|
||||
def send_event(_):
|
||||
# logger.debug(f"Sending zap: {zap_receipt.to_message()}")
|
||||
ws.send(zap_receipt.to_message())
|
||||
ws.close()
|
||||
|
||||
from lnbits.core import bolt11
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue