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 nip 57 code in make_lnurl_payment. #5

Open
santyr opened this issue Apr 22, 2024 · 0 comments
Open

Fix nip 57 code in make_lnurl_payment. #5

santyr opened this issue Apr 22, 2024 · 0 comments

Comments

@santyr
Copy link
Contributor

santyr commented Apr 22, 2024

Missed one crucial step. Function should include separate invoicing for zaps. Something like:

# construct zap request if needed
        if lnurl_data.get("allowsNostr") and lnurl_data.get("nostrPubkey"):
            event_details = {
                "kind": 9734,
                "content": description or "CyberHerd Treats",
                "tags": [
                    ["p", lnurl_data["nostrPubkey"]]
                ],
                "pubkey": "669ebbcccf409ee0467a33660ae88fd17e5379e646e41d7c236ff4963f3c36b6",
                "created_at": round(datetime.now().timestamp()),
            }
            signed_zap_event = await sign_event(event_details, nos_sec)
            zap_event_encoded = quote(json.dumps(signed_zap_event))
            zap_url = f"{lnurl_data['callback']}?amount={amount}&nostr={zap_event_encoded}"
            zap_response = await client.get(zap_url, headers=headers)
            zap_response.raise_for_status()

            invoice = zap_response.json().get('payment_request', None)
            
            if invoice:
                logger.info(f"Received invoice: {invoice}")
                return await pay_invoice(client, invoice)  # pay_invoice should handle the payment and return a structured response
            else:
                logger.error("No invoice received from zap request")
                return {"success": False, "message": "No invoice received from zap request"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant