Skip to content

LnurlResponse.from_dict raises on valid LUD-06 pay callback when routes is omitted #99

@dsbaars

Description

@dsbaars

LnurlResponse.from_dict incorrectly rejects a valid LUD-06 pay-action callback response when the routes key is absent, raising:

LnurlResponseException: Expected Success or Error response. But no 'status' given.

(Related to lnbits/lnbits#3851)

Expected behaviour

The response is parsed and returned as a LnurlPayActionResponse with routes defaulting to [].

Actual behaviour

from_dict falls through to the status-handling branch and raises:

LnurlResponseException: Expected Success or Error response. But no 'status' given.

Root cause

is_pay_action_response requires both "pr" and "routes" to be present:

def is_pay_action_response(data: dict) -> bool:
    return "pr" in data and "routes" in data

LUD-06 specifies routes as an empty array in the success form, but many real-world implementations omit it entirely. The presence of "pr" alone is the correct signal for a pay-action callback.

LnurlPayActionResponse already defines routes with a safe default (routes: list[list[LnurlPayRouteHop]] = []), so parsing a response without routes is safe.

Metadata

Metadata

Assignees

No one assigned

    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