Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions views_lnurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

from fastapi import APIRouter, HTTPException, Query, Request
from lnbits.core.services import create_invoice
from lnbits.exceptions import InvoiceError
from lnbits.utils.exchange_rates import get_fiat_rate_satoshis
from lnbits.wallets import get_funding_source
from lnbits.wallets.base import Feature
from lnurl import (
CallbackUrl,
LightningInvoice,
Expand Down Expand Up @@ -111,14 +114,26 @@ async def api_lnurl_callback(

# we take the zap request as the description instead of the metadata if present
unhashed_description = nostr.encode() if nostr else metadata.encode()
funding_source = get_funding_source()
if (
funding_source.features is not None
and not funding_source.has_feature(Feature.descriptionhash)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no feature for Feature.descriptionhash? am i missing something?

):
return LnurlErrorResponse(
reason="This payment link cannot receive payments with its current configuration."
)

try:
payment = await create_invoice(
wallet_id=link.wallet,
amount=int(amount / 1000),
memo=link.description,
unhashed_description=unhashed_description,
extra=extra,
)
except InvoiceError as exc:
return LnurlErrorResponse(reason=exc.message)

payment = await create_invoice(
wallet_id=link.wallet,
amount=int(amount / 1000),
memo=link.description,
unhashed_description=unhashed_description,
extra=extra,
)
invoice = parse_obj_as(LightningInvoice, LightningInvoice(payment.bolt11))

if link.success_url:
Expand Down
Loading