diff --git a/.gitignore b/.gitignore index 0152b6e..62836ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ __pycache__ node_modules .mypy_cache +.pytest_cache .venv +data diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..888f079 --- /dev/null +++ b/static/index.js @@ -0,0 +1,15 @@ +window.PageLndhub = { + template: '#page-lndhub', + mixins: [windowMixin], + data() { + const mappedWallets = g.user.wallets.map(wallet => ({ + label: wallet.name, + admin: `lndhub://admin:${wallet.adminkey}@${location.protocol}//${location.host}/lndhub/ext/`, + invoice: `lndhub://invoice:${wallet.inkey}@${location.protocol}//${location.host}/lndhub/ext/` + })) + return { + wallets: mappedWallets, + selectedWallet: mappedWallets[0] + } + } +} diff --git a/static/index.vue b/static/index.vue new file mode 100644 index 0000000..a6d43dc --- /dev/null +++ b/static/index.vue @@ -0,0 +1,138 @@ + diff --git a/static/routes.json b/static/routes.json new file mode 100644 index 0000000..67b6754 --- /dev/null +++ b/static/routes.json @@ -0,0 +1,8 @@ +[ + { + "path": "/lndhub/", + "name": "PageLndhub", + "template": "/lndhub/static/index.vue", + "component": "/lndhub/static/index.js" + } +] diff --git a/templates/lndhub/_instructions.html b/templates/lndhub/_instructions.html deleted file mode 100644 index a5eba8a..0000000 --- a/templates/lndhub/_instructions.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - To access an LNbits wallet from a mobile phone, -
    -
  1. - Install either - Zeus or - BlueWallet; -
  2. -
  3. - Go to Add a wallet / Import wallet on BlueWallet or - Settings / Add a new node on Zeus. -
  4. -
  5. Select the desired wallet on this page;
  6. -
  7. Scan one of the two QR codes from the mobile wallet.
  8. -
-
    -
  • - Invoice URLs mean the mobile wallet will only have the - authorization to read your payments and invoices and generate new - invoices. -
  • -
  • - Admin URLs mean the mobile wallet will be able to pay - invoices.. -
  • -
-
- -
-
diff --git a/templates/lndhub/_lndhub.html b/templates/lndhub/_lndhub.html deleted file mode 100644 index 73097db..0000000 --- a/templates/lndhub/_lndhub.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -

- LndHub is a protocol invented by - BlueWallet - that allows mobile wallets to query payments and balances, generate - invoices and make payments from accounts that exist on a server. The - protocol is a collection of HTTP endpoints exposed through the internet. -

-

- For a wallet that supports it, reading a QR code that contains the URL - along with secret access credentials should enable access. Currently it - is supported by - Zeus and - BlueWallet. -

-
-
-
diff --git a/templates/lndhub/index.html b/templates/lndhub/index.html deleted file mode 100644 index a5177c9..0000000 --- a/templates/lndhub/index.html +++ /dev/null @@ -1,87 +0,0 @@ -{% extends "base.html" %} {% from "macros.jinja" import window_vars with context -%} {% block page %} -
-
-
- - -
- - -
-
- Copy LndHub URL -
-
-
-
- - - - - - - -
- -
- - -
- {{SITE_TITLE}} LndHub extension -
-
- - - - {% include "lndhub/_instructions.html" %} - - {% include "lndhub/_lndhub.html" %} - - -
-
-
- -{% endblock %} {% block scripts %} {{ window_vars(user) }} - -{% endblock %} diff --git a/views.py b/views.py index 444adb7..b524ea6 100644 --- a/views.py +++ b/views.py @@ -1,18 +1,9 @@ -from fastapi import APIRouter, Depends, Request -from lnbits.core.models import User +from fastapi import APIRouter, Depends +from lnbits.core.views.generic import index from lnbits.decorators import check_user_exists -from lnbits.helpers import template_renderer - - -def lndhub_renderer(): - return template_renderer(["lndhub/templates"]) - lndhub_generic_router = APIRouter() - -@lndhub_generic_router.get("/") -async def lndhub_index(request: Request, user: User = Depends(check_user_exists)): - return lndhub_renderer().TemplateResponse( - "lndhub/index.html", {"request": request, "user": user.json()} - ) +lndhub_generic_router.add_api_route( + "/", methods=["GET"], endpoint=index, dependencies=[Depends(check_user_exists)] +)