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_api import * # noqa
from .views import * # noqa from .views import * # noqa
from .lnurl import * # noqa

View file

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

View file

@ -1,7 +1,7 @@
from sqlite3 import Row from sqlite3 import Row
from typing import NamedTuple from typing import NamedTuple
import time import time
from quart import url_for
from lnurl import Lnurl, encode as lnurl_encode # type: ignore from lnurl import Lnurl, encode as lnurl_encode # type: ignore
from lnurl.types import LnurlPayMetadata # type: ignore from lnurl.types import LnurlPayMetadata # type: ignore
from lnurl.models import LnurlPaySuccessAction, UrlAction # type: ignore from lnurl.models import LnurlPaySuccessAction, UrlAction # type: ignore
@ -35,5 +35,5 @@ class Copilots(NamedTuple):
@property @property
def lnurl(self) -> Lnurl: 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) return lnurl_encode(url)

View file

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

View file

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

View file

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