Compare commits
21 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c0e58a87c | |||
| 2877cf6b20 | |||
| 0e06ab2087 | |||
| 40dce4d88c | |||
| 66026abe96 | |||
| e9d911e593 | |||
| 82a6d4a894 | |||
| 95ed17754d | |||
|
|
2e52400f52 |
||
|
|
74852e3494 |
||
|
|
ab96594f70 |
||
|
|
8a20df70fe |
||
|
|
68ff753cfd |
||
|
|
eb7f7fda47 |
||
|
|
720aa694c1 |
||
|
|
d0689b7859 |
||
|
|
8efacf2d4c |
||
|
|
10a4caff7e |
||
|
|
1bce3bde2d |
||
|
|
717d9c88f8 |
||
|
|
b42fee99e5 |
22 changed files with 3024 additions and 2983 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
|
@ -7,7 +7,7 @@ jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Create github release
|
- name: Create github release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
needs: [release]
|
needs: [release]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.EXT_GITHUB }}
|
token: ${{ secrets.EXT_GITHUB }}
|
||||||
repository: lnbits/lnbits-extensions
|
repository: lnbits/lnbits-extensions
|
||||||
|
|
|
||||||
24
Makefile
24
Makefile
|
|
@ -5,27 +5,27 @@ format: prettier black ruff
|
||||||
check: mypy pyright checkblack checkruff checkprettier
|
check: mypy pyright checkblack checkruff checkprettier
|
||||||
|
|
||||||
prettier:
|
prettier:
|
||||||
poetry run ./node_modules/.bin/prettier --write .
|
uv run ./node_modules/.bin/prettier --write .
|
||||||
pyright:
|
pyright:
|
||||||
poetry run ./node_modules/.bin/pyright
|
uv run ./node_modules/.bin/pyright
|
||||||
|
|
||||||
mypy:
|
mypy:
|
||||||
poetry run mypy .
|
uv run mypy .
|
||||||
|
|
||||||
black:
|
black:
|
||||||
poetry run black .
|
uv run black .
|
||||||
|
|
||||||
ruff:
|
ruff:
|
||||||
poetry run ruff check . --fix
|
uv run ruff check . --fix
|
||||||
|
|
||||||
checkruff:
|
checkruff:
|
||||||
poetry run ruff check .
|
uv run ruff check .
|
||||||
|
|
||||||
checkprettier:
|
checkprettier:
|
||||||
poetry run ./node_modules/.bin/prettier --check .
|
uv run ./node_modules/.bin/prettier --check .
|
||||||
|
|
||||||
checkblack:
|
checkblack:
|
||||||
poetry run black --check .
|
uv run black --check .
|
||||||
|
|
||||||
checkeditorconfig:
|
checkeditorconfig:
|
||||||
editorconfig-checker
|
editorconfig-checker
|
||||||
|
|
@ -33,14 +33,14 @@ checkeditorconfig:
|
||||||
test:
|
test:
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
DEBUG=true \
|
DEBUG=true \
|
||||||
poetry run pytest
|
uv run pytest
|
||||||
install-pre-commit-hook:
|
install-pre-commit-hook:
|
||||||
@echo "Installing pre-commit hook to git"
|
@echo "Installing pre-commit hook to git"
|
||||||
@echo "Uninstall the hook with poetry run pre-commit uninstall"
|
@echo "Uninstall the hook with uv run pre-commit uninstall"
|
||||||
poetry run pre-commit install
|
uv run pre-commit install
|
||||||
|
|
||||||
pre-commit:
|
pre-commit:
|
||||||
poetry run pre-commit run --all-files
|
uv run pre-commit run --all-files
|
||||||
|
|
||||||
|
|
||||||
checkbundle:
|
checkbundle:
|
||||||
|
|
|
||||||
49
__init__.py
49
__init__.py
|
|
@ -17,4 +17,51 @@ withdraw_ext.include_router(withdraw_ext_generic)
|
||||||
withdraw_ext.include_router(withdraw_ext_api)
|
withdraw_ext.include_router(withdraw_ext_api)
|
||||||
withdraw_ext.include_router(withdraw_ext_lnurl)
|
withdraw_ext.include_router(withdraw_ext_lnurl)
|
||||||
|
|
||||||
__all__ = ["withdraw_ext", "withdraw_static_files", "db"]
|
|
||||||
|
def withdraw_start() -> None:
|
||||||
|
"""
|
||||||
|
Register this extension's RPCs with the LNbits nostr transport so an
|
||||||
|
HTTP-allergic client (e.g. lamassu-next ATM) can manage LNURL-withdraw
|
||||||
|
links without touching the HTTP API. Also wires the link-owner
|
||||||
|
resolver so subscribe_payments({tag:"withdraw", link_id:...}) can
|
||||||
|
verify ownership.
|
||||||
|
|
||||||
|
No-op if the core transport module isn't present in the LNbits build.
|
||||||
|
No runtime `if nostr_transport_enabled` guard is needed — when
|
||||||
|
disabled, the relay pool never publishes, so registered RPCs are
|
||||||
|
simply unreachable.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
from lnbits.core.services.nostr_transport.dispatcher import (
|
||||||
|
AUTH_ACCOUNT,
|
||||||
|
AUTH_WALLET,
|
||||||
|
register_rpc,
|
||||||
|
)
|
||||||
|
from lnbits.core.services.nostr_transport.subscriptions import (
|
||||||
|
register_link_owner_resolver,
|
||||||
|
)
|
||||||
|
except ImportError:
|
||||||
|
return
|
||||||
|
|
||||||
|
from .transport_rpcs import (
|
||||||
|
handle_lnurlw_create_link,
|
||||||
|
handle_lnurlw_delete_link,
|
||||||
|
handle_lnurlw_get_link,
|
||||||
|
handle_lnurlw_list_links,
|
||||||
|
handle_lnurlw_unique_hashes,
|
||||||
|
handle_lnurlw_update_link,
|
||||||
|
resolve_withdraw_owner,
|
||||||
|
)
|
||||||
|
|
||||||
|
register_rpc("lnurlw_create_link", handle_lnurlw_create_link, AUTH_WALLET)
|
||||||
|
register_rpc("lnurlw_get_link", handle_lnurlw_get_link, AUTH_WALLET)
|
||||||
|
register_rpc("lnurlw_list_links", handle_lnurlw_list_links, AUTH_ACCOUNT)
|
||||||
|
register_rpc("lnurlw_unique_hashes", handle_lnurlw_unique_hashes, AUTH_WALLET)
|
||||||
|
register_rpc("lnurlw_update_link", handle_lnurlw_update_link, AUTH_WALLET)
|
||||||
|
register_rpc("lnurlw_delete_link", handle_lnurlw_delete_link, AUTH_WALLET)
|
||||||
|
register_link_owner_resolver(
|
||||||
|
"withdraw", resolve_withdraw_owner, link_extra_key="withdrawal_link_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["db", "withdraw_ext", "withdraw_start", "withdraw_static_files"]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
"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",
|
||||||
"min_lnbits_version": "1.0.0",
|
"version": "1.2.2-aio.2",
|
||||||
|
"min_lnbits_version": "1.3.0",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
"name": "arcbtc",
|
"name": "arcbtc",
|
||||||
|
|
|
||||||
17
crud.py
17
crud.py
|
|
@ -1,11 +1,10 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import shortuuid
|
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, WithdrawLink
|
from .models import CreateWithdrawData, HashCheck, PaginatedWithdraws, WithdrawLink
|
||||||
|
|
||||||
db = Database("ext_withdraw")
|
db = Database("ext_withdraw")
|
||||||
|
|
||||||
|
|
@ -33,13 +32,14 @@ async def create_withdraw_link(
|
||||||
webhook_headers=data.webhook_headers,
|
webhook_headers=data.webhook_headers,
|
||||||
webhook_body=data.webhook_body,
|
webhook_body=data.webhook_body,
|
||||||
custom_url=data.custom_url,
|
custom_url=data.custom_url,
|
||||||
|
extra=data.extra,
|
||||||
number=0,
|
number=0,
|
||||||
)
|
)
|
||||||
await db.insert("withdraw.withdraw_link", withdraw_link)
|
await db.insert("withdraw.withdraw_link", withdraw_link)
|
||||||
return withdraw_link
|
return withdraw_link
|
||||||
|
|
||||||
|
|
||||||
async def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]:
|
async def get_withdraw_link(link_id: str, num=0) -> WithdrawLink | None:
|
||||||
link = await db.fetchone(
|
link = await db.fetchone(
|
||||||
"SELECT * FROM withdraw.withdraw_link WHERE id = :id",
|
"SELECT * FROM withdraw.withdraw_link WHERE id = :id",
|
||||||
{"id": link_id},
|
{"id": link_id},
|
||||||
|
|
@ -52,7 +52,7 @@ async def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]:
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
|
||||||
async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> Optional[WithdrawLink]:
|
async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> WithdrawLink | None:
|
||||||
link = await db.fetchone(
|
link = await db.fetchone(
|
||||||
"SELECT * FROM withdraw.withdraw_link WHERE unique_hash = :hash",
|
"SELECT * FROM withdraw.withdraw_link WHERE unique_hash = :hash",
|
||||||
{"hash": unique_hash},
|
{"hash": unique_hash},
|
||||||
|
|
@ -67,7 +67,7 @@ async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> Optional[Withdra
|
||||||
|
|
||||||
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
|
||||||
) -> tuple[list[WithdrawLink], int]:
|
) -> PaginatedWithdraws:
|
||||||
q = ",".join([f"'{w}'" for w in wallet_ids])
|
q = ",".join([f"'{w}'" for w in wallet_ids])
|
||||||
|
|
||||||
query_str = f"""
|
query_str = f"""
|
||||||
|
|
@ -86,16 +86,15 @@ 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})
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
total = result.mappings().first()
|
result2 = result.mappings().first()
|
||||||
|
|
||||||
return links, total.total
|
return PaginatedWithdraws(data=links, total=int(result2.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:
|
||||||
|
|
@ -110,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.wait_time
|
link.open_time = int(datetime.now().timestamp())
|
||||||
await update_withdraw_link(link)
|
await update_withdraw_link(link)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
54
helpers.py
Normal file
54
helpers.py
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
from fastapi import Request
|
||||||
|
from lnbits.settings import settings
|
||||||
|
from lnurl import Lnurl
|
||||||
|
from lnurl import encode as lnurl_encode
|
||||||
|
from shortuuid import uuid
|
||||||
|
|
||||||
|
from .models import WithdrawLink
|
||||||
|
|
||||||
|
|
||||||
|
def create_lnurl(link: WithdrawLink, req: Request) -> Lnurl:
|
||||||
|
if link.is_unique:
|
||||||
|
usescssv = link.usescsv.split(",")
|
||||||
|
tohash = link.id + link.unique_hash + usescssv[link.number]
|
||||||
|
multihash = uuid(name=tohash)
|
||||||
|
url = req.url_for(
|
||||||
|
"withdraw.api_lnurl_multi_response",
|
||||||
|
unique_hash=link.unique_hash,
|
||||||
|
id_unique_hash=multihash,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
url = req.url_for("withdraw.api_lnurl_response", unique_hash=link.unique_hash)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return lnurl_encode(str(url))
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError(
|
||||||
|
f"Error creating LNURL with url: `{url!s}`, "
|
||||||
|
"check your webserver proxy configuration."
|
||||||
|
) from e
|
||||||
|
|
||||||
|
|
||||||
|
def create_lnurl_from_baseurl(link: WithdrawLink) -> Lnurl:
|
||||||
|
"""
|
||||||
|
Same shape as `create_lnurl`, but composes the callback URL from
|
||||||
|
`settings.lnbits_baseurl` instead of a FastAPI `Request`. Used by
|
||||||
|
the nostr-transport RPC handlers, which have no HTTP request to
|
||||||
|
derive a base URL from.
|
||||||
|
"""
|
||||||
|
base = settings.lnbits_baseurl.rstrip("/")
|
||||||
|
if link.is_unique:
|
||||||
|
usescssv = link.usescsv.split(",")
|
||||||
|
tohash = link.id + link.unique_hash + usescssv[link.number]
|
||||||
|
multihash = uuid(name=tohash)
|
||||||
|
url = f"{base}/withdraw/api/v1/lnurl/{link.unique_hash}/{multihash}"
|
||||||
|
else:
|
||||||
|
url = f"{base}/withdraw/api/v1/lnurl/{link.unique_hash}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
return lnurl_encode(url)
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError(
|
||||||
|
f"Error creating LNURL with url: `{url!s}`, "
|
||||||
|
"check your `LNBITS_BASEURL` configuration."
|
||||||
|
) from e
|
||||||
|
|
@ -139,3 +139,9 @@ 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;"
|
||||||
|
)
|
||||||
|
|
|
||||||
44
migrations_fork.py
Normal file
44
migrations_fork.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
"""
|
||||||
|
Fork-specific database migrations for the aiolabs withdraw extension.
|
||||||
|
|
||||||
|
These migrations are tracked separately under `withdraw_fork` in the
|
||||||
|
`dbversions` table (loaded by `lnbits/core/helpers.py:migrate_extension_database`),
|
||||||
|
so they do not collide with upstream's `m{NNN}_*` numbering in
|
||||||
|
`migrations.py`. Keeping the upstream-tracked file untouched means
|
||||||
|
`git pull upstream` stays rebase-clean for schema changes.
|
||||||
|
|
||||||
|
Conventions:
|
||||||
|
- Sequential numbering starting from m001.
|
||||||
|
- Each migration is `async def m{NNN}_<description>(db)`.
|
||||||
|
- DDL must be idempotent: a fresh install runs every migration; an
|
||||||
|
install that already carries the column must not crash. Use
|
||||||
|
`_alter_add_column_safe` so re-runs are no-ops.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
async def _alter_add_column_safe(db, sql: str) -> None:
|
||||||
|
"""ALTER TABLE ADD COLUMN that swallows duplicate-column errors, so a
|
||||||
|
re-run on a DB that already has the column is a silent no-op."""
|
||||||
|
try:
|
||||||
|
await db.execute(sql)
|
||||||
|
except Exception as exc:
|
||||||
|
msg = str(exc).lower()
|
||||||
|
if "duplicate column" in msg or "already exists" in msg:
|
||||||
|
return
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
async def m001_aio_withdraw_schema(db):
|
||||||
|
"""
|
||||||
|
Apply every aiolabs schema delta on top of upstream withdraw.
|
||||||
|
|
||||||
|
`withdraw_link.extra` — arbitrary JSON merged into the payout payment's
|
||||||
|
`extra` when the link is claimed (see views_lnurl). Lets a caller tag the
|
||||||
|
resulting payment with settlement/attribution metadata an external listener
|
||||||
|
can key on — e.g. bitSpire stamps {source, type, principal_sats, fee_sats,
|
||||||
|
...} so the spirekeeper cash-in settlement fires off an LNURL-withdraw
|
||||||
|
payout. Stored as TEXT; (de)serialized to a dict by the WithdrawLink model.
|
||||||
|
"""
|
||||||
|
await _alter_add_column_safe(
|
||||||
|
db, "ALTER TABLE withdraw.withdraw_link ADD COLUMN extra TEXT"
|
||||||
|
)
|
||||||
71
models.py
71
models.py
|
|
@ -1,14 +1,6 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import shortuuid
|
from fastapi import Query
|
||||||
from fastapi import Query, Request
|
|
||||||
from lnurl import (
|
|
||||||
ClearnetUrl,
|
|
||||||
Lnurl,
|
|
||||||
LnurlWithdrawResponse,
|
|
||||||
MilliSatoshi,
|
|
||||||
)
|
|
||||||
from lnurl import encode as lnurl_encode
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,6 +15,13 @@ 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)
|
||||||
|
# Arbitrary JSON merged into the payout payment's `extra` when this link is
|
||||||
|
# claimed (see views_lnurl). Lets a caller tag the resulting payment with
|
||||||
|
# settlement/attribution metadata an external listener can key on — e.g.
|
||||||
|
# bitSpire stamps {source, type, principal_sats, fee_sats, ...} so the
|
||||||
|
# spirekeeper cash-in settlement fires off an LNURL-withdraw payout.
|
||||||
|
extra: dict | None = None
|
||||||
|
|
||||||
|
|
||||||
class WithdrawLink(BaseModel):
|
class WithdrawLink(BaseModel):
|
||||||
|
|
@ -44,42 +43,38 @@ class WithdrawLink(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)
|
||||||
|
# Persisted as TEXT (JSON); merged into the payout payment's `extra` on
|
||||||
|
# claim. LNbits' db layer (de)serializes dict-typed columns to/from JSON
|
||||||
|
# natively (same as Payment.extra) — no per-field validator needed.
|
||||||
|
extra: dict | None = 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:
|
||||||
return self.used >= self.uses
|
return self.used >= self.uses
|
||||||
|
|
||||||
def lnurl(self, req: Request) -> Lnurl:
|
|
||||||
if self.is_unique:
|
|
||||||
usescssv = self.usescsv.split(",")
|
|
||||||
tohash = self.id + self.unique_hash + usescssv[self.number]
|
|
||||||
multihash = shortuuid.uuid(name=tohash)
|
|
||||||
url = str(
|
|
||||||
req.url_for(
|
|
||||||
"withdraw.api_lnurl_multi_response",
|
|
||||||
unique_hash=self.unique_hash,
|
|
||||||
id_unique_hash=multihash,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
url = str(
|
|
||||||
req.url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash)
|
|
||||||
)
|
|
||||||
|
|
||||||
return lnurl_encode(url)
|
|
||||||
|
|
||||||
def lnurl_response(self, req: Request) -> LnurlWithdrawResponse:
|
|
||||||
url = req.url_for("withdraw.api_lnurl_callback", unique_hash=self.unique_hash)
|
|
||||||
return LnurlWithdrawResponse(
|
|
||||||
callback=ClearnetUrl(url, scheme="https"), # type: ignore
|
|
||||||
k1=self.k1,
|
|
||||||
minWithdrawable=MilliSatoshi(self.min_withdrawable * 1000),
|
|
||||||
maxWithdrawable=MilliSatoshi(self.max_withdrawable * 1000),
|
|
||||||
defaultDescription=self.title,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class HashCheck(BaseModel):
|
class HashCheck(BaseModel):
|
||||||
hash: bool
|
hash: bool
|
||||||
lnurl: bool
|
lnurl: bool
|
||||||
|
|
||||||
|
|
||||||
|
class PaginatedWithdraws(BaseModel):
|
||||||
|
data: list[WithdrawLink]
|
||||||
|
total: int
|
||||||
|
|
|
||||||
2616
poetry.lock
generated
2616
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,37 +1,34 @@
|
||||||
[tool.poetry]
|
[project]
|
||||||
name = "lnbits-withdraw"
|
name = "lnbits-withdraw"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
requires-python = ">=3.10,<3.13"
|
||||||
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
||||||
authors = ["Alan Bits <alan@lnbits.com>"]
|
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
|
||||||
|
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/bitcoinswitch_extension" }
|
||||||
|
dependencies = [ "lnbits>1" ]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry]
|
||||||
python = "^3.10 | ^3.9"
|
package-mode = false
|
||||||
lnbits = {version = "*", allow-prereleases = true}
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.uv]
|
||||||
black = "^24.3.0"
|
dev-dependencies = [
|
||||||
pytest-asyncio = "^0.21.0"
|
"black",
|
||||||
pytest = "^7.3.2"
|
"pytest-asyncio",
|
||||||
mypy = "^1.5.1"
|
"pytest",
|
||||||
pre-commit = "^3.2.2"
|
"mypy",
|
||||||
ruff = "^0.3.2"
|
"pre-commit",
|
||||||
|
"ruff",
|
||||||
[build-system]
|
"pytest-md",
|
||||||
requires = ["poetry-core>=1.0.0"]
|
|
||||||
build-backend = "poetry.core.masonry.api"
|
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = [
|
|
||||||
"lnbits.*",
|
|
||||||
"lnurl.*",
|
|
||||||
"loguru.*",
|
|
||||||
"fastapi.*",
|
|
||||||
"pydantic.*",
|
|
||||||
"pyqrcode.*",
|
|
||||||
"shortuuid.*",
|
|
||||||
"httpx.*",
|
|
||||||
]
|
]
|
||||||
ignore_missing_imports = "True"
|
|
||||||
|
[tool.mypy]
|
||||||
|
plugins = ["pydantic.mypy"]
|
||||||
|
|
||||||
|
[tool.pydantic-mypy]
|
||||||
|
init_forbid_extra = true
|
||||||
|
init_typed = true
|
||||||
|
warn_required_dynamic_aliases = true
|
||||||
|
warn_untyped_fields = true
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
log_cli = false
|
log_cli = false
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,6 @@
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +14,7 @@ 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'},
|
||||||
|
|
@ -34,7 +24,7 @@ window.app = Vue.createApp({
|
||||||
label: 'Created At',
|
label: 'Created At',
|
||||||
field: 'created_at',
|
field: 'created_at',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
format: function (val, row) {
|
format: function (val) {
|
||||||
return new Date(val).toLocaleString()
|
return new Date(val).toLocaleString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -47,7 +37,7 @@ window.app = Vue.createApp({
|
||||||
{
|
{
|
||||||
name: 'uses',
|
name: 'uses',
|
||||||
align: 'right',
|
align: 'right',
|
||||||
label: 'Created',
|
label: 'Uses',
|
||||||
field: 'uses'
|
field: 'uses'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -56,8 +46,13 @@ 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', align: 'right', label: 'Max (sat)', field: 'max_fsat'}
|
name: 'max_withdrawable',
|
||||||
|
align: 'right',
|
||||||
|
label: 'Max (sat)',
|
||||||
|
field: 'max_withdrawable',
|
||||||
|
format: LNbits.utils.formatSat
|
||||||
|
}
|
||||||
],
|
],
|
||||||
pagination: {
|
pagination: {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|
@ -73,7 +68,8 @@ 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: {
|
||||||
|
|
@ -83,7 +79,8 @@ 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: {
|
||||||
|
|
@ -130,22 +127,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})
|
||||||
|
|
@ -258,7 +255,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(response => {
|
.then(() => {
|
||||||
this.withdrawLinks = _.reject(this.withdrawLinks, function (obj) {
|
this.withdrawLinks = _.reject(this.withdrawLinks, function (obj) {
|
||||||
return obj.id === linkId
|
return obj.id === linkId
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{% 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,24 +4,32 @@
|
||||||
<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">
|
||||||
{% if link.is_spent %}
|
<q-badge v-if="spent" color="red" class="q-mb-md"
|
||||||
<q-badge color="red" class="q-mb-md">Withdraw is spent.</q-badge>
|
>Withdraw is spent.</q-badge
|
||||||
{% endif %}
|
>
|
||||||
<a class="text-secondary" href="lightning:{{ lnurl }}">
|
<q-badge v-if="spent" color="red" class="q-mb-md"
|
||||||
<lnbits-qrcode
|
>Withdraw is spent.</q-badge
|
||||||
:value="this.here + '/?lightning={{lnurl }}'"
|
>
|
||||||
></lnbits-qrcode>
|
<q-badge v-else-if="!enabled" color="grey" class="q-mb-md"
|
||||||
|
>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>
|
||||||
|
|
@ -52,8 +60,11 @@
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
here: location.protocol + '//' + location.host,
|
spent: {{ 'true' if spent else 'false' }},
|
||||||
nfcTagWriting: false
|
url: '{{ lnurl_url }}',
|
||||||
|
lnurl: '',
|
||||||
|
nfcTagWriting: false,
|
||||||
|
enabled: {{ 'true' if enabled else 'false' }}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
>
|
>
|
||||||
<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
|
||||||
|
|
@ -51,49 +52,48 @@
|
||||||
</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="props.row.withdraw_url"
|
:href="'/withdraw/' + props.row.id"
|
||||||
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 list </q-tooltip></q-btn
|
><q-tooltip>CSV download</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">
|
||||||
{{SITE_TITLE}} LNURL-withdraw extension
|
LNbits 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,6 +252,20 @@
|
||||||
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
|
||||||
|
|
@ -364,6 +378,20 @@
|
||||||
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
|
||||||
|
|
@ -413,9 +441,11 @@
|
||||||
|
|
||||||
<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
|
<lnbits-qrcode-lnurl
|
||||||
:value="qrCodeDialog.data.url + '/?lightning=' + qrCodeDialog.data.lnurl"
|
:url="activeUrl"
|
||||||
></lnbits-qrcode>
|
@update:lnurl="v => lnurl = v"
|
||||||
|
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>
|
||||||
|
|
@ -440,31 +470,32 @@
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
@click="copyText(qrCodeDialog.data.lnurl, 'LNURL copied to clipboard!')"
|
@click="copyText(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(qrCodeDialog.data.lnurl)"
|
@click="writeNfcTag(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="qrCodeDialog.data.print_url"
|
:href="'/withdraw/print/' + qrCodeDialog.data.id"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
><q-tooltip>Print</q-tooltip></q-btn
|
><q-tooltip>Print</q-tooltip></q-btn
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,21 @@
|
||||||
<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">
|
||||||
<table style="width: 100%">
|
<div class="full-height content-center">
|
||||||
{% for threes in page %}
|
{% for row in page %}
|
||||||
<tr style="height: 59.4mm">
|
<div class="row" style="max-height: 54mm">
|
||||||
{% for one in threes %}
|
{% for one in row %}
|
||||||
<td style="width: 105mm">
|
<div class="col-6">
|
||||||
<center>
|
|
||||||
<lnbits-qrcode
|
<lnbits-qrcode
|
||||||
style="width: fit-content"
|
style="width: 50mm"
|
||||||
:value="theurl + '/?lightning={{one}}'"
|
:value="theurl + '/?lightning={{one}}'"
|
||||||
:options="{width: 150}"
|
:show-buttons="false"
|
||||||
></lnbits-qrcode>
|
></lnbits-qrcode>
|
||||||
</center>
|
</div>
|
||||||
</td>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</div>
|
||||||
</page>
|
</page>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
<div class="lnurlw">
|
<div class="lnurlw">
|
||||||
<lnbits-qrcode
|
<lnbits-qrcode
|
||||||
:value="theurl + '/?lightning={{one}}'"
|
:value="theurl + '/?lightning={{one}}'"
|
||||||
:options="{width: 98, margin: 2, logo: false}"
|
:show-buttons="false"
|
||||||
|
:options="{width: 150}"
|
||||||
></lnbits-qrcode>
|
></lnbits-qrcode>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -61,9 +62,10 @@
|
||||||
.wrapper .lnurlw {
|
.wrapper .lnurlw {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(7.3mm + 1rem);
|
top: calc(3mm + 1rem);
|
||||||
left: calc(7.5mm + 1rem);
|
left: calc(6mm + 1rem);
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
|
width: 27mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
|
|
@ -83,8 +85,8 @@
|
||||||
.wrapper .lnurlw {
|
.wrapper .lnurlw {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 7.3mm;
|
top: 3mm;
|
||||||
left: 7.5mm;
|
left: 6mm;
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
225
transport_rpcs.py
Normal file
225
transport_rpcs.py
Normal file
|
|
@ -0,0 +1,225 @@
|
||||||
|
"""
|
||||||
|
Nostr-transport RPC handlers for the withdraw (LNURL-withdraw) extension.
|
||||||
|
|
||||||
|
Names mirror the Lightning.Pub `withdraw.*` contract that the lamassu-next
|
||||||
|
ATM consumes (see ~/dev/shocknet/lamassu-next/packages/lightning/src/client.ts
|
||||||
|
lines ~301–351). That keeps the lamassu-next-side adapter a pure name
|
||||||
|
translation — no semantic reshaping.
|
||||||
|
|
||||||
|
Auth model (set in `__init__.py:withdraw_start`):
|
||||||
|
- create / get / update / delete → AUTH_WALLET; the calling pubkey must
|
||||||
|
own the wallet the link is scoped to. *_get / *_update / *_delete also
|
||||||
|
verify the link's stored `wallet` matches the caller's wallet id.
|
||||||
|
|
||||||
|
`resolve_withdraw_owner` is registered with the core subscription module
|
||||||
|
under tag `"withdraw"` and extras-key `"withdrawal_link_id"` (matching
|
||||||
|
where the extension stamps the link id on settlement — see
|
||||||
|
`views_lnurl.py:144`). That lets `subscribe_payments({tag:"withdraw",
|
||||||
|
link_id:...})` enforce ownership without core importing this module.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from lnbits.core.crud.wallets import get_wallets
|
||||||
|
from lnbits.core.models import Account
|
||||||
|
from lnbits.core.models.wallets import WalletTypeInfo
|
||||||
|
from lnbits.core.services.nostr_transport.models import NostrRpcRequest
|
||||||
|
from shortuuid import uuid
|
||||||
|
|
||||||
|
from .crud import (
|
||||||
|
create_withdraw_link,
|
||||||
|
delete_withdraw_link,
|
||||||
|
get_withdraw_link,
|
||||||
|
get_withdraw_links,
|
||||||
|
update_withdraw_link,
|
||||||
|
)
|
||||||
|
from .helpers import create_lnurl_from_baseurl
|
||||||
|
from .models import CreateWithdrawData, WithdrawLink
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_create_link(
|
||||||
|
auth: WalletTypeInfo, request: NostrRpcRequest
|
||||||
|
) -> dict:
|
||||||
|
body = request.body or {}
|
||||||
|
data = CreateWithdrawData(**body)
|
||||||
|
link = await create_withdraw_link(data, auth.wallet.id)
|
||||||
|
return _to_dict(_populate_lnurl(link))
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_get_link(
|
||||||
|
auth: WalletTypeInfo, request: NostrRpcRequest
|
||||||
|
) -> dict:
|
||||||
|
link_id = _require_id(request)
|
||||||
|
link = await _require_owned_link(link_id, auth.wallet.id)
|
||||||
|
return _to_dict(_populate_lnurl(link))
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_update_link(
|
||||||
|
auth: WalletTypeInfo, request: NostrRpcRequest
|
||||||
|
) -> dict:
|
||||||
|
link_id = _require_id(request)
|
||||||
|
link = await _require_owned_link(link_id, auth.wallet.id)
|
||||||
|
body = request.body or {}
|
||||||
|
_MUTABLE = {
|
||||||
|
"title",
|
||||||
|
"min_withdrawable",
|
||||||
|
"max_withdrawable",
|
||||||
|
"uses",
|
||||||
|
"wait_time",
|
||||||
|
"is_unique",
|
||||||
|
"webhook_url",
|
||||||
|
"webhook_headers",
|
||||||
|
"webhook_body",
|
||||||
|
"custom_url",
|
||||||
|
"enabled",
|
||||||
|
}
|
||||||
|
for k, v in body.items():
|
||||||
|
if k in _MUTABLE:
|
||||||
|
setattr(link, k, v)
|
||||||
|
updated = await update_withdraw_link(link)
|
||||||
|
return _to_dict(_populate_lnurl(updated))
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_delete_link(
|
||||||
|
auth: WalletTypeInfo, request: NostrRpcRequest
|
||||||
|
) -> dict:
|
||||||
|
link_id = _require_id(request)
|
||||||
|
await _require_owned_link(link_id, auth.wallet.id)
|
||||||
|
await delete_withdraw_link(link_id)
|
||||||
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_list_links(auth: Account, request: NostrRpcRequest) -> dict:
|
||||||
|
"""List withdraw links across all wallets owned by the calling account.
|
||||||
|
Useful for ATMs to re-discover their links after a reconnect.
|
||||||
|
|
||||||
|
Body fields:
|
||||||
|
- limit: int (0 means no limit; default 0)
|
||||||
|
- offset: int (default 0)
|
||||||
|
If `request.wallet_id` is set and is one of the caller's wallets,
|
||||||
|
narrow to just that wallet.
|
||||||
|
"""
|
||||||
|
body = request.body or {}
|
||||||
|
limit = int(body.get("limit") or 0)
|
||||||
|
offset = int(body.get("offset") or 0)
|
||||||
|
|
||||||
|
wallets = await get_wallets(auth.id)
|
||||||
|
wallet_ids = [w.id for w in wallets]
|
||||||
|
if not wallet_ids:
|
||||||
|
return {"data": [], "total": 0}
|
||||||
|
if request.wallet_id and request.wallet_id in wallet_ids:
|
||||||
|
wallet_ids = [request.wallet_id]
|
||||||
|
|
||||||
|
page = await get_withdraw_links(wallet_ids, limit, offset)
|
||||||
|
return {
|
||||||
|
"data": [_to_dict(_populate_lnurl(link)) for link in page.data],
|
||||||
|
"total": page.total,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_lnurlw_unique_hashes(
|
||||||
|
auth: WalletTypeInfo, request: NostrRpcRequest
|
||||||
|
) -> dict:
|
||||||
|
"""
|
||||||
|
For a `is_unique=True` link, return the per-use `id_unique_hash`
|
||||||
|
values that the ATM uses to generate distinct QR codes — one per
|
||||||
|
unredeemed slot. Mirrors the formula in `helpers.py:create_lnurl`
|
||||||
|
exactly so an ATM never has to re-implement the derivation:
|
||||||
|
|
||||||
|
id_unique_hash = shortuuid.uuid(name=link.id + link.unique_hash + index)
|
||||||
|
|
||||||
|
`link.usescsv` is the canonical list of *unredeemed* slot indexes;
|
||||||
|
after a customer claims a slot it gets removed there (see
|
||||||
|
`crud.remove_unique_withdraw_link`). The hashes returned here are
|
||||||
|
therefore exactly the ones still claimable.
|
||||||
|
|
||||||
|
Response:
|
||||||
|
{
|
||||||
|
"link_id": str,
|
||||||
|
"unique_hash": str, # base hash
|
||||||
|
"is_unique": bool,
|
||||||
|
"unredeemed_hashes": [ # one entry per remaining slot
|
||||||
|
{"index": str, "id_unique_hash": str}, ...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
For `is_unique=False` links the list is empty and `unique_hash`
|
||||||
|
alone identifies the callback path
|
||||||
|
(`/withdraw/api/v1/lnurl/<unique_hash>`). For `is_unique=True`
|
||||||
|
each callback path is
|
||||||
|
`/withdraw/api/v1/lnurl/<unique_hash>/<id_unique_hash>`.
|
||||||
|
"""
|
||||||
|
link_id = _require_id(request)
|
||||||
|
link = await _require_owned_link(link_id, auth.wallet.id)
|
||||||
|
|
||||||
|
unredeemed = []
|
||||||
|
if link.is_unique:
|
||||||
|
# usescsv is comma-separated; split and skip empties (after the
|
||||||
|
# last slot is consumed it becomes the empty string).
|
||||||
|
for index_str in [s for s in link.usescsv.split(",") if s.strip()]:
|
||||||
|
tohash = link.id + link.unique_hash + index_str
|
||||||
|
unredeemed.append(
|
||||||
|
{
|
||||||
|
"index": index_str.strip(),
|
||||||
|
"id_unique_hash": uuid(name=tohash),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"link_id": link.id,
|
||||||
|
"unique_hash": link.unique_hash,
|
||||||
|
"is_unique": link.is_unique,
|
||||||
|
"unredeemed_hashes": unredeemed,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def resolve_withdraw_owner(link_id: str) -> str | None:
|
||||||
|
"""For the core subscription module: link_id -> wallet_id (or None)."""
|
||||||
|
link = await get_withdraw_link(link_id)
|
||||||
|
return link.wallet if link else None
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# helpers
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def _require_id(request: NostrRpcRequest) -> str:
|
||||||
|
body = request.body or {}
|
||||||
|
link_id = body.get("id")
|
||||||
|
if not link_id:
|
||||||
|
raise ValueError("withdraw: body.id is required")
|
||||||
|
return str(link_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def _require_owned_link(link_id: str, wallet_id: str):
|
||||||
|
link = await get_withdraw_link(link_id)
|
||||||
|
if link is None:
|
||||||
|
raise ValueError(f"withdraw: link not found: {link_id}")
|
||||||
|
if link.wallet != wallet_id:
|
||||||
|
raise PermissionError("withdraw: link does not belong to caller's wallet")
|
||||||
|
return link
|
||||||
|
|
||||||
|
|
||||||
|
def _populate_lnurl(link: WithdrawLink) -> WithdrawLink:
|
||||||
|
"""
|
||||||
|
Compose `lnurl` / `lnurl_url` from `settings.lnbits_baseurl` so
|
||||||
|
nostr-transport responses match the HTTP `views_api` shape, where
|
||||||
|
these fields are populated from `request.url_for(...)`. Without
|
||||||
|
this, consumers (ATMs, etc.) would have to re-derive the callback
|
||||||
|
URL themselves from a separately-provisioned LNbits HTTPS URL —
|
||||||
|
duplicating state LNbits already knows. See aiolabs/withdraw#1.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
encoded = create_lnurl_from_baseurl(link)
|
||||||
|
link.lnurl = str(encoded.bech32)
|
||||||
|
link.lnurl_url = str(encoded.url)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return link
|
||||||
|
|
||||||
|
|
||||||
|
def _to_dict(link) -> dict:
|
||||||
|
import json
|
||||||
|
|
||||||
|
return json.loads(link.json())
|
||||||
93
views.py
93
views.py
|
|
@ -1,7 +1,6 @@
|
||||||
|
import io
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
import pyqrcode
|
|
||||||
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, StreamingResponse
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
|
|
@ -9,6 +8,7 @@ from lnbits.decorators import check_user_exists
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
||||||
from .crud import chunks, get_withdraw_link
|
from .crud import chunks, get_withdraw_link
|
||||||
|
from .helpers import create_lnurl
|
||||||
|
|
||||||
withdraw_ext_generic = APIRouter()
|
withdraw_ext_generic = APIRouter()
|
||||||
|
|
||||||
|
|
@ -32,39 +32,22 @@ async def display(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."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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(
|
return withdraw_renderer().TemplateResponse(
|
||||||
"withdraw/display.html",
|
"withdraw/display.html",
|
||||||
{
|
{
|
||||||
"request": request,
|
"request": request,
|
||||||
"link": link.json(),
|
"spent": link.is_spent,
|
||||||
"lnurl": link.lnurl(req=request),
|
"lnurl_url": str(lnurl.url),
|
||||||
"unique": True,
|
"enabled": link.enabled,
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_generic.get("/img/{link_id}", response_class=StreamingResponse)
|
|
||||||
async def img(request: Request, link_id):
|
|
||||||
link = await get_withdraw_link(link_id, 0)
|
|
||||||
if not link:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
|
||||||
)
|
|
||||||
qr = pyqrcode.create(link.lnurl(request))
|
|
||||||
stream = BytesIO()
|
|
||||||
qr.svg(stream, scale=3)
|
|
||||||
stream.seek(0)
|
|
||||||
|
|
||||||
async def _generator(stream: BytesIO):
|
|
||||||
yield stream.getvalue()
|
|
||||||
|
|
||||||
return StreamingResponse(
|
|
||||||
_generator(stream),
|
|
||||||
headers={
|
|
||||||
"Content-Type": "image/svg+xml",
|
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
||||||
"Pragma": "no-cache",
|
|
||||||
"Expires": "0",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -76,11 +59,8 @@ 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},
|
||||||
|
|
@ -94,7 +74,14 @@ 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."
|
||||||
)
|
)
|
||||||
links.append(str(linkk.lnurl(request)))
|
try:
|
||||||
|
lnurl = create_lnurl(linkk, request)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
detail=str(exc),
|
||||||
|
) from exc
|
||||||
|
links.append(str(lnurl.bech32))
|
||||||
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))
|
||||||
|
|
@ -123,29 +110,37 @@ async def csv(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:
|
||||||
|
raise HTTPException(
|
||||||
return withdraw_renderer().TemplateResponse(
|
status_code=HTTPStatus.BAD_REQUEST, detail="Withdraw is spent."
|
||||||
"withdraw/csv.html",
|
|
||||||
{"request": request, "link": link.json(), "unique": False},
|
|
||||||
)
|
)
|
||||||
links = []
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
|
buffer = io.StringIO()
|
||||||
|
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:
|
||||||
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."
|
||||||
)
|
)
|
||||||
links.append(str(linkk.lnurl(request)))
|
try:
|
||||||
count = count + 1
|
lnurl = create_lnurl(linkk, request)
|
||||||
page_link = list(chunks(links, 2))
|
except ValueError as exc:
|
||||||
linked = list(chunks(page_link, 5))
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
detail=str(exc),
|
||||||
|
) from exc
|
||||||
|
buffer.write(f"{lnurl.bech32!s}\n")
|
||||||
|
count += 1
|
||||||
|
|
||||||
return withdraw_renderer().TemplateResponse(
|
# Move buffer cursor to the beginning
|
||||||
"withdraw/csv.html", {"request": request, "link": linked, "unique": True}
|
buffer.seek(0)
|
||||||
|
|
||||||
|
return StreamingResponse(
|
||||||
|
buffer,
|
||||||
|
media_type="text/csv",
|
||||||
|
headers={
|
||||||
|
"Content-Disposition": f"attachment; filename=withdraw-links-{link_id}.csv"
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
71
views_api.py
71
views_api.py
|
|
@ -1,10 +1,9 @@
|
||||||
import json
|
import json
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
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 WalletTypeInfo
|
from lnbits.core.models import SimpleStatus, 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,38 +14,48 @@ from .crud import (
|
||||||
get_withdraw_links,
|
get_withdraw_links,
|
||||||
update_withdraw_link,
|
update_withdraw_link,
|
||||||
)
|
)
|
||||||
from .models import CreateWithdrawData, HashCheck
|
from .helpers import create_lnurl
|
||||||
|
from .models import CreateWithdrawData, HashCheck, PaginatedWithdraws, WithdrawLink
|
||||||
|
|
||||||
withdraw_ext_api = APIRouter(prefix="/api/v1")
|
withdraw_ext_api = APIRouter(prefix="/api/v1")
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.get("/links", status_code=HTTPStatus.OK)
|
@withdraw_ext_api.get("/links", status_code=HTTPStatus.OK)
|
||||||
async def api_links(
|
async def api_links(
|
||||||
req: Request,
|
request: Request,
|
||||||
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
||||||
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, total = await get_withdraw_links(wallet_ids, limit, offset)
|
links = await get_withdraw_links(wallet_ids, limit, offset)
|
||||||
return {
|
|
||||||
"data": [{**link.dict(), **{"lnurl": link.lnurl(req)}} for link in links],
|
for linkk in links.data:
|
||||||
"total": total,
|
try:
|
||||||
}
|
lnurl = create_lnurl(linkk, request)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
detail=str(exc),
|
||||||
|
) from exc
|
||||||
|
linkk.lnurl = str(lnurl.bech32)
|
||||||
|
linkk.lnurl_url = str(lnurl.url)
|
||||||
|
|
||||||
|
return links
|
||||||
|
|
||||||
|
|
||||||
@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(
|
||||||
link_id: str,
|
|
||||||
request: Request,
|
request: Request,
|
||||||
|
link_id: str,
|
||||||
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:
|
||||||
|
|
@ -58,17 +67,27 @@ 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
|
||||||
)
|
)
|
||||||
return {**link.dict(), **{"lnurl": link.lnurl(request)}}
|
|
||||||
|
try:
|
||||||
|
lnurl = create_lnurl(link, request)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
detail=str(exc),
|
||||||
|
) from exc
|
||||||
|
link.lnurl = str(lnurl.bech32)
|
||||||
|
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}", status_code=HTTPStatus.OK)
|
@withdraw_ext_api.put("/links/{link_id}")
|
||||||
async def api_link_create_or_update(
|
async def api_link_create_or_update(
|
||||||
req: Request,
|
request: Request,
|
||||||
data: CreateWithdrawData,
|
data: CreateWithdrawData,
|
||||||
link_id: Optional[str] = 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)
|
||||||
|
|
||||||
|
|
@ -140,14 +159,24 @@ 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:
|
||||||
|
lnurl = create_lnurl(link, request)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
detail=str(exc),
|
||||||
|
) from exc
|
||||||
|
|
||||||
return {**link.dict(), **{"lnurl": link.lnurl(req)}}
|
link.lnurl = str(lnurl.bech32)
|
||||||
|
link.lnurl_url = str(lnurl.url)
|
||||||
|
|
||||||
|
return link
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.delete("/links/{link_id}", status_code=HTTPStatus.OK)
|
@withdraw_ext_api.delete("/links/{link_id}")
|
||||||
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:
|
||||||
|
|
@ -161,7 +190,7 @@ async def api_link_delete(
|
||||||
)
|
)
|
||||||
|
|
||||||
await delete_withdraw_link(link_id)
|
await delete_withdraw_link(link_id)
|
||||||
return {"success": True}
|
return SimpleStatus(success=True, message="Withdraw link deleted.")
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_api.get(
|
@withdraw_ext_api.get(
|
||||||
|
|
|
||||||
191
views_lnurl.py
191
views_lnurl.py
|
|
@ -1,18 +1,23 @@
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from http import HTTPStatus
|
|
||||||
from typing import Callable, Optional
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import shortuuid
|
import shortuuid
|
||||||
from fastapi import APIRouter, HTTPException, Request, Response
|
from bolt11 import decode as decode_bolt11
|
||||||
|
from fastapi import APIRouter, Request
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from fastapi.routing import APIRoute
|
|
||||||
from lnbits.core.crud import update_payment
|
from lnbits.core.crud import update_payment
|
||||||
from lnbits.core.models import Payment
|
from lnbits.core.models import Payment
|
||||||
from lnbits.core.services import pay_invoice
|
from lnbits.core.services import pay_invoice
|
||||||
|
from lnurl import (
|
||||||
|
CallbackUrl,
|
||||||
|
LnurlErrorResponse,
|
||||||
|
LnurlSuccessResponse,
|
||||||
|
LnurlWithdrawResponse,
|
||||||
|
MilliSatoshi,
|
||||||
|
)
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
from pydantic import parse_obj_as
|
||||||
|
|
||||||
from .crud import (
|
from .crud import (
|
||||||
create_hash_check,
|
create_hash_check,
|
||||||
|
|
@ -23,28 +28,7 @@ from .crud import (
|
||||||
)
|
)
|
||||||
from .models import WithdrawLink
|
from .models import WithdrawLink
|
||||||
|
|
||||||
|
|
||||||
class LNURLErrorResponseHandler(APIRoute):
|
|
||||||
def get_route_handler(self) -> Callable:
|
|
||||||
original_route_handler = super().get_route_handler()
|
|
||||||
|
|
||||||
async def custom_route_handler(request: Request) -> Response:
|
|
||||||
try:
|
|
||||||
response = await original_route_handler(request)
|
|
||||||
return response
|
|
||||||
except HTTPException as exc:
|
|
||||||
logger.debug(f"HTTPException: {exc}")
|
|
||||||
response = JSONResponse(
|
|
||||||
status_code=200,
|
|
||||||
content={"status": "ERROR", "reason": f"{exc.detail}"},
|
|
||||||
)
|
|
||||||
return response
|
|
||||||
|
|
||||||
return custom_route_handler
|
|
||||||
|
|
||||||
|
|
||||||
withdraw_ext_lnurl = APIRouter(prefix="/api/v1/lnurl")
|
withdraw_ext_lnurl = APIRouter(prefix="/api/v1/lnurl")
|
||||||
withdraw_ext_lnurl.route_class = LNURLErrorResponseHandler
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_lnurl.get(
|
@withdraw_ext_lnurl.get(
|
||||||
|
|
@ -52,45 +36,35 @@ withdraw_ext_lnurl.route_class = LNURLErrorResponseHandler
|
||||||
response_class=JSONResponse,
|
response_class=JSONResponse,
|
||||||
name="withdraw.api_lnurl_response",
|
name="withdraw.api_lnurl_response",
|
||||||
)
|
)
|
||||||
async def api_lnurl_response(request: Request, unique_hash: str):
|
async def api_lnurl_response(
|
||||||
|
request: Request, unique_hash: str
|
||||||
|
) -> LnurlWithdrawResponse | LnurlErrorResponse:
|
||||||
link = await get_withdraw_link_by_hash(unique_hash)
|
link = await get_withdraw_link_by_hash(unique_hash)
|
||||||
|
|
||||||
if not link:
|
if not link:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
|
||||||
)
|
if not link.enabled:
|
||||||
|
return LnurlErrorResponse(reason="Withdraw link is disabled.")
|
||||||
|
|
||||||
if link.is_spent:
|
if link.is_spent:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="Withdraw is spent.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw is spent."
|
|
||||||
)
|
|
||||||
|
|
||||||
if link.is_unique:
|
if link.is_unique:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="This link requires an id_unique_hash.")
|
||||||
status_code=HTTPStatus.NOT_FOUND,
|
|
||||||
detail="This link requires an id_unique_hash.",
|
|
||||||
)
|
|
||||||
|
|
||||||
url = str(
|
url = str(
|
||||||
request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if url is .onion and change to http
|
callback_url = parse_obj_as(CallbackUrl, url)
|
||||||
if urlparse(url).netloc.endswith(".onion"):
|
return LnurlWithdrawResponse(
|
||||||
# change url string scheme to http
|
callback=callback_url,
|
||||||
url = url.replace("https://", "http://")
|
k1=link.k1,
|
||||||
|
minWithdrawable=MilliSatoshi(link.min_withdrawable * 1000),
|
||||||
return {
|
maxWithdrawable=MilliSatoshi(link.max_withdrawable * 1000),
|
||||||
"tag": "withdrawRequest",
|
defaultDescription=link.title,
|
||||||
"callback": url,
|
)
|
||||||
"k1": link.k1,
|
|
||||||
"minWithdrawable": link.min_withdrawable * 1000,
|
|
||||||
"maxWithdrawable": link.max_withdrawable * 1000,
|
|
||||||
"defaultDescription": link.title,
|
|
||||||
"webhook_url": link.webhook_url,
|
|
||||||
"webhook_headers": link.webhook_headers,
|
|
||||||
"webhook_body": link.webhook_body,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_lnurl.get(
|
@withdraw_ext_lnurl.get(
|
||||||
|
|
@ -114,60 +88,69 @@ async def api_lnurl_callback(
|
||||||
unique_hash: str,
|
unique_hash: str,
|
||||||
k1: str,
|
k1: str,
|
||||||
pr: str,
|
pr: str,
|
||||||
id_unique_hash: Optional[str] = None,
|
id_unique_hash: str | None = None,
|
||||||
):
|
) -> 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:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="withdraw link not found.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="withdraw 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:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="withdraw is spent.")
|
||||||
status_code=HTTPStatus.METHOD_NOT_ALLOWED, detail="withdraw is spent."
|
|
||||||
)
|
|
||||||
|
|
||||||
if link.k1 != k1:
|
if link.k1 != k1:
|
||||||
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail="k1 is wrong.")
|
return LnurlErrorResponse(reason="k1 is wrong.")
|
||||||
|
|
||||||
now = int(datetime.now().timestamp())
|
now = int(datetime.now().timestamp())
|
||||||
|
|
||||||
if now < link.open_time:
|
if now < link.open_time + link.wait_time:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
reason=f"Wait {link.open_time + link.wait_time - now} seconds."
|
||||||
detail=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:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="id_unique_hash is required for this link.")
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
|
||||||
detail="id_unique_hash is required for this link.",
|
|
||||||
)
|
|
||||||
|
|
||||||
if id_unique_hash:
|
if id_unique_hash:
|
||||||
if check_unique_link(link, id_unique_hash):
|
if check_unique_link(link, id_unique_hash):
|
||||||
await remove_unique_withdraw_link(link, id_unique_hash)
|
await remove_unique_withdraw_link(link, id_unique_hash)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="id_unique_hash not found.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="withdraw not found."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a record with the id_unique_hash or unique_hash, if it already exists,
|
# Create a record with the id_unique_hash or unique_hash, if it already exists,
|
||||||
# raise an exception thus preventing the same LNURL from being processed twice.
|
# raise an exception thus preventing the same LNURL from being processed twice.
|
||||||
try:
|
try:
|
||||||
await create_hash_check(id_unique_hash or unique_hash, k1)
|
await create_hash_check(id_unique_hash or unique_hash, k1)
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="LNURL already being processed.")
|
||||||
status_code=HTTPStatus.BAD_REQUEST, detail="LNURL already being processed."
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
payment = await pay_invoice(
|
payment = await pay_invoice(
|
||||||
wallet_id=link.wallet,
|
wallet_id=link.wallet,
|
||||||
payment_request=pr,
|
payment_request=pr,
|
||||||
max_sat=link.max_withdrawable,
|
max_sat=link.max_withdrawable,
|
||||||
extra={"tag": "withdraw", "withdrawal_link_id": link.id},
|
# Merge the link's caller-supplied `extra` onto the payout so an
|
||||||
|
# external listener can key on it (e.g. bitSpire cash-in
|
||||||
|
# settlements via spirekeeper). The withdraw extension's own
|
||||||
|
# `tag`/`withdrawal_link_id` are written last so a caller cannot
|
||||||
|
# clobber them.
|
||||||
|
extra={
|
||||||
|
**(link.extra or {}),
|
||||||
|
"tag": "withdraw",
|
||||||
|
"withdrawal_link_id": link.id,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
await increment_withdraw_link(link)
|
await increment_withdraw_link(link)
|
||||||
# If the payment succeeds, delete the record with the unique_hash.
|
# If the payment succeeds, delete the record with the unique_hash.
|
||||||
|
|
@ -177,13 +160,11 @@ async def api_lnurl_callback(
|
||||||
|
|
||||||
if link.webhook_url:
|
if link.webhook_url:
|
||||||
await dispatch_webhook(link, payment, pr)
|
await dispatch_webhook(link, payment, pr)
|
||||||
return {"status": "OK"}
|
return LnurlSuccessResponse()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
# If payment fails, delete the hash stored so another attempt can be made.
|
# If payment fails, delete the hash stored so another attempt can be made.
|
||||||
await delete_hash_check(id_unique_hash or unique_hash)
|
await delete_hash_check(id_unique_hash or unique_hash)
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason=f"withdraw not working. {exc!s}")
|
||||||
status_code=HTTPStatus.BAD_REQUEST, detail=f"withdraw not working. {exc!s}"
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
|
|
||||||
def check_unique_link(link: WithdrawLink, unique_hash: str) -> bool:
|
def check_unique_link(link: WithdrawLink, unique_hash: str) -> bool:
|
||||||
|
|
@ -232,38 +213,28 @@ async def dispatch_webhook(
|
||||||
)
|
)
|
||||||
async def api_lnurl_multi_response(
|
async def api_lnurl_multi_response(
|
||||||
request: Request, unique_hash: str, id_unique_hash: str
|
request: Request, unique_hash: str, id_unique_hash: str
|
||||||
):
|
) -> LnurlWithdrawResponse | LnurlErrorResponse:
|
||||||
link = await get_withdraw_link_by_hash(unique_hash)
|
link = await get_withdraw_link_by_hash(unique_hash)
|
||||||
|
|
||||||
if not link:
|
if not link:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="Withdraw link does not exist.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="LNURL-withdraw not found."
|
|
||||||
)
|
if not link.enabled:
|
||||||
|
return LnurlErrorResponse(reason="Withdraw link is disabled.")
|
||||||
|
|
||||||
if link.is_spent:
|
if link.is_spent:
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="Withdraw is spent.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw is spent."
|
|
||||||
)
|
|
||||||
|
|
||||||
if not check_unique_link(link, id_unique_hash):
|
if not check_unique_link(link, id_unique_hash):
|
||||||
raise HTTPException(
|
return LnurlErrorResponse(reason="id_unique_hash not found for this link.")
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="LNURL-withdraw not found."
|
|
||||||
|
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
||||||
|
|
||||||
|
callback_url = parse_obj_as(CallbackUrl, f"{url!s}?id_unique_hash={id_unique_hash}")
|
||||||
|
return LnurlWithdrawResponse(
|
||||||
|
callback=callback_url,
|
||||||
|
k1=link.k1,
|
||||||
|
minWithdrawable=MilliSatoshi(link.min_withdrawable * 1000),
|
||||||
|
maxWithdrawable=MilliSatoshi(link.max_withdrawable * 1000),
|
||||||
|
defaultDescription=link.title,
|
||||||
)
|
)
|
||||||
|
|
||||||
url = str(
|
|
||||||
request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check if url is .onion and change to http
|
|
||||||
if urlparse(url).netloc.endswith(".onion"):
|
|
||||||
# change url string scheme to http
|
|
||||||
url = url.replace("https://", "http://")
|
|
||||||
|
|
||||||
return {
|
|
||||||
"tag": "withdrawRequest",
|
|
||||||
"callback": f"{url}?id_unique_hash={id_unique_hash}",
|
|
||||||
"k1": link.k1,
|
|
||||||
"minWithdrawable": link.min_withdrawable * 1000,
|
|
||||||
"maxWithdrawable": link.max_withdrawable * 1000,
|
|
||||||
"defaultDescription": link.title,
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue