Compare commits
No commits in common. "2e52400f5298f44f723f669f8cedbd2838c329a1" and "1bce3bde2d21ed30f6536f137c43c1d9c98b4169" have entirely different histories.
2e52400f52
...
1bce3bde2d
14 changed files with 150 additions and 229 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "Withdraw Links",
|
"name": "Withdraw Links",
|
||||||
"short_description": "Make LNURL withdraw links",
|
"short_description": "Make LNURL withdraw links",
|
||||||
"tile": "/withdraw/static/image/lnurl-withdraw.png",
|
"tile": "/withdraw/static/image/lnurl-withdraw.png",
|
||||||
"version": "1.2.2",
|
"version": "1.1.0",
|
||||||
"min_lnbits_version": "1.3.0",
|
"min_lnbits_version": "1.3.0",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
11
crud.py
11
crud.py
|
|
@ -4,7 +4,7 @@ import shortuuid
|
||||||
from lnbits.db import Database
|
from lnbits.db import Database
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
from .models import CreateWithdrawData, HashCheck, PaginatedWithdraws, WithdrawLink
|
from .models import CreateWithdrawData, HashCheck, WithdrawLink
|
||||||
|
|
||||||
db = Database("ext_withdraw")
|
db = Database("ext_withdraw")
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> WithdrawLink | N
|
||||||
|
|
||||||
async def get_withdraw_links(
|
async def get_withdraw_links(
|
||||||
wallet_ids: list[str], limit: int, offset: int
|
wallet_ids: list[str], limit: int, offset: int
|
||||||
) -> PaginatedWithdraws:
|
) -> tuple[list[WithdrawLink], int]:
|
||||||
q = ",".join([f"'{w}'" for w in wallet_ids])
|
q = ",".join([f"'{w}'" for w in wallet_ids])
|
||||||
|
|
||||||
query_str = f"""
|
query_str = f"""
|
||||||
|
|
@ -85,15 +85,16 @@ async def get_withdraw_links(
|
||||||
query_params,
|
query_params,
|
||||||
WithdrawLink,
|
WithdrawLink,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
f"""
|
f"""
|
||||||
SELECT COUNT(*) as total FROM withdraw.withdraw_link
|
SELECT COUNT(*) as total FROM withdraw.withdraw_link
|
||||||
WHERE wallet IN ({q})
|
WHERE wallet IN ({q})
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result2 = result.mappings().first()
|
total = result.mappings().first()
|
||||||
|
|
||||||
return PaginatedWithdraws(data=links, total=int(result2.total))
|
return links, total.total
|
||||||
|
|
||||||
|
|
||||||
async def remove_unique_withdraw_link(link: WithdrawLink, unique_hash: str) -> None:
|
async def remove_unique_withdraw_link(link: WithdrawLink, unique_hash: str) -> None:
|
||||||
|
|
@ -108,7 +109,7 @@ async def remove_unique_withdraw_link(link: WithdrawLink, unique_hash: str) -> N
|
||||||
|
|
||||||
async def increment_withdraw_link(link: WithdrawLink) -> None:
|
async def increment_withdraw_link(link: WithdrawLink) -> None:
|
||||||
link.used = link.used + 1
|
link.used = link.used + 1
|
||||||
link.open_time = int(datetime.now().timestamp())
|
link.open_time = int(datetime.now().timestamp()) + link.wait_time
|
||||||
await update_withdraw_link(link)
|
await update_withdraw_link(link)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,3 @@ async def m007_add_created_at_timestamp(db):
|
||||||
"ALTER TABLE withdraw.withdraw_link "
|
"ALTER TABLE withdraw.withdraw_link "
|
||||||
f"ADD COLUMN created_at TIMESTAMP DEFAULT {db.timestamp_column_default}"
|
f"ADD COLUMN created_at TIMESTAMP DEFAULT {db.timestamp_column_default}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def m008_add_enabled_column(db):
|
|
||||||
await db.execute(
|
|
||||||
"ALTER TABLE withdraw.withdraw_link ADD COLUMN enabled BOOLEAN DEFAULT true;"
|
|
||||||
)
|
|
||||||
|
|
|
||||||
22
models.py
22
models.py
|
|
@ -15,7 +15,6 @@ class CreateWithdrawData(BaseModel):
|
||||||
webhook_headers: str = Query(None)
|
webhook_headers: str = Query(None)
|
||||||
webhook_body: str = Query(None)
|
webhook_body: str = Query(None)
|
||||||
custom_url: str = Query(None)
|
custom_url: str = Query(None)
|
||||||
enabled: bool = Query(True)
|
|
||||||
|
|
||||||
|
|
||||||
class WithdrawLink(BaseModel):
|
class WithdrawLink(BaseModel):
|
||||||
|
|
@ -38,22 +37,6 @@ class WithdrawLink(BaseModel):
|
||||||
webhook_body: str = Query(None)
|
webhook_body: str = Query(None)
|
||||||
custom_url: str = Query(None)
|
custom_url: str = Query(None)
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
enabled: bool = Query(True)
|
|
||||||
lnurl: str | None = Field(
|
|
||||||
default=None,
|
|
||||||
no_database=True,
|
|
||||||
deprecated=True,
|
|
||||||
description=(
|
|
||||||
"Deprecated: Instead of using this bech32 encoded string, dynamically "
|
|
||||||
"generate your own static link (lud17/bech32) on the client side. "
|
|
||||||
"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
|
@property
|
||||||
def is_spent(self) -> bool:
|
def is_spent(self) -> bool:
|
||||||
|
|
@ -63,8 +46,3 @@ class WithdrawLink(BaseModel):
|
||||||
class HashCheck(BaseModel):
|
class HashCheck(BaseModel):
|
||||||
hash: bool
|
hash: bool
|
||||||
lnurl: bool
|
lnurl: bool
|
||||||
|
|
||||||
|
|
||||||
class PaginatedWithdraws(BaseModel):
|
|
||||||
data: list[WithdrawLink]
|
|
||||||
total: int
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
|
||||||
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/bitcoinswitch_extension" }
|
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/bitcoinswitch_extension" }
|
||||||
dependencies = [ "lnbits>1" ]
|
dependencies = [ "lnbits>1" ]
|
||||||
|
|
||||||
[tool.poetry]
|
|
||||||
package-mode = false
|
|
||||||
|
|
||||||
[tool.uv]
|
[tool.uv]
|
||||||
dev-dependencies = [
|
dev-dependencies = [
|
||||||
"black",
|
"black",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,17 @@
|
||||||
|
const locationPath = [
|
||||||
|
window.location.protocol,
|
||||||
|
'//',
|
||||||
|
window.location.host,
|
||||||
|
window.location.pathname
|
||||||
|
].join('')
|
||||||
|
|
||||||
const mapWithdrawLink = function (obj) {
|
const mapWithdrawLink = function (obj) {
|
||||||
obj._data = _.clone(obj)
|
obj._data = _.clone(obj)
|
||||||
|
obj.min_fsat = new Intl.NumberFormat(LOCALE).format(obj.min_withdrawable)
|
||||||
|
obj.max_fsat = new Intl.NumberFormat(LOCALE).format(obj.max_withdrawable)
|
||||||
obj.uses_left = obj.uses - obj.used
|
obj.uses_left = obj.uses - obj.used
|
||||||
|
obj.print_url = [locationPath, 'print/', obj.id].join('')
|
||||||
|
obj.withdraw_url = [locationPath, obj.id].join('')
|
||||||
obj._data.use_custom = Boolean(obj.custom_url)
|
obj._data.use_custom = Boolean(obj.custom_url)
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +25,6 @@ window.app = Vue.createApp({
|
||||||
return {
|
return {
|
||||||
checker: null,
|
checker: null,
|
||||||
withdrawLinks: [],
|
withdrawLinks: [],
|
||||||
lnurl: '',
|
|
||||||
withdrawLinksTable: {
|
withdrawLinksTable: {
|
||||||
columns: [
|
columns: [
|
||||||
{name: 'title', align: 'left', label: 'Title', field: 'title'},
|
{name: 'title', align: 'left', label: 'Title', field: 'title'},
|
||||||
|
|
@ -24,7 +34,7 @@ window.app = Vue.createApp({
|
||||||
label: 'Created At',
|
label: 'Created At',
|
||||||
field: 'created_at',
|
field: 'created_at',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
format: function (val) {
|
format: function (val, row) {
|
||||||
return new Date(val).toLocaleString()
|
return new Date(val).toLocaleString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -37,7 +47,7 @@ window.app = Vue.createApp({
|
||||||
{
|
{
|
||||||
name: 'uses',
|
name: 'uses',
|
||||||
align: 'right',
|
align: 'right',
|
||||||
label: 'Uses',
|
label: 'Created',
|
||||||
field: 'uses'
|
field: 'uses'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -46,13 +56,8 @@ window.app = Vue.createApp({
|
||||||
label: 'Uses left',
|
label: 'Uses left',
|
||||||
field: 'uses_left'
|
field: 'uses_left'
|
||||||
},
|
},
|
||||||
{
|
{name: 'min', align: 'right', label: 'Min (sat)', field: 'min_fsat'},
|
||||||
name: 'max_withdrawable',
|
{name: 'max', align: 'right', label: 'Max (sat)', field: 'max_fsat'}
|
||||||
align: 'right',
|
|
||||||
label: 'Max (sat)',
|
|
||||||
field: 'max_withdrawable',
|
|
||||||
format: LNbits.utils.formatSat
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
pagination: {
|
pagination: {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|
@ -68,8 +73,7 @@ window.app = Vue.createApp({
|
||||||
data: {
|
data: {
|
||||||
is_unique: false,
|
is_unique: false,
|
||||||
use_custom: false,
|
use_custom: false,
|
||||||
has_webhook: false,
|
has_webhook: false
|
||||||
enabled: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
simpleformDialog: {
|
simpleformDialog: {
|
||||||
|
|
@ -79,8 +83,7 @@ window.app = Vue.createApp({
|
||||||
use_custom: false,
|
use_custom: false,
|
||||||
title: 'Vouchers',
|
title: 'Vouchers',
|
||||||
min_withdrawable: 0,
|
min_withdrawable: 0,
|
||||||
wait_time: 1,
|
wait_time: 1
|
||||||
enabled: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
qrCodeDialog: {
|
qrCodeDialog: {
|
||||||
|
|
@ -127,22 +130,22 @@ window.app = Vue.createApp({
|
||||||
this.formDialog.data = {
|
this.formDialog.data = {
|
||||||
is_unique: false,
|
is_unique: false,
|
||||||
use_custom: false,
|
use_custom: false,
|
||||||
has_webhook: false,
|
has_webhook: false
|
||||||
enabled: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
simplecloseFormDialog() {
|
simplecloseFormDialog() {
|
||||||
this.simpleformDialog.data = {
|
this.simpleformDialog.data = {
|
||||||
is_unique: false,
|
is_unique: false,
|
||||||
use_custom: false,
|
use_custom: false
|
||||||
enabled: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openQrCodeDialog(linkId) {
|
openQrCodeDialog(linkId) {
|
||||||
const link = _.findWhere(this.withdrawLinks, {id: linkId})
|
const link = _.findWhere(this.withdrawLinks, {id: linkId})
|
||||||
|
|
||||||
this.qrCodeDialog.data = _.clone(link)
|
this.qrCodeDialog.data = _.clone(link)
|
||||||
|
this.qrCodeDialog.data.url =
|
||||||
|
window.location.protocol + '//' + window.location.host
|
||||||
this.qrCodeDialog.show = true
|
this.qrCodeDialog.show = true
|
||||||
this.activeUrl = link.lnurl_url
|
|
||||||
},
|
},
|
||||||
openUpdateDialog(linkId) {
|
openUpdateDialog(linkId) {
|
||||||
let link = _.findWhere(this.withdrawLinks, {id: linkId})
|
let link = _.findWhere(this.withdrawLinks, {id: linkId})
|
||||||
|
|
@ -255,7 +258,7 @@ window.app = Vue.createApp({
|
||||||
'/withdraw/api/v1/links/' + linkId,
|
'/withdraw/api/v1/links/' + linkId,
|
||||||
_.findWhere(this.g.user.wallets, {id: link.wallet}).adminkey
|
_.findWhere(this.g.user.wallets, {id: link.wallet}).adminkey
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(response => {
|
||||||
this.withdrawLinks = _.reject(this.withdrawLinks, function (obj) {
|
this.withdrawLinks = _.reject(this.withdrawLinks, function (obj) {
|
||||||
return obj.id === linkId
|
return obj.id === linkId
|
||||||
})
|
})
|
||||||
|
|
|
||||||
12
templates/withdraw/csv.html
Normal file
12
templates/withdraw/csv.html
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "print.html" %} {% block page %} {% for page in link %} {% for threes
|
||||||
|
in page %} {% for one in threes %} {{one}}, {% endfor %} {% endfor %} {% endfor
|
||||||
|
%} {% endblock %} {% block scripts %}
|
||||||
|
<script>
|
||||||
|
window.app = Vue.createApp({
|
||||||
|
el: '#vue',
|
||||||
|
data: function () {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -4,32 +4,24 @@
|
||||||
<q-card class="q-pa-lg">
|
<q-card class="q-pa-lg">
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<q-badge v-if="spent" color="red" class="q-mb-md"
|
{% if link.is_spent %}
|
||||||
>Withdraw is spent.</q-badge
|
<q-badge color="red" class="q-mb-md">Withdraw is spent.</q-badge>
|
||||||
>
|
{% endif %}
|
||||||
<q-badge v-if="spent" color="red" class="q-mb-md"
|
<a class="text-secondary" href="lightning:{{ lnurl }}">
|
||||||
>Withdraw is spent.</q-badge
|
<lnbits-qrcode
|
||||||
>
|
:value="this.here + '/?lightning={{lnurl }}'"
|
||||||
<q-badge v-else-if="!enabled" color="grey" class="q-mb-md"
|
></lnbits-qrcode>
|
||||||
>Withdraw is disabled.</q-badge
|
|
||||||
>
|
|
||||||
<a v-else class="text-secondary" :href="link">
|
|
||||||
<lnbits-qrcode-lnurl
|
|
||||||
prefix="lnurlw"
|
|
||||||
:url="url"
|
|
||||||
@update:lnurl="v => lnurl = v"
|
|
||||||
></lnbits-qrcode-lnurl>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-mt-lg q-gutter-sm">
|
<div class="row q-mt-lg q-gutter-sm">
|
||||||
<q-btn outline color="grey" @click="copyText(lnurl)"
|
<q-btn outline color="grey" @click="copyText('{{ lnurl }}')"
|
||||||
>Copy LNURL</q-btn
|
>Copy LNURL</q-btn
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
icon="nfc"
|
icon="nfc"
|
||||||
@click="writeNfcTag(lnurl)"
|
@click="writeNfcTag(' {{ lnurl }} ')"
|
||||||
:disable="nfcTagWriting"
|
:disable="nfcTagWriting"
|
||||||
></q-btn>
|
></q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -60,11 +52,8 @@
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
spent: {{ 'true' if spent else 'false' }},
|
here: location.protocol + '//' + location.host,
|
||||||
url: '{{ lnurl_url }}',
|
nfcTagWriting: false
|
||||||
lnurl: '',
|
|
||||||
nfcTagWriting: false,
|
|
||||||
enabled: {{ 'true' if enabled else 'false' }}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
<q-th auto-width></q-th>
|
|
||||||
<q-th auto-width></q-th>
|
<q-th auto-width></q-th>
|
||||||
<q-th auto-width></q-th>
|
<q-th auto-width></q-th>
|
||||||
<q-th
|
<q-th
|
||||||
|
|
@ -52,48 +51,49 @@
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
<q-td auto-width>
|
|
||||||
<q-icon
|
|
||||||
name="power_settings_new"
|
|
||||||
:color="props.row.enabled ? 'green' : 'red'"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<q-tooltip>
|
|
||||||
<span
|
|
||||||
v-text="props.row.enabled ? 'Withdraw link is enabled' : 'Withdraw link is disabled'"
|
|
||||||
></span>
|
|
||||||
</q-tooltip>
|
|
||||||
</q-icon>
|
|
||||||
</q-td>
|
|
||||||
<q-td auto-width>
|
<q-td auto-width>
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
dense
|
dense
|
||||||
size="xs"
|
size="xs"
|
||||||
icon="launch"
|
icon="launch"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
type="a"
|
type="a"
|
||||||
:href="'/withdraw/' + props.row.id"
|
:href="props.row.withdraw_url"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<q-tooltip>Shareable link</q-tooltip></q-btn
|
<q-tooltip> shareable link </q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
unelevated
|
||||||
|
dense
|
||||||
|
size="xs"
|
||||||
|
icon="web_asset"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
|
type="a"
|
||||||
|
:href="'/withdraw/img/' + props.row.id"
|
||||||
|
target="_blank"
|
||||||
|
><q-tooltip> embeddable image </q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
dense
|
dense
|
||||||
size="xs"
|
size="xs"
|
||||||
icon="reorder"
|
icon="reorder"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
type="a"
|
type="a"
|
||||||
:href="'/withdraw/csv/' + props.row.id"
|
:href="'/withdraw/csv/' + props.row.id"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
><q-tooltip>CSV download</q-tooltip></q-btn
|
><q-tooltip> csv list </q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
dense
|
dense
|
||||||
size="xs"
|
size="xs"
|
||||||
icon="visibility"
|
icon="visibility"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
@click="openQrCodeDialog(props.row.id)"
|
@click="openQrCodeDialog(props.row.id)"
|
||||||
><q-tooltip>view LNURL</q-tooltip></q-btn
|
><q-tooltip> view LNURL </q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
</q-td>
|
</q-td>
|
||||||
<q-td auto-width>
|
<q-td auto-width>
|
||||||
|
|
@ -139,7 +139,7 @@
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<h6 class="text-subtitle1 q-my-none">
|
<h6 class="text-subtitle1 q-my-none">
|
||||||
LNbits LNURL withdraw extension
|
{{SITE_TITLE}} LNURL-withdraw extension
|
||||||
</h6>
|
</h6>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
|
|
@ -252,20 +252,6 @@
|
||||||
hint="Custom data as JSON string, will get posted along with webhook 'body' field."
|
hint="Custom data as JSON string, will get posted along with webhook 'body' field."
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item tag="label" class="rounded-borders">
|
|
||||||
<q-item-section avatar>
|
|
||||||
<q-checkbox
|
|
||||||
v-model="formDialog.data.enabled"
|
|
||||||
color="primary"
|
|
||||||
></q-checkbox>
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label>Enable / Disable </q-item-label>
|
|
||||||
<q-item-label caption
|
|
||||||
>You can enable or disable these vouchers</q-item-label
|
|
||||||
>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
<q-item tag="label" class="rounded-borders">
|
<q-item tag="label" class="rounded-borders">
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
|
|
@ -378,20 +364,6 @@
|
||||||
label="Number of vouchers"
|
label="Number of vouchers"
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item tag="label" class="rounded-borders">
|
|
||||||
<q-item-section avatar>
|
|
||||||
<q-checkbox
|
|
||||||
v-model="simpleformDialog.data.enabled"
|
|
||||||
color="primary"
|
|
||||||
></q-checkbox>
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section>
|
|
||||||
<q-item-label>Enable / Disable </q-item-label>
|
|
||||||
<q-item-label caption
|
|
||||||
>You can enable or disable these vouchers</q-item-label
|
|
||||||
>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
<q-item tag="label" class="rounded-borders">
|
<q-item tag="label" class="rounded-borders">
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
|
|
@ -441,11 +413,9 @@
|
||||||
|
|
||||||
<q-dialog v-model="qrCodeDialog.show" position="top">
|
<q-dialog v-model="qrCodeDialog.show" position="top">
|
||||||
<q-card v-if="qrCodeDialog.data" class="q-pa-lg lnbits__dialog-card">
|
<q-card v-if="qrCodeDialog.data" class="q-pa-lg lnbits__dialog-card">
|
||||||
<lnbits-qrcode-lnurl
|
<lnbits-qrcode
|
||||||
:url="activeUrl"
|
:value="qrCodeDialog.data.url + '/?lightning=' + qrCodeDialog.data.lnurl"
|
||||||
@update:lnurl="v => lnurl = v"
|
></lnbits-qrcode>
|
||||||
prefix="lnurlw"
|
|
||||||
></lnbits-qrcode-lnurl>
|
|
||||||
<p style="word-break: break-all">
|
<p style="word-break: break-all">
|
||||||
<strong>ID:</strong> <span v-text="qrCodeDialog.data.id"></span><br />
|
<strong>ID:</strong> <span v-text="qrCodeDialog.data.id"></span><br />
|
||||||
<strong>Unique:</strong>
|
<strong>Unique:</strong>
|
||||||
|
|
@ -470,32 +440,31 @@
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
@click="copyText(lnurl, 'LNURL copied to clipboard!')"
|
@click="copyText(qrCodeDialog.data.lnurl, 'LNURL copied to clipboard!')"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
>Copy LNURL</q-btn
|
>Copy LNURL</q-btn
|
||||||
>
|
>
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="grey"
|
||||||
|
icon="link"
|
||||||
|
@click="copyText(qrCodeDialog.data.withdraw_url, 'Link copied to clipboard!')"
|
||||||
|
><q-tooltip>Copy sharable link</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
icon="nfc"
|
icon="nfc"
|
||||||
@click="writeNfcTag(lnurl)"
|
@click="writeNfcTag(qrCodeDialog.data.lnurl)"
|
||||||
:disable="nfcTagWriting"
|
:disable="nfcTagWriting"
|
||||||
><q-tooltip>Write to NFC</q-tooltip></q-btn
|
><q-tooltip>Write to NFC</q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
<q-btn
|
|
||||||
outline
|
|
||||||
color="grey"
|
|
||||||
icon="link"
|
|
||||||
:href="'/withdraw/' + qrCodeDialog.data.id"
|
|
||||||
target="_blank"
|
|
||||||
><q-tooltip>Open sharable link</q-tooltip>
|
|
||||||
</q-btn>
|
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
icon="print"
|
icon="print"
|
||||||
type="a"
|
type="a"
|
||||||
:href="'/withdraw/print/' + qrCodeDialog.data.id"
|
:href="qrCodeDialog.data.print_url"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
><q-tooltip>Print</q-tooltip></q-btn
|
><q-tooltip>Print</q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,23 @@
|
||||||
<div class="" id="vue">
|
<div class="" id="vue">
|
||||||
{% for page in link %}
|
{% for page in link %}
|
||||||
<page size="A4" id="pdfprint">
|
<page size="A4" id="pdfprint">
|
||||||
<div class="full-height content-center">
|
<table style="width: 100%">
|
||||||
{% for row in page %}
|
{% for threes in page %}
|
||||||
<div class="row" style="max-height: 54mm">
|
<tr style="height: 59.4mm">
|
||||||
{% for one in row %}
|
{% for one in threes %}
|
||||||
<div class="col-6">
|
<td style="width: 105mm">
|
||||||
|
<center>
|
||||||
<lnbits-qrcode
|
<lnbits-qrcode
|
||||||
style="width: 50mm"
|
style="width: fit-content"
|
||||||
:value="theurl + '/?lightning={{one}}'"
|
:value="theurl + '/?lightning={{one}}'"
|
||||||
:show-buttons="false"
|
:options="{width: 150}"
|
||||||
></lnbits-qrcode>
|
></lnbits-qrcode>
|
||||||
</div>
|
</center>
|
||||||
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</table>
|
||||||
</page>
|
</page>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@
|
||||||
<div class="lnurlw">
|
<div class="lnurlw">
|
||||||
<lnbits-qrcode
|
<lnbits-qrcode
|
||||||
:value="theurl + '/?lightning={{one}}'"
|
:value="theurl + '/?lightning={{one}}'"
|
||||||
:show-buttons="false"
|
:options="{width: 98, margin: 2, logo: false}"
|
||||||
:options="{width: 150}"
|
|
||||||
></lnbits-qrcode>
|
></lnbits-qrcode>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -62,10 +61,9 @@
|
||||||
.wrapper .lnurlw {
|
.wrapper .lnurlw {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(3mm + 1rem);
|
top: calc(7.3mm + 1rem);
|
||||||
left: calc(6mm + 1rem);
|
left: calc(7.5mm + 1rem);
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
width: 27mm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
|
|
@ -85,8 +83,8 @@
|
||||||
.wrapper .lnurlw {
|
.wrapper .lnurlw {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3mm;
|
top: 7.3mm;
|
||||||
left: 6mm;
|
left: 7.5mm;
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
41
views.py
41
views.py
|
|
@ -1,8 +1,7 @@
|
||||||
import io
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||||
from fastapi.responses import HTMLResponse, StreamingResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
@ -45,9 +44,9 @@ async def display(request: Request, link_id):
|
||||||
"withdraw/display.html",
|
"withdraw/display.html",
|
||||||
{
|
{
|
||||||
"request": request,
|
"request": request,
|
||||||
"spent": link.is_spent,
|
"link": link.json(),
|
||||||
"lnurl_url": str(lnurl.url),
|
"lnurl": lnurl,
|
||||||
"enabled": link.enabled,
|
"unique": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -59,8 +58,11 @@ async def print_qr(request: Request, link_id):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
||||||
)
|
)
|
||||||
|
# response.status_code = HTTPStatus.NOT_FOUND
|
||||||
|
# return "Withdraw link does not exist."
|
||||||
|
|
||||||
if link.uses == 0:
|
if link.uses == 0:
|
||||||
|
|
||||||
return withdraw_renderer().TemplateResponse(
|
return withdraw_renderer().TemplateResponse(
|
||||||
"withdraw/print_qr.html",
|
"withdraw/print_qr.html",
|
||||||
{"request": request, "link": link.json(), "unique": False},
|
{"request": request, "link": link.json(), "unique": False},
|
||||||
|
|
@ -81,7 +83,7 @@ async def print_qr(request: Request, link_id):
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
links.append(str(lnurl.bech32))
|
links.append(str(lnurl))
|
||||||
count = count + 1
|
count = count + 1
|
||||||
page_link = list(chunks(links, 2))
|
page_link = list(chunks(links, 2))
|
||||||
linked = list(chunks(page_link, 5))
|
linked = list(chunks(page_link, 5))
|
||||||
|
|
@ -112,12 +114,14 @@ async def csv(request: Request, link_id):
|
||||||
)
|
)
|
||||||
|
|
||||||
if link.uses == 0:
|
if link.uses == 0:
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.BAD_REQUEST, detail="Withdraw is spent."
|
|
||||||
)
|
|
||||||
|
|
||||||
buffer = io.StringIO()
|
return withdraw_renderer().TemplateResponse(
|
||||||
|
"withdraw/csv.html",
|
||||||
|
{"request": request, "link": link.json(), "unique": False},
|
||||||
|
)
|
||||||
|
links = []
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
for _ in link.usescsv.split(","):
|
for _ in link.usescsv.split(","):
|
||||||
linkk = await get_withdraw_link(link_id, count)
|
linkk = await get_withdraw_link(link_id, count)
|
||||||
if not linkk:
|
if not linkk:
|
||||||
|
|
@ -131,16 +135,11 @@ async def csv(request: Request, link_id):
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
buffer.write(f"{lnurl.bech32!s}\n")
|
links.append(str(lnurl))
|
||||||
count += 1
|
count = count + 1
|
||||||
|
page_link = list(chunks(links, 2))
|
||||||
|
linked = list(chunks(page_link, 5))
|
||||||
|
|
||||||
# Move buffer cursor to the beginning
|
return withdraw_renderer().TemplateResponse(
|
||||||
buffer.seek(0)
|
"withdraw/csv.html", {"request": request, "link": linked, "unique": True}
|
||||||
|
|
||||||
return StreamingResponse(
|
|
||||||
buffer,
|
|
||||||
media_type="text/csv",
|
|
||||||
headers={
|
|
||||||
"Content-Disposition": f"attachment; filename=withdraw-links-{link_id}.csv"
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
46
views_api.py
46
views_api.py
|
|
@ -3,7 +3,7 @@ from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
from lnbits.core.models import SimpleStatus, WalletTypeInfo
|
from lnbits.core.models import WalletTypeInfo
|
||||||
from lnbits.decorators import require_admin_key, require_invoice_key
|
from lnbits.decorators import require_admin_key, require_invoice_key
|
||||||
|
|
||||||
from .crud import (
|
from .crud import (
|
||||||
|
|
@ -15,7 +15,7 @@ from .crud import (
|
||||||
update_withdraw_link,
|
update_withdraw_link,
|
||||||
)
|
)
|
||||||
from .helpers import create_lnurl
|
from .helpers import create_lnurl
|
||||||
from .models import CreateWithdrawData, HashCheck, PaginatedWithdraws, WithdrawLink
|
from .models import CreateWithdrawData, HashCheck
|
||||||
|
|
||||||
withdraw_ext_api = APIRouter(prefix="/api/v1")
|
withdraw_ext_api = APIRouter(prefix="/api/v1")
|
||||||
|
|
||||||
|
|
@ -27,35 +27,38 @@ async def api_links(
|
||||||
all_wallets: bool = Query(False),
|
all_wallets: bool = Query(False),
|
||||||
offset: int = Query(0),
|
offset: int = Query(0),
|
||||||
limit: int = Query(0),
|
limit: int = Query(0),
|
||||||
) -> PaginatedWithdraws:
|
):
|
||||||
wallet_ids = [key_info.wallet.id]
|
wallet_ids = [key_info.wallet.id]
|
||||||
|
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
user = await get_user(key_info.wallet.user)
|
user = await get_user(key_info.wallet.user)
|
||||||
wallet_ids = user.wallet_ids if user else []
|
wallet_ids = user.wallet_ids if user else []
|
||||||
|
|
||||||
links = await get_withdraw_links(wallet_ids, limit, offset)
|
links, total = await get_withdraw_links(wallet_ids, limit, offset)
|
||||||
|
|
||||||
for linkk in links.data:
|
data = []
|
||||||
|
for link in links:
|
||||||
try:
|
try:
|
||||||
lnurl = create_lnurl(linkk, request)
|
lnurl = create_lnurl(link, request)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
linkk.lnurl = str(lnurl.bech32)
|
data.append({**link.dict(), **{"lnurl": lnurl}})
|
||||||
linkk.lnurl_url = str(lnurl.url)
|
|
||||||
|
|
||||||
return links
|
return {
|
||||||
|
"data": data,
|
||||||
|
"total": total,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.get("/links/{link_id}", status_code=HTTPStatus.OK)
|
@withdraw_ext_api.get("/links/{link_id}", status_code=HTTPStatus.OK)
|
||||||
async def api_link_retrieve(
|
async def api_link_retrieve(
|
||||||
request: Request,
|
|
||||||
link_id: str,
|
link_id: str,
|
||||||
|
request: Request,
|
||||||
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
||||||
) -> WithdrawLink:
|
):
|
||||||
link = await get_withdraw_link(link_id, 0)
|
link = await get_withdraw_link(link_id, 0)
|
||||||
|
|
||||||
if not link:
|
if not link:
|
||||||
|
|
@ -67,7 +70,6 @@ async def api_link_retrieve(
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Not your withdraw link.", status_code=HTTPStatus.FORBIDDEN
|
detail="Not your withdraw link.", status_code=HTTPStatus.FORBIDDEN
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lnurl = create_lnurl(link, request)
|
lnurl = create_lnurl(link, request)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
|
|
@ -75,19 +77,17 @@ async def api_link_retrieve(
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
link.lnurl = str(lnurl.bech32)
|
return {**link.dict(), **{"lnurl": lnurl}}
|
||||||
link.lnurl_url = str(lnurl.url)
|
|
||||||
return link
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.post("/links", status_code=HTTPStatus.CREATED)
|
@withdraw_ext_api.post("/links", status_code=HTTPStatus.CREATED)
|
||||||
@withdraw_ext_api.put("/links/{link_id}")
|
@withdraw_ext_api.put("/links/{link_id}", status_code=HTTPStatus.OK)
|
||||||
async def api_link_create_or_update(
|
async def api_link_create_or_update(
|
||||||
request: Request,
|
request: Request,
|
||||||
data: CreateWithdrawData,
|
data: CreateWithdrawData,
|
||||||
link_id: str | None = None,
|
link_id: str | None = None,
|
||||||
key_info: WalletTypeInfo = Depends(require_admin_key),
|
key_info: WalletTypeInfo = Depends(require_admin_key),
|
||||||
) -> WithdrawLink:
|
):
|
||||||
if data.uses > 250:
|
if data.uses > 250:
|
||||||
raise HTTPException(detail="250 uses max.", status_code=HTTPStatus.BAD_REQUEST)
|
raise HTTPException(detail="250 uses max.", status_code=HTTPStatus.BAD_REQUEST)
|
||||||
|
|
||||||
|
|
@ -159,6 +159,7 @@ async def api_link_create_or_update(
|
||||||
link = await update_withdraw_link(link)
|
link = await update_withdraw_link(link)
|
||||||
else:
|
else:
|
||||||
link = await create_withdraw_link(wallet_id=key_info.wallet.id, data=data)
|
link = await create_withdraw_link(wallet_id=key_info.wallet.id, data=data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lnurl = create_lnurl(link, request)
|
lnurl = create_lnurl(link, request)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
|
|
@ -167,16 +168,13 @@ async def api_link_create_or_update(
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
link.lnurl = str(lnurl.bech32)
|
return {**link.dict(), **{"lnurl": lnurl}}
|
||||||
link.lnurl_url = str(lnurl.url)
|
|
||||||
|
|
||||||
return link
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.delete("/links/{link_id}")
|
@withdraw_ext_api.delete("/links/{link_id}", status_code=HTTPStatus.OK)
|
||||||
async def api_link_delete(
|
async def api_link_delete(
|
||||||
link_id: str, key_info: WalletTypeInfo = Depends(require_admin_key)
|
link_id: str, key_info: WalletTypeInfo = Depends(require_admin_key)
|
||||||
) -> SimpleStatus:
|
):
|
||||||
link = await get_withdraw_link(link_id)
|
link = await get_withdraw_link(link_id)
|
||||||
|
|
||||||
if not link:
|
if not link:
|
||||||
|
|
@ -190,7 +188,7 @@ async def api_link_delete(
|
||||||
)
|
)
|
||||||
|
|
||||||
await delete_withdraw_link(link_id)
|
await delete_withdraw_link(link_id)
|
||||||
return SimpleStatus(success=True, message="Withdraw link deleted.")
|
return {"success": True}
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.get(
|
@withdraw_ext_api.get(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ from datetime import datetime
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import shortuuid
|
import shortuuid
|
||||||
from bolt11 import decode as decode_bolt11
|
|
||||||
from fastapi import APIRouter, Request
|
from fastapi import APIRouter, Request
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from lnbits.core.crud import update_payment
|
from lnbits.core.crud import update_payment
|
||||||
|
|
@ -44,9 +43,6 @@ async def api_lnurl_response(
|
||||||
if not link:
|
if not link:
|
||||||
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
||||||
|
|
||||||
if not link.enabled:
|
|
||||||
return LnurlErrorResponse(reason="Withdraw link is disabled.")
|
|
||||||
|
|
||||||
if link.is_spent:
|
if link.is_spent:
|
||||||
return LnurlErrorResponse(reason="Withdraw is spent.")
|
return LnurlErrorResponse(reason="Withdraw is spent.")
|
||||||
|
|
||||||
|
|
@ -90,23 +86,11 @@ async def api_lnurl_callback(
|
||||||
pr: str,
|
pr: str,
|
||||||
id_unique_hash: str | None = None,
|
id_unique_hash: str | None = None,
|
||||||
) -> LnurlErrorResponse | LnurlSuccessResponse:
|
) -> LnurlErrorResponse | LnurlSuccessResponse:
|
||||||
|
|
||||||
link = await get_withdraw_link_by_hash(unique_hash)
|
link = await get_withdraw_link_by_hash(unique_hash)
|
||||||
if not link:
|
if not link:
|
||||||
return LnurlErrorResponse(reason="withdraw link not found.")
|
return LnurlErrorResponse(reason="withdraw link not found.")
|
||||||
|
|
||||||
if not link.enabled:
|
|
||||||
return LnurlErrorResponse(reason="Withdraw link is disabled.")
|
|
||||||
|
|
||||||
bolt11 = decode_bolt11(pr)
|
|
||||||
if not bolt11.amount_msat:
|
|
||||||
return LnurlErrorResponse(reason="0 amount invoices are not supported.")
|
|
||||||
|
|
||||||
if (
|
|
||||||
link.min_withdrawable * 1000 > bolt11.amount_msat
|
|
||||||
or bolt11.amount_msat > link.max_withdrawable * 1000
|
|
||||||
):
|
|
||||||
return LnurlErrorResponse(reason="Amount not within limits.")
|
|
||||||
|
|
||||||
if link.is_spent:
|
if link.is_spent:
|
||||||
return LnurlErrorResponse(reason="withdraw is spent.")
|
return LnurlErrorResponse(reason="withdraw is spent.")
|
||||||
|
|
||||||
|
|
@ -115,9 +99,9 @@ async def api_lnurl_callback(
|
||||||
|
|
||||||
now = int(datetime.now().timestamp())
|
now = int(datetime.now().timestamp())
|
||||||
|
|
||||||
if now < link.open_time + link.wait_time:
|
if now < link.open_time:
|
||||||
return LnurlErrorResponse(
|
return LnurlErrorResponse(
|
||||||
reason=f"Wait {link.open_time + link.wait_time - now} seconds."
|
reason=f"wait link open_time {link.open_time - now} seconds."
|
||||||
)
|
)
|
||||||
|
|
||||||
if not id_unique_hash and link.is_unique:
|
if not id_unique_hash and link.is_unique:
|
||||||
|
|
@ -210,9 +194,6 @@ async def api_lnurl_multi_response(
|
||||||
if not link:
|
if not link:
|
||||||
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
||||||
|
|
||||||
if not link.enabled:
|
|
||||||
return LnurlErrorResponse(reason="Withdraw link is disabled.")
|
|
||||||
|
|
||||||
if link.is_spent:
|
if link.is_spent:
|
||||||
return LnurlErrorResponse(reason="Withdraw is spent.")
|
return LnurlErrorResponse(reason="Withdraw is spent.")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue