Skip to content

400 bad request when creating pay link #100

@hax0rbana-adam

Description

@hax0rbana-adam

Problem

The error messages when there is an invalid URL does not contain the URL which is invalid nor does it explain where the URL comes from.

Steps to reproduce

  1. Set up a full bitcoin node, an LND node, LNbits using LND (REST) as a back end, and install lnurlp
  2. Attempt to create a pay link, filling in only the required fields
  3. Observe the toast popup that says "400 BAD REQUEST"
  4. Check the logs and find the log messages do not contain a URL which is invalid nor where this URL comes from (logs pasted below)

As a subsequent problem, the lightning address appears to be taken ("409 conflict" response) after the above failure to create a link. I can create a separate ticket for that if desired.

Version information

  • lnurlp version: 1.0.1
  • lnbits version: 1.2.1
  • lnd version: 0.19.2

Logs

Aug 19 16:11:53 btc poetry[96936]: Traceback (most recent call last):
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/lnurl/core.py", line 33, in encode
Aug 19 16:11:53 btc poetry[96936]:     return Lnurl(url_encode(url))
Aug 19 16:11:53 btc poetry[96936]:            ^^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/lnurl/types.py", line 178, in __init__
Aug 19 16:11:53 btc poetry[96936]:     self.url = url if url else self.__get_url__(bech32)
Aug 19 16:11:53 btc poetry[96936]:                                ^^^^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/lnurl/types.py", line 183, in __get_ur>
Aug 19 16:11:53 btc poetry[96936]:     return parse_obj_as(Union[OnionUrl, ClearnetUrl, DebugUrl], url)  # type: ignore
Aug 19 16:11:53 btc poetry[96936]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
Aug 19 16:11:53 btc poetry[96936]:   File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
Aug 19 16:11:53 btc poetry[96936]: pydantic.error_wrappers.ValidationError: 3 validation errors for ParsingModel[Union[OnionUrl, ClearnetUrl, DebugUrl]]
Aug 19 16:11:53 btc poetry[96936]: __root__
Aug 19 16:11:53 btc poetry[96936]:   URL host invalid, top level domain required (type=value_error.url.host)
Aug 19 16:11:53 btc poetry[96936]: __root__
Aug 19 16:11:53 btc poetry[96936]:   URL scheme not permitted (type=value_error.url.scheme; allowed_schemes={'https'})
Aug 19 16:11:53 btc poetry[96936]: __root__
Aug 19 16:11:53 btc poetry[96936]:   invalid or missing URL scheme (type=value_error.url.scheme)
Aug 19 16:11:53 btc poetry[96936]: During handling of the above exception, another exception occurred:
Aug 19 16:11:53 btc poetry[96936]: Traceback (most recent call last):
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line>
Aug 19 16:11:53 btc poetry[96936]:     await app(scope, receive, sender)
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
Aug 19 16:11:53 btc poetry[96936]:     response = await f(request)
Aug 19 16:11:53 btc poetry[96936]:                ^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
Aug 19 16:11:53 btc poetry[96936]:     raw_response = await run_endpoint_function(
Aug 19 16:11:53 btc poetry[96936]:                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_>
Aug 19 16:11:53 btc poetry[96936]:     return await dependant.call(**values)
Aug 19 16:11:53 btc poetry[96936]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/usr/local/lnbits/data/upgrades/lnurlp-281cf5b0ebb4289f93c97ff9438abf18e01569508faaf389723144104bba2273/views_api.py", line 202,>
Aug 19 16:11:53 btc poetry[96936]:     return {**link.dict(), "lnurl": link.lnurl(request)}
Aug 19 16:11:53 btc poetry[96936]:                                     ^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/usr/local/lnbits/data/upgrades/lnurlp-281cf5b0ebb4289f93c97ff9438abf18e01569508faaf389723144104bba2273/models.py", line 74, in >
Aug 19 16:11:53 btc poetry[96936]:     return lnurl_encode(url_str)
Aug 19 16:11:53 btc poetry[96936]:            ^^^^^^^^^^^^^^^^^^^^^
Aug 19 16:11:53 btc poetry[96936]:   File "/home/lnd/.cache/pypoetry/virtualenvs/lnbits-CTKNlgQK-py3.11/lib/python3.11/site-packages/lnurl/core.py", line 35, in encode
Aug 19 16:11:53 btc poetry[96936]:     raise InvalidUrl
Aug 19 16:11:53 btc poetry[96936]: lnurl.exceptions.InvalidUrl
Aug 19 16:11:53 btc poetry[96936]: 2025-08-19 16:11:53.85 | WARNING | ValueError:
Aug 19 16:11:53 btc poetry[96936]: 2025-08-19 16:11:53.85 | INFO | 127.0.0.1:52532 - "POST /upgrades/281cf5b0ebb4289f93c97ff9438abf18e01569508faaf389723144104bba2273/lnurl>
Aug 19 16:11:58 btc poetry[96936]: 2025-08-19 16:11:58.13 | INFO | 127.0.0.1:48578 - "POST /upgrades/281...REDACTED...73/lnurl>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions