Damn you lnurl

This commit is contained in:
Ben Arc 2021-04-14 22:03:36 +01:00
parent 0e67e6a0bb
commit 412ac8d110
6 changed files with 17 additions and 8 deletions

View file

@ -9,3 +9,4 @@ copilot_ext: Blueprint = Blueprint(
from .views_api import * # noqa
from .views import * # noqa
from .lnurl import * # noqa

View file

@ -15,6 +15,7 @@ from quart import jsonify
async def create_copilot(
title: str,
user: str,
wallet: str,
animation1: Optional[str] = None,
animation2: Optional[str] = None,
animation3: Optional[str] = None,
@ -36,6 +37,7 @@ async def create_copilot(
INSERT INTO copilots (
id,
user,
wallet,
title,
animation1,
animation2,
@ -52,11 +54,12 @@ async def create_copilot(
lnurl_title,
amount_made
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
copilot_id,
user,
wallet,
title,
animation1,
animation2,

View file

@ -1,7 +1,7 @@
from sqlite3 import Row
from typing import NamedTuple
import time
from quart import url_for
from lnurl import Lnurl, encode as lnurl_encode # type: ignore
from lnurl.types import LnurlPayMetadata # type: ignore
from lnurl.models import LnurlPaySuccessAction, UrlAction # type: ignore
@ -35,5 +35,5 @@ class Copilots(NamedTuple):
@property
def lnurl(self) -> Lnurl:
url = url_for("copilots.lnurl_response", ls_id=self.id, _external=True)
url = url_for("copilot.lnurl_response", cp_id=self.id, _external=True)
return lnurl_encode(url)

View file

@ -14,12 +14,13 @@
class="fixed-bottom-right"
></video>
<img src="" style="width: 100%" id="animations" class="fixed-bottom-left" />
<img
src="/copilot/static/lnurl.png"
style="width: 20%"
id="animations"
<qrcode
style="width: 25%"
:value="{{copilot.lnurl}}"
:options="{width: 800}"
class="rounded-borders"
class="fixed-top-right"
/>
></qrcode>
<q-btn
color="primary"
@click="reconnect"

View file

@ -10,6 +10,8 @@ from quart import g, abort, render_template, jsonify, websocket
from functools import wraps
import trio
import shortuuid
from . import copilot_ext
connected_websockets = {}
@copilot_ext.websocket('/ws/panel/<copilot_id>')

View file

@ -6,6 +6,8 @@ import httpx
from lnbits.core.crud import get_user
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
from . import copilot_ext
from lnbits.extensions.copilot import copilot_ext
from .crud import (
create_copilot,