prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  No success message and URL returned with LNURLp links
  As the title says, the neither the URL, nor the message are returned to the wallet making the payment. This used to work when I was still on the [latest `raspiblitz` tag](https://github.com/lnbits/lnbits/releases/tag/raspiblitz). Now on [this commit](https://github.com/lnbits/lnbits/commit/7ab4553ef5083f6746bd6fe747775ba57e2e54a4) (the issue could have appeared during any of the commits in between), it has stopped working, even on newly created LNURLp links.
  Edit: Reproducible on lnbits.com
  
  </issue>
  <code>
  [start of lnbits/extensions/lnurlp/lnurl.py]
  1 import hashlib
  2 import math
  3 from http import HTTPStatus
  4 from quart import jsonify, url_for, request
  5 from lnurl import LnurlPayResponse, LnurlPayActionResponse, LnurlErrorResponse  # type: ignore
  6 
  7 from lnbits.core.services import create_invoice
  8 from lnbits.utils.exchange_rates import get_fiat_rate_satoshis
  9 
  10 from . import lnurlp_ext
  11 from .crud import increment_pay_link
  12 
  13 
  14 @lnurlp_ext.route("/api/v1/lnurl/<link_id>", methods=["GET"])
  15 async def api_lnurl_response(link_id):
  16     link = await increment_pay_link(link_id, served_meta=1)
  17     if not link:
  18         return (
  19             jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}),
  20             HTTPStatus.OK,
  21         )
  22 
  23     rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1
  24     resp = LnurlPayResponse(
  25         callback=url_for("lnurlp.api_lnurl_callback", link_id=link.id, _external=True),
  26         min_sendable=math.ceil(link.min * rate) * 1000,
  27         max_sendable=round(link.max * rate) * 1000,
  28         metadata=link.lnurlpay_metadata,
  29     )
  30     params = resp.dict()
  31 
  32     if link.comment_chars > 0:
  33         params["commentAllowed"] = link.comment_chars
  34 
  35     return jsonify(params), HTTPStatus.OK
  36 
  37 
  38 @lnurlp_ext.route("/api/v1/lnurl/cb/<link_id>", methods=["GET"])
  39 async def api_lnurl_callback(link_id):
  40     link = await increment_pay_link(link_id, served_pr=1)
  41     if not link:
  42         return (
  43             jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}),
  44             HTTPStatus.OK,
  45         )
  46 
  47     min, max = link.min, link.max
  48     rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1
  49     if link.currency:
  50         # allow some fluctuation (as the fiat price may have changed between the calls)
  51         min = rate * 995 * link.min
  52         max = rate * 1010 * link.max
  53     else:
  54         min = link.min * 1000
  55         max = link.max * 1000
  56 
  57     amount_received = int(request.args.get("amount") or 0)
  58     if amount_received < min:
  59         return (
  60             jsonify(
  61                 LnurlErrorResponse(
  62                     reason=f"Amount {amount_received} is smaller than minimum {min}."
  63                 ).dict()
  64             ),
  65             HTTPStatus.OK,
  66         )
  67     elif amount_received > max:
  68         return (
  69             jsonify(
  70                 LnurlErrorResponse(
  71                     reason=f"Amount {amount_received} is greater than maximum {max}."
  72                 ).dict()
  73             ),
  74             HTTPStatus.OK,
  75         )
  76 
  77     comment = request.args.get("comment")
  78     if len(comment or "") > link.comment_chars:
  79         return (
  80             jsonify(
  81                 LnurlErrorResponse(
  82                     reason=f"Got a comment with {len(comment)} characters, but can only accept {link.comment_chars}"
  83                 ).dict()
  84             ),
  85             HTTPStatus.OK,
  86         )
  87 
  88     payment_hash, payment_request = await create_invoice(
  89         wallet_id=link.wallet,
  90         amount=int(amount_received / 1000),
  91         memo=link.description,
  92         description_hash=hashlib.sha256(
  93             link.lnurlpay_metadata.encode("utf-8")
  94         ).digest(),
  95         extra={"tag": "lnurlp", "link": link.id, "comment": comment},
  96     )
  97 
  98     resp = {
  99         "routes": [],
  100         "pr": payment_request,
  101     }
  102 
  103     success_action = link.success_action(payment_hash)
  104     if success_action:
  105         resp["success_action"] = success_action
  106 
  107     return jsonify(resp), HTTPStatus.OK
  108
  [end of lnbits/extensions/lnurlp/lnurl.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lnbits/extensions/lnurlp/lnurl.py b/lnbits/extensions/lnurlp/lnurl.py
  --- a/lnbits/extensions/lnurlp/lnurl.py
  +++ b/lnbits/extensions/lnurlp/lnurl.py
  @@ -95,13 +95,17 @@
           extra={"tag": "lnurlp", "link": link.id, "comment": comment},
       )
   
  -    resp = {
  -        "routes": [],
  -        "pr": payment_request,
  -    }
  -
       success_action = link.success_action(payment_hash)
       if success_action:
  -        resp["success_action"] = success_action
  +        resp = LnurlPayActionResponse(
  +            pr=payment_request,
  +            success_action=success_action,
  +            routes=[],
  +        )
  +    else:
  +        resp = LnurlPayActionResponse(
  +            pr=payment_request,
  +            routes=[],
  +        )
   
  -    return jsonify(resp), HTTPStatus.OK
  +    return jsonify(resp.dict()), HTTPStatus.OK
  
verification_info: {"golden_diff": "diff --git a/lnbits/extensions/lnurlp/lnurl.py b/lnbits/extensions/lnurlp/lnurl.py\n--- a/lnbits/extensions/lnurlp/lnurl.py\n+++ b/lnbits/extensions/lnurlp/lnurl.py\n@@ -95,13 +95,17 @@\n         extra={\"tag\": \"lnurlp\", \"link\": link.id, \"comment\": comment},\n     )\n \n-    resp = {\n-        \"routes\": [],\n-        \"pr\": payment_request,\n-    }\n-\n     success_action = link.success_action(payment_hash)\n     if success_action:\n-        resp[\"success_action\"] = success_action\n+        resp = LnurlPayActionResponse(\n+            pr=payment_request,\n+            success_action=success_action,\n+            routes=[],\n+        )\n+    else:\n+        resp = LnurlPayActionResponse(\n+            pr=payment_request,\n+            routes=[],\n+        )\n \n-    return jsonify(resp), HTTPStatus.OK\n+    return jsonify(resp.dict()), HTTPStatus.OK\n", "issue": "No success message and URL returned with LNURLp links\nAs the title says, the neither the URL, nor the message are returned to the wallet making the payment. This used to work when I was still on the [latest `raspiblitz` tag](https://github.com/lnbits/lnbits/releases/tag/raspiblitz). Now on [this commit](https://github.com/lnbits/lnbits/commit/7ab4553ef5083f6746bd6fe747775ba57e2e54a4) (the issue could have appeared during any of the commits in between), it has stopped working, even on newly created LNURLp links.\r\nEdit: Reproducible on lnbits.com\n", "before_files": [{"content": "import hashlib\nimport math\nfrom http import HTTPStatus\nfrom quart import jsonify, url_for, request\nfrom lnurl import LnurlPayResponse, LnurlPayActionResponse, LnurlErrorResponse  # type: ignore\n\nfrom lnbits.core.services import create_invoice\nfrom lnbits.utils.exchange_rates import get_fiat_rate_satoshis\n\nfrom . import lnurlp_ext\nfrom .crud import increment_pay_link\n\n\n@lnurlp_ext.route(\"/api/v1/lnurl/<link_id>\", methods=[\"GET\"])\nasync def api_lnurl_response(link_id):\n    link = await increment_pay_link(link_id, served_meta=1)\n    if not link:\n        return (\n            jsonify({\"status\": \"ERROR\", \"reason\": \"LNURL-pay not found.\"}),\n            HTTPStatus.OK,\n        )\n\n    rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1\n    resp = LnurlPayResponse(\n        callback=url_for(\"lnurlp.api_lnurl_callback\", link_id=link.id, _external=True),\n        min_sendable=math.ceil(link.min * rate) * 1000,\n        max_sendable=round(link.max * rate) * 1000,\n        metadata=link.lnurlpay_metadata,\n    )\n    params = resp.dict()\n\n    if link.comment_chars > 0:\n        params[\"commentAllowed\"] = link.comment_chars\n\n    return jsonify(params), HTTPStatus.OK\n\n\n@lnurlp_ext.route(\"/api/v1/lnurl/cb/<link_id>\", methods=[\"GET\"])\nasync def api_lnurl_callback(link_id):\n    link = await increment_pay_link(link_id, served_pr=1)\n    if not link:\n        return (\n            jsonify({\"status\": \"ERROR\", \"reason\": \"LNURL-pay not found.\"}),\n            HTTPStatus.OK,\n        )\n\n    min, max = link.min, link.max\n    rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1\n    if link.currency:\n        # allow some fluctuation (as the fiat price may have changed between the calls)\n        min = rate * 995 * link.min\n        max = rate * 1010 * link.max\n    else:\n        min = link.min * 1000\n        max = link.max * 1000\n\n    amount_received = int(request.args.get(\"amount\") or 0)\n    if amount_received < min:\n        return (\n            jsonify(\n                LnurlErrorResponse(\n                    reason=f\"Amount {amount_received} is smaller than minimum {min}.\"\n                ).dict()\n            ),\n            HTTPStatus.OK,\n        )\n    elif amount_received > max:\n        return (\n            jsonify(\n                LnurlErrorResponse(\n                    reason=f\"Amount {amount_received} is greater than maximum {max}.\"\n                ).dict()\n            ),\n            HTTPStatus.OK,\n        )\n\n    comment = request.args.get(\"comment\")\n    if len(comment or \"\") > link.comment_chars:\n        return (\n            jsonify(\n                LnurlErrorResponse(\n                    reason=f\"Got a comment with {len(comment)} characters, but can only accept {link.comment_chars}\"\n                ).dict()\n            ),\n            HTTPStatus.OK,\n        )\n\n    payment_hash, payment_request = await create_invoice(\n        wallet_id=link.wallet,\n        amount=int(amount_received / 1000),\n        memo=link.description,\n        description_hash=hashlib.sha256(\n            link.lnurlpay_metadata.encode(\"utf-8\")\n        ).digest(),\n        extra={\"tag\": \"lnurlp\", \"link\": link.id, \"comment\": comment},\n    )\n\n    resp = {\n        \"routes\": [],\n        \"pr\": payment_request,\n    }\n\n    success_action = link.success_action(payment_hash)\n    if success_action:\n        resp[\"success_action\"] = success_action\n\n    return jsonify(resp), HTTPStatus.OK\n", "path": "lnbits/extensions/lnurlp/lnurl.py"}]}