feat: support lud-11 disposable links (#95)
This commit is contained in:
parent
0cf2df2dcb
commit
3dc1e86d8c
6 changed files with 29 additions and 4 deletions
1
crud.py
1
crud.py
|
|
@ -66,6 +66,7 @@ async def create_pay_link(data: CreatePayLinkData) -> PayLink:
|
|||
fiat_base_multiplier=data.fiat_base_multiplier,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
disposable=data.disposable if data.disposable is not None else True,
|
||||
)
|
||||
|
||||
await db.insert("lnurlp.pay_links", link)
|
||||
|
|
|
|||
|
|
@ -212,3 +212,9 @@ async def m011_add_created_at(db: Connection):
|
|||
""",
|
||||
{"now": now},
|
||||
)
|
||||
|
||||
|
||||
async def m012_add_disposable(db: Connection):
|
||||
await db.execute(
|
||||
"ALTER TABLE lnurlp.pay_links ADD COLUMN disposable BOOLEAN DEFAULT TRUE"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class CreatePayLinkData(BaseModel):
|
|||
fiat_base_multiplier: int = Query(100, ge=1)
|
||||
username: str = Query(None)
|
||||
zaps: Optional[bool] = Query(False)
|
||||
disposable: bool | None = Query(True)
|
||||
|
||||
|
||||
class PayLink(BaseModel):
|
||||
|
|
@ -63,6 +64,8 @@ class PayLink(BaseModel):
|
|||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
disposable: bool
|
||||
|
||||
def lnurl(self, req: Request) -> str:
|
||||
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
||||
url = url.replace(path=normalize_path(url.path))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ const mapPayLink = obj => {
|
|||
obj._data = _.clone(obj)
|
||||
obj.created_at = LNbits.utils.formatDateString(obj.created_at)
|
||||
obj.updated_at = LNbits.utils.formatDateString(obj.updated_at)
|
||||
|
||||
obj.print_url = [locationPath, 'print/', obj.id].join('')
|
||||
obj.pay_url = [locationPath, 'link/', obj.id].join('')
|
||||
return obj
|
||||
|
|
|
|||
|
|
@ -235,6 +235,18 @@
|
|||
>
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||
LUD-11: Disposable and storeable payRequests.
|
||||
</h5>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<q-checkbox
|
||||
dense
|
||||
v-model="formDialog.data.disposable"
|
||||
label="If enabled, the LNURL will not be stored (default)."
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">LNURL</h5>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
|
|
|||
|
|
@ -119,15 +119,19 @@ async def api_lnurl_callback(
|
|||
text = link.success_text or f"Link to {link.success_url}"
|
||||
desc = parse_obj_as(Max144Str, text)
|
||||
action = UrlAction(tag=LnurlPaySuccessActionTag.url, url=url, description=desc)
|
||||
return LnurlPayActionResponse(pr=invoice, successAction=action)
|
||||
return LnurlPayActionResponse(
|
||||
pr=invoice, successAction=action, disposable=link.disposable
|
||||
)
|
||||
|
||||
if link.success_text:
|
||||
message = parse_obj_as(Max144Str, link.success_text)
|
||||
return LnurlPayActionResponse(
|
||||
pr=invoice, successAction=MessageAction(message=message)
|
||||
pr=invoice,
|
||||
successAction=MessageAction(message=message),
|
||||
disposable=link.disposable,
|
||||
)
|
||||
|
||||
return LnurlPayActionResponse(pr=invoice)
|
||||
return LnurlPayActionResponse(pr=invoice, disposable=link.disposable)
|
||||
|
||||
|
||||
@lnurlp_lnurl_router.get(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue