Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class WithdrawLink(BaseModel):
"Example: lnurlw://${window.location.hostname}/lnurlw/${id}"
),
)
lnurl_url: str | None = Field(
default=None,
no_database=True,
description="The raw LNURL callback URL (use for QR code generation)",
)

@property
def is_spent(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ window.app = Vue.createApp({
const link = _.findWhere(this.withdrawLinks, {id: linkId})
this.qrCodeDialog.data = _.clone(link)
this.qrCodeDialog.show = true
this.activeUrl = `${window.location.origin}/withdraw/api/v1/lnurl/${link.unique_hash}`
this.activeUrl = link.lnurl_url
},
openUpdateDialog(linkId) {
let link = _.findWhere(this.withdrawLinks, {id: linkId})
Expand Down
2 changes: 1 addition & 1 deletion templates/withdraw/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h6 class="text-subtitle1 q-mb-sm q-mt-none">
data() {
return {
spent: {{ 'true' if spent else 'false' }},
url: `${window.location.origin}/withdraw/api/v1/lnurl/{{ unique_hash }}`,
url: '{{ lnurl_url }}',
lnurl: '',
nfcTagWriting: false
}
Expand Down
10 changes: 9 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ async def display(request: Request, link_id):
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)

try:
lnurl = create_lnurl(link, request)
except ValueError as exc:
raise HTTPException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
detail=str(exc),
) from exc

return withdraw_renderer().TemplateResponse(
"withdraw/display.html",
{
"request": request,
"spent": link.is_spent,
"unique_hash": link.unique_hash,
"lnurl_url": str(lnurl.url),
},
)

Expand Down
3 changes: 3 additions & 0 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def api_links(
detail=str(exc),
) from exc
linkk.lnurl = str(lnurl.bech32)
linkk.lnurl_url = str(lnurl.url)

return links

Expand Down Expand Up @@ -75,6 +76,7 @@ async def api_link_retrieve(
detail=str(exc),
) from exc
link.lnurl = str(lnurl.bech32)
link.lnurl_url = str(lnurl.url)
return link


Expand Down Expand Up @@ -166,6 +168,7 @@ async def api_link_create_or_update(
) from exc

link.lnurl = str(lnurl.bech32)
link.lnurl_url = str(lnurl.url)

return link

Expand Down