From 1af84b2b3d866b0e396f650c96a495a33cbe9728 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Thu, 15 Apr 2021 09:39:27 +0100 Subject: [PATCH] Should be working Need to check lnurl logic, and debug --- lnbits/extensions/copilot/crud.py | 7 +- lnbits/extensions/copilot/lnurl.py | 4 +- lnbits/extensions/copilot/migrations.py | 1 + lnbits/extensions/copilot/models.py | 1 + .../copilot/templates/copilot/compose.html | 75 +--- .../copilot/templates/copilot/index.html | 357 +++++++++--------- lnbits/extensions/copilot/views.py | 4 +- lnbits/extensions/copilot/views_api.py | 38 +- 8 files changed, 227 insertions(+), 260 deletions(-) diff --git a/lnbits/extensions/copilot/crud.py b/lnbits/extensions/copilot/crud.py index b5f09278..04d78f16 100644 --- a/lnbits/extensions/copilot/crud.py +++ b/lnbits/extensions/copilot/crud.py @@ -15,7 +15,8 @@ from quart import jsonify async def create_copilot( title: str, user: str, - wallet: str, + lnurl_toggle: str, + wallet: Optional[str] = None, animation1: Optional[str] = None, animation2: Optional[str] = None, animation3: Optional[str] = None, @@ -37,6 +38,7 @@ async def create_copilot( INSERT INTO copilots ( id, user, + lnurl_toggle, wallet, title, animation1, @@ -54,11 +56,12 @@ async def create_copilot( lnurl_title, amount_made ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( copilot_id, user, + lnurl_toggle, wallet, title, animation1, diff --git a/lnbits/extensions/copilot/lnurl.py b/lnbits/extensions/copilot/lnurl.py index f06f888c..3884ceb3 100644 --- a/lnbits/extensions/copilot/lnurl.py +++ b/lnbits/extensions/copilot/lnurl.py @@ -67,6 +67,7 @@ async def lnurl_callback(cp_id): wallet_id=cp.wallet, amount=int(amount_received / 1000), memo=cp.lnurl_title, + webhook="/copilot/api/v1/copilot/hook/" + cp_id, description_hash=hashlib.sha256( (cp.lnurl_title).encode("utf-8") ).digest(), @@ -83,8 +84,5 @@ async def lnurl_callback(cp_id): success_action=success_action, routes=[], ) - socket_sendererer = app.socket_sendererer() - async with socket_sendererer.websocket('/ws') as the_websocket: - await the_websocket.send("pay{payment_hash}") return jsonify(resp.dict()) \ No newline at end of file diff --git a/lnbits/extensions/copilot/migrations.py b/lnbits/extensions/copilot/migrations.py index 783609e5..e7f6d2e6 100644 --- a/lnbits/extensions/copilot/migrations.py +++ b/lnbits/extensions/copilot/migrations.py @@ -9,6 +9,7 @@ async def m001_initial(db): id TEXT NOT NULL PRIMARY KEY, user TEXT, title TEXT, + lnurl_toggle INTEGER, wallet TEXT, animation1 TEXT, animation2 TEXT, diff --git a/lnbits/extensions/copilot/models.py b/lnbits/extensions/copilot/models.py index 42ecff5d..1283c7ad 100644 --- a/lnbits/extensions/copilot/models.py +++ b/lnbits/extensions/copilot/models.py @@ -10,6 +10,7 @@ class Copilots(NamedTuple): id: str user: str title: str + lnurl_toggle: str wallet: str animation1: str animation2: str diff --git a/lnbits/extensions/copilot/templates/copilot/compose.html b/lnbits/extensions/copilot/templates/copilot/compose.html index 7c4a21f4..7017d137 100644 --- a/lnbits/extensions/copilot/templates/copilot/compose.html +++ b/lnbits/extensions/copilot/templates/copilot/compose.html @@ -16,6 +16,7 @@