From 674dc0f7fca096e9ae83658ad0dc10f763fac1ff Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 08:59:17 -0400 Subject: [PATCH 01/26] Create .gitkeep --- lnbits/extensions/ngrok/.gitkeep | 1 + 1 file changed, 1 insertion(+) create mode 100644 lnbits/extensions/ngrok/.gitkeep diff --git a/lnbits/extensions/ngrok/.gitkeep b/lnbits/extensions/ngrok/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lnbits/extensions/ngrok/.gitkeep @@ -0,0 +1 @@ + From bb9299b3b2992e021de9e5c02faa4f94c4760a07 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:05:48 -0400 Subject: [PATCH 02/26] Add files via upload --- lnbits/extensions/ngrok/LICENSE | 121 ++++++++++++++++++++++++++ lnbits/extensions/ngrok/README.md | 20 +++++ lnbits/extensions/ngrok/__init__.py | 12 +++ lnbits/extensions/ngrok/config.json | 6 ++ lnbits/extensions/ngrok/migrations.py | 11 +++ lnbits/extensions/ngrok/models.py | 11 +++ lnbits/extensions/ngrok/views.py | 32 +++++++ lnbits/extensions/ngrok/views_api.py | 15 ++++ 8 files changed, 228 insertions(+) create mode 100644 lnbits/extensions/ngrok/LICENSE create mode 100644 lnbits/extensions/ngrok/README.md create mode 100644 lnbits/extensions/ngrok/__init__.py create mode 100644 lnbits/extensions/ngrok/config.json create mode 100644 lnbits/extensions/ngrok/migrations.py create mode 100644 lnbits/extensions/ngrok/models.py create mode 100644 lnbits/extensions/ngrok/views.py create mode 100644 lnbits/extensions/ngrok/views_api.py diff --git a/lnbits/extensions/ngrok/LICENSE b/lnbits/extensions/ngrok/LICENSE new file mode 100644 index 00000000..0e259d42 --- /dev/null +++ b/lnbits/extensions/ngrok/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/lnbits/extensions/ngrok/README.md b/lnbits/extensions/ngrok/README.md new file mode 100644 index 00000000..73f9b631 --- /dev/null +++ b/lnbits/extensions/ngrok/README.md @@ -0,0 +1,20 @@ +

Free Tunnel

+

Serve lnbits over https for free using ngrok

+ + + +

How it works

+ +When enabled, Free Tunnel creates a tunnel to ngrok with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working. + +

Installation

+ +Check the Extensions page on your instance of lnbits. If you have copy of lnbits with Free Tunnel as one of the built in extensions, click Enable -- that's the only thing you need to do to install it. + +If your copy of lnbits does not have Free Tunnel as one of the built in extensions, stop lnbits, create go into your lnbits folder, and run this command: ./venv/bin/pip install pyngrok. Then go into the lnbits subdirectory and the extensions subdirectory within that. (So lnbits > lnbits > extensions.) Create a new subdirectory in there called freetunnel, download this repository as a zip file, and unzip it in the freetunnel directory. If your unzipper creates a new "freetunnel" subdirectory, take everything out of there and put it in the freetunnel directory you created. Then go back to the top level lnbits directory and run these commands: + +``` +./venv/bin/quart assets +./venv/bin/quart migrate +./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()' +``` diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py new file mode 100644 index 00000000..d0afa73a --- /dev/null +++ b/lnbits/extensions/ngrok/__init__.py @@ -0,0 +1,12 @@ +from quart import Blueprint +from lnbits.db import Database + +db = Database("ext_freetunnel") + +freetunnel_ext: Blueprint = Blueprint( + "freetunnel", __name__, static_folder="static", template_folder="templates" +) + + +from .views_api import * # noqa +from .views import * # noqa diff --git a/lnbits/extensions/ngrok/config.json b/lnbits/extensions/ngrok/config.json new file mode 100644 index 00000000..1f0bf410 --- /dev/null +++ b/lnbits/extensions/ngrok/config.json @@ -0,0 +1,6 @@ +{ + "name": "Free tunnel", + "short_description": "Serve lnbits over https for free using ngrok", + "icon": "trip_origin", + "contributors": ["supertestnet"] +} diff --git a/lnbits/extensions/ngrok/migrations.py b/lnbits/extensions/ngrok/migrations.py new file mode 100644 index 00000000..aca4a27e --- /dev/null +++ b/lnbits/extensions/ngrok/migrations.py @@ -0,0 +1,11 @@ +# async def m001_initial(db): + +# await db.execute( +# """ +# CREATE TABLE IF NOT EXISTS example ( +# id TEXT PRIMARY KEY, +# wallet TEXT NOT NULL, +# time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now')) +# ); +# """ +# ) diff --git a/lnbits/extensions/ngrok/models.py b/lnbits/extensions/ngrok/models.py new file mode 100644 index 00000000..be523233 --- /dev/null +++ b/lnbits/extensions/ngrok/models.py @@ -0,0 +1,11 @@ +# from sqlite3 import Row +# from typing import NamedTuple + + +# class Example(NamedTuple): +# id: str +# wallet: str +# +# @classmethod +# def from_row(cls, row: Row) -> "Example": +# return cls(**dict(row)) diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py new file mode 100644 index 00000000..60ed0b17 --- /dev/null +++ b/lnbits/extensions/ngrok/views.py @@ -0,0 +1,32 @@ +from quart import g, render_template + +from lnbits.decorators import check_user_exists, validate_uuids + +from pyngrok import conf, ngrok + +def log_event_callback(log): + string = str(log) + string2 = string[string.find('url="https'):string.find('url="https')+40] + if string2: + string3 = string2 + string4 = string3[4:] + global string5 + string5 = string4.replace( '"', '' ) + +conf.get_default().log_event_callback = log_event_callback + +ngrok_tunnel = ngrok.connect(5000) + +from . import freetunnel_ext + +@freetunnel_ext.route("/") +@validate_uuids(["usr"], required=True) +@check_user_exists() + +async def index(): +# row = await db.fetchone("SELECT * FROM ngrok") + +# return row +# return "Access and use your lnbits instance here: " + string5 +# return Ngrok.from_row(row) if row else None + return await render_template("freetunnel/index.html", ngrok=string5) diff --git a/lnbits/extensions/ngrok/views_api.py b/lnbits/extensions/ngrok/views_api.py new file mode 100644 index 00000000..463f91d4 --- /dev/null +++ b/lnbits/extensions/ngrok/views_api.py @@ -0,0 +1,15 @@ +# views_api.py is for you API endpoints that could be hit by another service + +# add your dependencies here + +import pyngrok + +# import json +# import httpx +# (use httpx just like requests, except instead of response.ok there's only the +# response.is_error that is its inverse) + +from quart import jsonify +from http import HTTPStatus + +from . import freetunnel_ext From b53db465c0e7236c819605a48dfa1d4d695131ae Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:06:40 -0400 Subject: [PATCH 03/26] Update README.md --- lnbits/extensions/ngrok/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/ngrok/README.md b/lnbits/extensions/ngrok/README.md index 73f9b631..0d085cfb 100644 --- a/lnbits/extensions/ngrok/README.md +++ b/lnbits/extensions/ngrok/README.md @@ -1,17 +1,17 @@ -

Free Tunnel

+

Ngrok

Serve lnbits over https for free using ngrok

How it works

-When enabled, Free Tunnel creates a tunnel to ngrok with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working. +When enabled, ngrok creates a tunnel to ngrok with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working.

Installation

-Check the Extensions page on your instance of lnbits. If you have copy of lnbits with Free Tunnel as one of the built in extensions, click Enable -- that's the only thing you need to do to install it. +Check the Extensions page on your instance of lnbits. If you have copy of lnbits with ngrok as one of the built in extensions, click Enable -- that's the only thing you need to do to install it. -If your copy of lnbits does not have Free Tunnel as one of the built in extensions, stop lnbits, create go into your lnbits folder, and run this command: ./venv/bin/pip install pyngrok. Then go into the lnbits subdirectory and the extensions subdirectory within that. (So lnbits > lnbits > extensions.) Create a new subdirectory in there called freetunnel, download this repository as a zip file, and unzip it in the freetunnel directory. If your unzipper creates a new "freetunnel" subdirectory, take everything out of there and put it in the freetunnel directory you created. Then go back to the top level lnbits directory and run these commands: +If your copy of lnbits does not have ngrok as one of the built in extensions, stop lnbits, create go into your lnbits folder, and run this command: ./venv/bin/pip install pyngrok. Then go into the lnbits subdirectory and the extensions subdirectory within that. (So lnbits > lnbits > extensions.) Create a new subdirectory in there called freetunnel, download this repository as a zip file, and unzip it in the freetunnel directory. If your unzipper creates a new "freetunnel" subdirectory, take everything out of there and put it in the freetunnel directory you created. Then go back to the top level lnbits directory and run these commands: ``` ./venv/bin/quart assets From 10ecaf5d2439bec84498b65be7cafb85cef983e6 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:07:02 -0400 Subject: [PATCH 04/26] Update README.md --- lnbits/extensions/ngrok/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/ngrok/README.md b/lnbits/extensions/ngrok/README.md index 0d085cfb..666f95bc 100644 --- a/lnbits/extensions/ngrok/README.md +++ b/lnbits/extensions/ngrok/README.md @@ -5,7 +5,7 @@

How it works

-When enabled, ngrok creates a tunnel to ngrok with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working. +When enabled, ngrok creates a tunnel to ngrok.io with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working.

Installation

From e559ede16ca170f618dc5faae280d51bc22274ef Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:07:37 -0400 Subject: [PATCH 05/26] Create .gitkeep --- lnbits/extensions/ngrok/pycache/.gitkeep | 1 + 1 file changed, 1 insertion(+) create mode 100644 lnbits/extensions/ngrok/pycache/.gitkeep diff --git a/lnbits/extensions/ngrok/pycache/.gitkeep b/lnbits/extensions/ngrok/pycache/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lnbits/extensions/ngrok/pycache/.gitkeep @@ -0,0 +1 @@ + From b2a337fb0b44291d0edc81fbd50b4b1dda1c98b3 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:08:04 -0400 Subject: [PATCH 06/26] Delete lnbits/extensions/ngrok/pycache directory --- lnbits/extensions/ngrok/pycache/.gitkeep | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lnbits/extensions/ngrok/pycache/.gitkeep diff --git a/lnbits/extensions/ngrok/pycache/.gitkeep b/lnbits/extensions/ngrok/pycache/.gitkeep deleted file mode 100644 index 8b137891..00000000 --- a/lnbits/extensions/ngrok/pycache/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - From 541f655f4f8e416eda8cade3e15c622a3ba6de38 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:08:21 -0400 Subject: [PATCH 07/26] Create .gitkeep --- lnbits/extensions/ngrok/__pycache__/.gitkeep | 1 + 1 file changed, 1 insertion(+) create mode 100644 lnbits/extensions/ngrok/__pycache__/.gitkeep diff --git a/lnbits/extensions/ngrok/__pycache__/.gitkeep b/lnbits/extensions/ngrok/__pycache__/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lnbits/extensions/ngrok/__pycache__/.gitkeep @@ -0,0 +1 @@ + From c5ed8e0391d9ec216209359c742bf5806435399d Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:09:08 -0400 Subject: [PATCH 08/26] Create index.html --- .../ngrok/templates/ngrok/index.html | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lnbits/extensions/ngrok/templates/ngrok/index.html diff --git a/lnbits/extensions/ngrok/templates/ngrok/index.html b/lnbits/extensions/ngrok/templates/ngrok/index.html new file mode 100644 index 00000000..2216777a --- /dev/null +++ b/lnbits/extensions/ngrok/templates/ngrok/index.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} + + +
Access this lnbits instance at the following url
+ +

{{ ngrok }}

+

Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working.

+
+
+{% endblock %} {% block scripts %} {{ window_vars(user) }} + +{% endblock %} From ba364f15059fd6add7145ad14c1aed5ea865e15e Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:09:35 -0400 Subject: [PATCH 09/26] Update views.py --- lnbits/extensions/ngrok/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 60ed0b17..7d2d89e0 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -17,9 +17,9 @@ conf.get_default().log_event_callback = log_event_callback ngrok_tunnel = ngrok.connect(5000) -from . import freetunnel_ext +from . import ngrok_ext -@freetunnel_ext.route("/") +@ngrok_ext.route("/") @validate_uuids(["usr"], required=True) @check_user_exists() @@ -29,4 +29,4 @@ async def index(): # return row # return "Access and use your lnbits instance here: " + string5 # return Ngrok.from_row(row) if row else None - return await render_template("freetunnel/index.html", ngrok=string5) + return await render_template("ngrok/index.html", ngrok=string5) From 171247853c2dd9d3bebbd279278637520d41d03f Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:09:54 -0400 Subject: [PATCH 10/26] Update views_api.py --- lnbits/extensions/ngrok/views_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/ngrok/views_api.py b/lnbits/extensions/ngrok/views_api.py index 463f91d4..2952eb23 100644 --- a/lnbits/extensions/ngrok/views_api.py +++ b/lnbits/extensions/ngrok/views_api.py @@ -12,4 +12,4 @@ import pyngrok from quart import jsonify from http import HTTPStatus -from . import freetunnel_ext +from . import ngrok_ext From 24b20a5b6cd323478b4cfe09234973b1359e31d9 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:10:21 -0400 Subject: [PATCH 11/26] Update config.json --- lnbits/extensions/ngrok/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/ngrok/config.json b/lnbits/extensions/ngrok/config.json index 1f0bf410..58e9ff8e 100644 --- a/lnbits/extensions/ngrok/config.json +++ b/lnbits/extensions/ngrok/config.json @@ -1,5 +1,5 @@ { - "name": "Free tunnel", + "name": "Ngrok", "short_description": "Serve lnbits over https for free using ngrok", "icon": "trip_origin", "contributors": ["supertestnet"] From a9c5bb93c38598d97b5ce5d4ff2607133019ce55 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:10:46 -0400 Subject: [PATCH 12/26] Update __init__.py --- lnbits/extensions/ngrok/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index d0afa73a..39b61ab4 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -1,10 +1,10 @@ from quart import Blueprint from lnbits.db import Database -db = Database("ext_freetunnel") +db = Database("ext_ngrok") freetunnel_ext: Blueprint = Blueprint( - "freetunnel", __name__, static_folder="static", template_folder="templates" + "ngrok", __name__, static_folder="static", template_folder="templates" ) From 117ae1aec355a011e9a8322851b3c677b1a0bc66 Mon Sep 17 00:00:00 2001 From: supertestnet <58400631+supertestnet@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:18:22 -0400 Subject: [PATCH 13/26] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 5e10e7cd..af1b4938 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,6 +27,7 @@ marshmallow==3.11.1 outcome==1.1.0 priority==1.3.0 pydantic==1.8.1 +pyngrok==5.0.5 pypng==0.0.20 pyqrcode==1.2.1 pyscss==1.3.7 From 8619da29cf7ebe90445841c30ab7e8caa27402ca Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:00:08 +0100 Subject: [PATCH 14/26] fixed bug --- lnbits/extensions/ngrok/__init__.py | 6 +- .../ngrok/templates/ngrok/index.html | 64 +++++++++++-------- lnbits/extensions/ngrok/views.py | 3 +- lnbits/extensions/ngrok/views_api.py | 15 ----- 4 files changed, 40 insertions(+), 48 deletions(-) delete mode 100644 lnbits/extensions/ngrok/views_api.py diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 39b61ab4..29d63ff8 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -3,10 +3,8 @@ from lnbits.db import Database db = Database("ext_ngrok") -freetunnel_ext: Blueprint = Blueprint( +ngrok_ext: Blueprint = Blueprint( "ngrok", __name__, static_folder="static", template_folder="templates" ) - -from .views_api import * # noqa -from .views import * # noqa +from .views import * # noqa \ No newline at end of file diff --git a/lnbits/extensions/ngrok/templates/ngrok/index.html b/lnbits/extensions/ngrok/templates/ngrok/index.html index 2216777a..d41d317b 100644 --- a/lnbits/extensions/ngrok/templates/ngrok/index.html +++ b/lnbits/extensions/ngrok/templates/ngrok/index.html @@ -1,37 +1,47 @@ {% extends "base.html" %} {% from "macros.jinja" import window_vars with context %} {% block page %} - - -
Access this lnbits instance at the following url
- -

{{ ngrok }}

-

Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working.

-
-
+ +
+
+ + +
+ Access this lnbits instance at the following url +
+ +

{{ ngrok }}

+

+ Note that if you restart your device, your device will generate a new + url. If anyone is using your old one for wallets, lnurls, etc., + whatever they are doing will stop working. +

+
+
+
+ +
+ + +
Ngrok extension
+
+ + + + {% include "tpos/_api_docs.html" %} + + {% include "tpos/_tpos.html" %} + + +
+
+
+ {% endblock %} {% block scripts %} {{ window_vars(user) }} {% endblock %} diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 7d2d89e0..2d35286f 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -3,6 +3,7 @@ from quart import g, render_template from lnbits.decorators import check_user_exists, validate_uuids from pyngrok import conf, ngrok +from . import ngrok_ext def log_event_callback(log): string = str(log) @@ -17,8 +18,6 @@ conf.get_default().log_event_callback = log_event_callback ngrok_tunnel = ngrok.connect(5000) -from . import ngrok_ext - @ngrok_ext.route("/") @validate_uuids(["usr"], required=True) @check_user_exists() diff --git a/lnbits/extensions/ngrok/views_api.py b/lnbits/extensions/ngrok/views_api.py deleted file mode 100644 index 2952eb23..00000000 --- a/lnbits/extensions/ngrok/views_api.py +++ /dev/null @@ -1,15 +0,0 @@ -# views_api.py is for you API endpoints that could be hit by another service - -# add your dependencies here - -import pyngrok - -# import json -# import httpx -# (use httpx just like requests, except instead of response.ok there's only the -# response.is_error that is its inverse) - -from quart import jsonify -from http import HTTPStatus - -from . import ngrok_ext From 483c4b6586ce252d917aa7322b3b588091149d21 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:01:16 +0100 Subject: [PATCH 15/26] ran black --- lnbits/extensions/ngrok/__init__.py | 2 +- lnbits/extensions/ngrok/views.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 29d63ff8..29622a9c 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -7,4 +7,4 @@ ngrok_ext: Blueprint = Blueprint( "ngrok", __name__, static_folder="static", template_folder="templates" ) -from .views import * # noqa \ No newline at end of file +from .views import * # noqa diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 2d35286f..016ace34 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -5,27 +5,29 @@ from lnbits.decorators import check_user_exists, validate_uuids from pyngrok import conf, ngrok from . import ngrok_ext + def log_event_callback(log): string = str(log) - string2 = string[string.find('url="https'):string.find('url="https')+40] + string2 = string[string.find('url="https') : string.find('url="https') + 40] if string2: string3 = string2 string4 = string3[4:] global string5 - string5 = string4.replace( '"', '' ) + string5 = string4.replace('"', "") + conf.get_default().log_event_callback = log_event_callback ngrok_tunnel = ngrok.connect(5000) + @ngrok_ext.route("/") @validate_uuids(["usr"], required=True) @check_user_exists() - async def index(): -# row = await db.fetchone("SELECT * FROM ngrok") + # row = await db.fetchone("SELECT * FROM ngrok") -# return row -# return "Access and use your lnbits instance here: " + string5 -# return Ngrok.from_row(row) if row else None + # return row + # return "Access and use your lnbits instance here: " + string5 + # return Ngrok.from_row(row) if row else None return await render_template("ngrok/index.html", ngrok=string5) From 64f72f90eb65a1c11de5637d04a81a0476bae557 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:05:17 +0100 Subject: [PATCH 16/26] Added creditation --- .../ngrok/templates/ngrok/index.html | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lnbits/extensions/ngrok/templates/ngrok/index.html b/lnbits/extensions/ngrok/templates/ngrok/index.html index d41d317b..7a9cc3c5 100644 --- a/lnbits/extensions/ngrok/templates/ngrok/index.html +++ b/lnbits/extensions/ngrok/templates/ngrok/index.html @@ -10,11 +10,6 @@

{{ ngrok }}

-

- Note that if you restart your device, your device will generate a new - url. If anyone is using your old one for wallets, lnurls, etc., - whatever they are doing will stop working. -

@@ -25,12 +20,21 @@
Ngrok extension
- - - {% include "tpos/_api_docs.html" %} - - {% include "tpos/_tpos.html" %} - + + +

+ Note that if you restart your device, your device will generate a + new url. If anyone is using your old one for wallets, lnurls, + etc., whatever they are doing will stop working. +

+ Created by + Supertestnet. +
+
From 7eba75c0a08a46d091d74203fb1d89c395d598ae Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:29:40 +0100 Subject: [PATCH 17/26] Deleted all the bits we dont need --- lnbits/extensions/ngrok/LICENSE | 121 ------------------ lnbits/extensions/ngrok/__init__.py | 2 +- lnbits/extensions/ngrok/migrations.py | 11 -- lnbits/extensions/ngrok/models.py | 11 -- .../ngrok/templates/ngrok/index.html | 10 +- lnbits/extensions/ngrok/views.py | 7 +- 6 files changed, 3 insertions(+), 159 deletions(-) delete mode 100644 lnbits/extensions/ngrok/LICENSE delete mode 100644 lnbits/extensions/ngrok/migrations.py delete mode 100644 lnbits/extensions/ngrok/models.py diff --git a/lnbits/extensions/ngrok/LICENSE b/lnbits/extensions/ngrok/LICENSE deleted file mode 100644 index 0e259d42..00000000 --- a/lnbits/extensions/ngrok/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 29622a9c..44b1c313 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -4,7 +4,7 @@ from lnbits.db import Database db = Database("ext_ngrok") ngrok_ext: Blueprint = Blueprint( - "ngrok", __name__, static_folder="static", template_folder="templates" + "ngrok", __name__, template_folder="templates" ) from .views import * # noqa diff --git a/lnbits/extensions/ngrok/migrations.py b/lnbits/extensions/ngrok/migrations.py deleted file mode 100644 index aca4a27e..00000000 --- a/lnbits/extensions/ngrok/migrations.py +++ /dev/null @@ -1,11 +0,0 @@ -# async def m001_initial(db): - -# await db.execute( -# """ -# CREATE TABLE IF NOT EXISTS example ( -# id TEXT PRIMARY KEY, -# wallet TEXT NOT NULL, -# time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now')) -# ); -# """ -# ) diff --git a/lnbits/extensions/ngrok/models.py b/lnbits/extensions/ngrok/models.py deleted file mode 100644 index be523233..00000000 --- a/lnbits/extensions/ngrok/models.py +++ /dev/null @@ -1,11 +0,0 @@ -# from sqlite3 import Row -# from typing import NamedTuple - - -# class Example(NamedTuple): -# id: str -# wallet: str -# -# @classmethod -# def from_row(cls, row: Row) -> "Example": -# return cls(**dict(row)) diff --git a/lnbits/extensions/ngrok/templates/ngrok/index.html b/lnbits/extensions/ngrok/templates/ngrok/index.html index 7a9cc3c5..78f0d95c 100644 --- a/lnbits/extensions/ngrok/templates/ngrok/index.html +++ b/lnbits/extensions/ngrok/templates/ngrok/index.html @@ -2,7 +2,7 @@ %} {% block page %}
-
+
@@ -40,12 +40,4 @@
-{% endblock %} {% block scripts %} {{ window_vars(user) }} - {% endblock %} diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 016ace34..04e79dac 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -25,9 +25,4 @@ ngrok_tunnel = ngrok.connect(5000) @validate_uuids(["usr"], required=True) @check_user_exists() async def index(): - # row = await db.fetchone("SELECT * FROM ngrok") - - # return row - # return "Access and use your lnbits instance here: " + string5 - # return Ngrok.from_row(row) if row else None - return await render_template("ngrok/index.html", ngrok=string5) + return await render_template("ngrok/index.html", ngrok=string5) \ No newline at end of file From 16b10d8b7c97f91d6f52f611a681b8e395933123 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:33:05 +0100 Subject: [PATCH 18/26] Maybe --- lnbits/extensions/ngrok/.gitkeep | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lnbits/extensions/ngrok/.gitkeep diff --git a/lnbits/extensions/ngrok/.gitkeep b/lnbits/extensions/ngrok/.gitkeep deleted file mode 100644 index 8b137891..00000000 --- a/lnbits/extensions/ngrok/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - From ad618c1a7bfdf683320d0d39fb94c142444ee084 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:47:53 +0100 Subject: [PATCH 19/26] woops fixed bug --- lnbits/extensions/ngrok/templates/ngrok/index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lnbits/extensions/ngrok/templates/ngrok/index.html b/lnbits/extensions/ngrok/templates/ngrok/index.html index 78f0d95c..3af4fa44 100644 --- a/lnbits/extensions/ngrok/templates/ngrok/index.html +++ b/lnbits/extensions/ngrok/templates/ngrok/index.html @@ -40,4 +40,14 @@
+{% endblock %}{% block scripts %} {{ window_vars(user) }} + {% endblock %} From 819fc43328c8a8e5af293bf14aed31a716020c48 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 15:50:40 +0100 Subject: [PATCH 20/26] removed db reference --- lnbits/extensions/ngrok/__init__.py | 3 --- lnbits/extensions/ngrok/views.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 44b1c313..99062173 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -1,7 +1,4 @@ from quart import Blueprint -from lnbits.db import Database - -db = Database("ext_ngrok") ngrok_ext: Blueprint = Blueprint( "ngrok", __name__, template_folder="templates" diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 04e79dac..83c746e5 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -5,7 +5,6 @@ from lnbits.decorators import check_user_exists, validate_uuids from pyngrok import conf, ngrok from . import ngrok_ext - def log_event_callback(log): string = str(log) string2 = string[string.find('url="https') : string.find('url="https') + 40] @@ -15,7 +14,6 @@ def log_event_callback(log): global string5 string5 = string4.replace('"', "") - conf.get_default().log_event_callback = log_event_callback ngrok_tunnel = ngrok.connect(5000) From 03f0df681b3045ed746633fbc589ef8b46dec51e Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:04:45 +0100 Subject: [PATCH 21/26] ran black --- lnbits/bolt11.py | 6 ++--- lnbits/extensions/bleskomat/crud.py | 15 ++++++++--- lnbits/extensions/captcha/crud.py | 4 ++- lnbits/extensions/diagonalley/crud.py | 29 ++++++++++++++++------ lnbits/extensions/diagonalley/views_api.py | 16 +++++++++--- lnbits/extensions/events/crud.py | 11 +++++--- lnbits/extensions/events/migrations.py | 12 ++++++--- lnbits/extensions/jukebox/tasks.py | 9 ++++--- lnbits/extensions/lnticket/crud.py | 8 ++++-- lnbits/extensions/lnticket/migrations.py | 20 +++++++++++---- lnbits/extensions/ngrok/__init__.py | 4 +-- lnbits/extensions/ngrok/views.py | 4 ++- lnbits/extensions/offlineshop/crud.py | 8 ++++-- lnbits/extensions/offlineshop/helpers.py | 4 +-- lnbits/extensions/paywall/crud.py | 4 ++- lnbits/extensions/splitpayments/crud.py | 8 ++++-- lnbits/extensions/subdomains/crud.py | 8 ++++-- lnbits/extensions/subdomains/migrations.py | 8 ++++-- lnbits/extensions/usermanager/crud.py | 16 +++++++++--- lnbits/extensions/withdraw/crud.py | 15 ++++++++--- lnbits/extensions/withdraw/migrations.py | 4 ++- 21 files changed, 152 insertions(+), 61 deletions(-) diff --git a/lnbits/bolt11.py b/lnbits/bolt11.py index 6acc6db7..b9f3270b 100644 --- a/lnbits/bolt11.py +++ b/lnbits/bolt11.py @@ -161,9 +161,9 @@ def _trim_to_bytes(barr): def _readable_scid(short_channel_id: int) -> str: return "{blockheight}x{transactionindex}x{outputindex}".format( - blockheight=((short_channel_id >> 40) & 0xFFFFFF), - transactionindex=((short_channel_id >> 16) & 0xFFFFFF), - outputindex=(short_channel_id & 0xFFFF), + blockheight=((short_channel_id >> 40) & 0xffffff), + transactionindex=((short_channel_id >> 16) & 0xffffff), + outputindex=(short_channel_id & 0xffff), ) diff --git a/lnbits/extensions/bleskomat/crud.py b/lnbits/extensions/bleskomat/crud.py index 11dcb49c..1cc44576 100644 --- a/lnbits/extensions/bleskomat/crud.py +++ b/lnbits/extensions/bleskomat/crud.py @@ -42,7 +42,9 @@ async def create_bleskomat( async def get_bleskomat(bleskomat_id: str) -> Optional[Bleskomat]: - row = await db.fetchone("SELECT * FROM bleskomat.bleskomats WHERE id = ?", (bleskomat_id,)) + row = await db.fetchone( + "SELECT * FROM bleskomat.bleskomats WHERE id = ?", (bleskomat_id,) + ) return Bleskomat(**row) if row else None @@ -66,9 +68,12 @@ async def get_bleskomats(wallet_ids: Union[str, List[str]]) -> List[Bleskomat]: async def update_bleskomat(bleskomat_id: str, **kwargs) -> Optional[Bleskomat]: q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()]) await db.execute( - f"UPDATE bleskomat.bleskomats SET {q} WHERE id = ?", (*kwargs.values(), bleskomat_id) + f"UPDATE bleskomat.bleskomats SET {q} WHERE id = ?", + (*kwargs.values(), bleskomat_id), + ) + row = await db.fetchone( + "SELECT * FROM bleskomat.bleskomats WHERE id = ?", (bleskomat_id,) ) - row = await db.fetchone("SELECT * FROM bleskomat.bleskomats WHERE id = ?", (bleskomat_id,)) return Bleskomat(**row) if row else None @@ -108,5 +113,7 @@ async def create_bleskomat_lnurl( async def get_bleskomat_lnurl(secret: str) -> Optional[BleskomatLnurl]: hash = generate_bleskomat_lnurl_hash(secret) - row = await db.fetchone("SELECT * FROM bleskomat.bleskomat_lnurls WHERE hash = ?", (hash,)) + row = await db.fetchone( + "SELECT * FROM bleskomat.bleskomat_lnurls WHERE hash = ?", (hash,) + ) return BleskomatLnurl(**row) if row else None diff --git a/lnbits/extensions/captcha/crud.py b/lnbits/extensions/captcha/crud.py index 17cbb4f5..43a0374e 100644 --- a/lnbits/extensions/captcha/crud.py +++ b/lnbits/extensions/captcha/crud.py @@ -30,7 +30,9 @@ async def create_captcha( async def get_captcha(captcha_id: str) -> Optional[Captcha]: - row = await db.fetchone("SELECT * FROM captcha.captchas WHERE id = ?", (captcha_id,)) + row = await db.fetchone( + "SELECT * FROM captcha.captchas WHERE id = ?", (captcha_id,) + ) return Captcha.from_row(row) if row else None diff --git a/lnbits/extensions/diagonalley/crud.py b/lnbits/extensions/diagonalley/crud.py index 33f020bf..971cd449 100644 --- a/lnbits/extensions/diagonalley/crud.py +++ b/lnbits/extensions/diagonalley/crud.py @@ -57,16 +57,21 @@ def update_diagonalleys_product(product_id: str, **kwargs) -> Optional[Indexers] with open_ext_db("diagonalley") as db: db.execute( - f"UPDATE diagonalley.products SET {q} WHERE id = ?", (*kwargs.values(), product_id) + f"UPDATE diagonalley.products SET {q} WHERE id = ?", + (*kwargs.values(), product_id), + ) + row = db.fetchone( + "SELECT * FROM diagonalley.products WHERE id = ?", (product_id,) ) - row = db.fetchone("SELECT * FROM diagonalley.products WHERE id = ?", (product_id,)) return get_diagonalleys_indexer(product_id) def get_diagonalleys_product(product_id: str) -> Optional[Products]: with open_ext_db("diagonalley") as db: - row = db.fetchone("SELECT * FROM diagonalley.products WHERE id = ?", (product_id,)) + row = db.fetchone( + "SELECT * FROM diagonalley.products WHERE id = ?", (product_id,) + ) return Products(**row) if row else None @@ -131,16 +136,21 @@ def update_diagonalleys_indexer(indexer_id: str, **kwargs) -> Optional[Indexers] with open_ext_db("diagonalley") as db: db.execute( - f"UPDATE diagonalley.indexers SET {q} WHERE id = ?", (*kwargs.values(), indexer_id) + f"UPDATE diagonalley.indexers SET {q} WHERE id = ?", + (*kwargs.values(), indexer_id), + ) + row = db.fetchone( + "SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,) ) - row = db.fetchone("SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,)) return get_diagonalleys_indexer(indexer_id) def get_diagonalleys_indexer(indexer_id: str) -> Optional[Indexers]: with open_ext_db("diagonalley") as db: - roww = db.fetchone("SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,)) + roww = db.fetchone( + "SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,) + ) try: x = httpx.get(roww["indexeraddress"] + "/" + roww["ratingkey"]) if x.status_code == 200: @@ -166,7 +176,9 @@ def get_diagonalleys_indexer(indexer_id: str) -> Optional[Indexers]: except: print("An exception occurred") with open_ext_db("diagonalley") as db: - row = db.fetchone("SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,)) + row = db.fetchone( + "SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,) + ) return Indexers(**row) if row else None @@ -285,7 +297,8 @@ def get_diagonalleys_orders(wallet_ids: Union[str, List[str]]) -> List[Orders]: ), ) rows = db.fetchall( - f"SELECT * FROM diagonalley.orders WHERE wallet IN ({q})", (*wallet_ids,) + f"SELECT * FROM diagonalley.orders WHERE wallet IN ({q})", + (*wallet_ids,), ) return [Orders(**row) for row in rows] diff --git a/lnbits/extensions/diagonalley/views_api.py b/lnbits/extensions/diagonalley/views_api.py index 07aad712..71a2eca6 100644 --- a/lnbits/extensions/diagonalley/views_api.py +++ b/lnbits/extensions/diagonalley/views_api.py @@ -250,7 +250,9 @@ async def api_diagonalleys_order_shipped(order_id): order_id, ), ) - order = db.fetchone("SELECT * FROM diagonalley.orders WHERE id = ?", (order_id,)) + order = db.fetchone( + "SELECT * FROM diagonalley.orders WHERE id = ?", (order_id,) + ) return ( jsonify( @@ -268,12 +270,16 @@ async def api_diagonalleys_order_shipped(order_id): ) async def api_diagonalleys_stall_products(indexer_id): with open_ext_db("diagonalley") as db: - rows = db.fetchone("SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,)) + rows = db.fetchone( + "SELECT * FROM diagonalley.indexers WHERE id = ?", (indexer_id,) + ) print(rows[1]) if not rows: return jsonify({"message": "Indexer does not exist."}), HTTPStatus.NOT_FOUND - products = db.fetchone("SELECT * FROM diagonalley.products WHERE wallet = ?", (rows[1],)) + products = db.fetchone( + "SELECT * FROM diagonalley.products WHERE wallet = ?", (rows[1],) + ) if not products: return jsonify({"message": "No products"}), HTTPStatus.NOT_FOUND @@ -293,7 +299,9 @@ async def api_diagonalleys_stall_products(indexer_id): ) async def api_diagonalleys_stall_checkshipped(checking_id): with open_ext_db("diagonalley") as db: - rows = db.fetchone("SELECT * FROM diagonalley.orders WHERE invoiceid = ?", (checking_id,)) + rows = db.fetchone( + "SELECT * FROM diagonalley.orders WHERE invoiceid = ?", (checking_id,) + ) return jsonify({"shipped": rows["shipped"]}), HTTPStatus.OK diff --git a/lnbits/extensions/events/crud.py b/lnbits/extensions/events/crud.py index f7839b93..dece8e6d 100644 --- a/lnbits/extensions/events/crud.py +++ b/lnbits/extensions/events/crud.py @@ -151,13 +151,18 @@ async def delete_event(event_id: str) -> None: async def get_event_tickets(event_id: str, wallet_id: str) -> List[Tickets]: rows = await db.fetchall( - "SELECT * FROM events.ticket WHERE wallet = ? AND event = ?", (wallet_id, event_id) + "SELECT * FROM events.ticket WHERE wallet = ? AND event = ?", + (wallet_id, event_id), ) return [Tickets(**row) for row in rows] async def reg_ticket(ticket_id: str) -> List[Tickets]: - await db.execute("UPDATE events.ticket SET registered = ? WHERE id = ?", (True, ticket_id)) + await db.execute( + "UPDATE events.ticket SET registered = ? WHERE id = ?", (True, ticket_id) + ) ticket = await db.fetchone("SELECT * FROM events.ticket WHERE id = ?", (ticket_id,)) - rows = await db.fetchall("SELECT * FROM events.ticket WHERE event = ?", (ticket[1],)) + rows = await db.fetchall( + "SELECT * FROM events.ticket WHERE event = ?", (ticket[1],) + ) return [Tickets(**row) for row in rows] diff --git a/lnbits/extensions/events/migrations.py b/lnbits/extensions/events/migrations.py index ae4e45f7..d8f3d94e 100644 --- a/lnbits/extensions/events/migrations.py +++ b/lnbits/extensions/events/migrations.py @@ -13,7 +13,9 @@ async def m001_initial(db): amount_tickets INTEGER NOT NULL, price_per_ticket INTEGER NOT NULL, sold INTEGER NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) @@ -27,7 +29,9 @@ async def m001_initial(db): name TEXT NOT NULL, email TEXT NOT NULL, registered BOOLEAN NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) @@ -45,7 +49,9 @@ async def m002_changed(db): email TEXT NOT NULL, registered BOOLEAN NOT NULL, paid BOOLEAN NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) diff --git a/lnbits/extensions/jukebox/tasks.py b/lnbits/extensions/jukebox/tasks.py index 7c902937..65fca93d 100644 --- a/lnbits/extensions/jukebox/tasks.py +++ b/lnbits/extensions/jukebox/tasks.py @@ -20,8 +20,9 @@ async def wait_for_paid_invoices(invoice_paid_chan: trio.MemoryReceiveChannel): async for payment in invoice_paid_chan: await on_invoice_paid(payment) + async def on_invoice_paid(payment: Payment) -> None: - if "jukebox" != payment.extra.get("tag"): - # not a jukebox invoice - return - await update_jukebox_payment(payment.payment_hash, paid=True) + if "jukebox" != payment.extra.get("tag"): + # not a jukebox invoice + return + await update_jukebox_payment(payment.payment_hash, paid=True) diff --git a/lnbits/extensions/lnticket/crud.py b/lnbits/extensions/lnticket/crud.py index e7bf5262..45be7124 100644 --- a/lnbits/extensions/lnticket/crud.py +++ b/lnbits/extensions/lnticket/crud.py @@ -30,7 +30,9 @@ async def create_ticket( async def set_ticket_paid(payment_hash: str) -> Tickets: - row = await db.fetchone("SELECT * FROM lnticket.ticket WHERE id = ?", (payment_hash,)) + row = await db.fetchone( + "SELECT * FROM lnticket.ticket WHERE id = ?", (payment_hash,) + ) if row[7] == False: await db.execute( """ @@ -124,7 +126,9 @@ async def create_form( async def update_form(form_id: str, **kwargs) -> Forms: q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()]) - await db.execute(f"UPDATE lnticket.form SET {q} WHERE id = ?", (*kwargs.values(), form_id)) + await db.execute( + f"UPDATE lnticket.form SET {q} WHERE id = ?", (*kwargs.values(), form_id) + ) row = await db.fetchone("SELECT * FROM lnticket.form WHERE id = ?", (form_id,)) assert row, "Newly updated form couldn't be retrieved" return Forms(**row) diff --git a/lnbits/extensions/lnticket/migrations.py b/lnbits/extensions/lnticket/migrations.py index c2c2d275..82d5f3b8 100644 --- a/lnbits/extensions/lnticket/migrations.py +++ b/lnbits/extensions/lnticket/migrations.py @@ -9,7 +9,9 @@ async def m001_initial(db): description TEXT NOT NULL, costpword INTEGER NOT NULL, amountmade INTEGER NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) @@ -24,7 +26,9 @@ async def m001_initial(db): name TEXT NOT NULL, wallet TEXT NOT NULL, sats INTEGER NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) @@ -43,12 +47,16 @@ async def m002_changed(db): wallet TEXT NOT NULL, sats INTEGER NOT NULL, paid BOOLEAN NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) - for row in [list(row) for row in await db.fetchall("SELECT * FROM lnticket.tickets")]: + for row in [ + list(row) for row in await db.fetchall("SELECT * FROM lnticket.tickets") + ]: usescsv = "" for i in range(row[5]): @@ -97,7 +105,9 @@ async def m003_changed(db): description TEXT NOT NULL, costpword INTEGER NOT NULL, amountmade INTEGER NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 99062173..26490057 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -1,7 +1,5 @@ from quart import Blueprint -ngrok_ext: Blueprint = Blueprint( - "ngrok", __name__, template_folder="templates" -) +ngrok_ext: Blueprint = Blueprint("ngrok", __name__, template_folder="templates") from .views import * # noqa diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index 83c746e5..a78b2bcf 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -5,6 +5,7 @@ from lnbits.decorators import check_user_exists, validate_uuids from pyngrok import conf, ngrok from . import ngrok_ext + def log_event_callback(log): string = str(log) string2 = string[string.find('url="https') : string.find('url="https') + 40] @@ -14,6 +15,7 @@ def log_event_callback(log): global string5 string5 = string4.replace('"', "") + conf.get_default().log_event_callback = log_event_callback ngrok_tunnel = ngrok.connect(5000) @@ -23,4 +25,4 @@ ngrok_tunnel = ngrok.connect(5000) @validate_uuids(["usr"], required=True) @check_user_exists() async def index(): - return await render_template("ngrok/index.html", ngrok=string5) \ No newline at end of file + return await render_template("ngrok/index.html", ngrok=string5) diff --git a/lnbits/extensions/offlineshop/crud.py b/lnbits/extensions/offlineshop/crud.py index eb19c939..0168536b 100644 --- a/lnbits/extensions/offlineshop/crud.py +++ b/lnbits/extensions/offlineshop/crud.py @@ -22,7 +22,9 @@ async def get_shop(id: int) -> Optional[Shop]: async def get_or_create_shop_by_wallet(wallet: str) -> Optional[Shop]: - row = await db.fetchone("SELECT * FROM offlineshop.shops WHERE wallet = ?", (wallet,)) + row = await db.fetchone( + "SELECT * FROM offlineshop.shops WHERE wallet = ?", (wallet,) + ) if not row: # create on the fly @@ -83,7 +85,9 @@ async def update_item( async def get_item(id: int) -> Optional[Item]: - row = await db.fetchone("SELECT * FROM offlineshop.items WHERE id = ? LIMIT 1", (id,)) + row = await db.fetchone( + "SELECT * FROM offlineshop.items WHERE id = ? LIMIT 1", (id,) + ) return Item(**dict(row)) if row else None diff --git a/lnbits/extensions/offlineshop/helpers.py b/lnbits/extensions/offlineshop/helpers.py index 6b56cf55..db2c19cc 100644 --- a/lnbits/extensions/offlineshop/helpers.py +++ b/lnbits/extensions/offlineshop/helpers.py @@ -8,8 +8,8 @@ def hotp(key, counter, digits=6, digest="sha1"): key = base64.b32decode(key.upper() + "=" * ((8 - len(key)) % 8)) counter = struct.pack(">Q", counter) mac = hmac.new(key, counter, digest).digest() - offset = mac[-1] & 0x0F - binary = struct.unpack(">L", mac[offset : offset + 4])[0] & 0x7FFFFFFF + offset = mac[-1] & 0x0f + binary = struct.unpack(">L", mac[offset : offset + 4])[0] & 0x7fffffff return str(binary)[-digits:].zfill(digits) diff --git a/lnbits/extensions/paywall/crud.py b/lnbits/extensions/paywall/crud.py index 758d6a04..c13aba43 100644 --- a/lnbits/extensions/paywall/crud.py +++ b/lnbits/extensions/paywall/crud.py @@ -30,7 +30,9 @@ async def create_paywall( async def get_paywall(paywall_id: str) -> Optional[Paywall]: - row = await db.fetchone("SELECT * FROM paywall.paywalls WHERE id = ?", (paywall_id,)) + row = await db.fetchone( + "SELECT * FROM paywall.paywalls WHERE id = ?", (paywall_id,) + ) return Paywall.from_row(row) if row else None diff --git a/lnbits/extensions/splitpayments/crud.py b/lnbits/extensions/splitpayments/crud.py index 10549930..ef10add4 100644 --- a/lnbits/extensions/splitpayments/crud.py +++ b/lnbits/extensions/splitpayments/crud.py @@ -5,13 +5,17 @@ from .models import Target async def get_targets(source_wallet: str) -> List[Target]: - rows = await db.fetchall("SELECT * FROM splitpayments.targets WHERE source = ?", (source_wallet,)) + rows = await db.fetchall( + "SELECT * FROM splitpayments.targets WHERE source = ?", (source_wallet,) + ) return [Target(**dict(row)) for row in rows] async def set_targets(source_wallet: str, targets: List[Target]): async with db.connect() as conn: - await conn.execute("DELETE FROM splitpayments.targets WHERE source = ?", (source_wallet,)) + await conn.execute( + "DELETE FROM splitpayments.targets WHERE source = ?", (source_wallet,) + ) for target in targets: await conn.execute( """ diff --git a/lnbits/extensions/subdomains/crud.py b/lnbits/extensions/subdomains/crud.py index 0f98d8bc..08cb19eb 100644 --- a/lnbits/extensions/subdomains/crud.py +++ b/lnbits/extensions/subdomains/crud.py @@ -152,13 +152,17 @@ async def update_domain(domain_id: str, **kwargs) -> Domains: await db.execute( f"UPDATE subdomains.domain SET {q} WHERE id = ?", (*kwargs.values(), domain_id) ) - row = await db.fetchone("SELECT * FROM subdomains.domain WHERE id = ?", (domain_id,)) + row = await db.fetchone( + "SELECT * FROM subdomains.domain WHERE id = ?", (domain_id,) + ) assert row, "Newly updated domain couldn't be retrieved" return Domains(**row) async def get_domain(domain_id: str) -> Optional[Domains]: - row = await db.fetchone("SELECT * FROM subdomains.domain WHERE id = ?", (domain_id,)) + row = await db.fetchone( + "SELECT * FROM subdomains.domain WHERE id = ?", (domain_id,) + ) return Domains(**row) if row else None diff --git a/lnbits/extensions/subdomains/migrations.py b/lnbits/extensions/subdomains/migrations.py index 37474152..292d1f18 100644 --- a/lnbits/extensions/subdomains/migrations.py +++ b/lnbits/extensions/subdomains/migrations.py @@ -13,7 +13,9 @@ async def m001_initial(db): cost INTEGER NOT NULL, amountmade INTEGER NOT NULL, allowed_record_types TEXT NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) @@ -31,7 +33,9 @@ async def m001_initial(db): duration INTEGER NOT NULL, paid BOOLEAN NOT NULL, record_type TEXT NOT NULL, - time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ + time TIMESTAMP NOT NULL DEFAULT """ + + db.timestamp_now + + """ ); """ ) diff --git a/lnbits/extensions/usermanager/crud.py b/lnbits/extensions/usermanager/crud.py index 24899e32..a7854ad8 100644 --- a/lnbits/extensions/usermanager/crud.py +++ b/lnbits/extensions/usermanager/crud.py @@ -56,7 +56,9 @@ async def get_usermanager_user(user_id: str) -> Optional[Users]: async def get_usermanager_users(user_id: str) -> List[Users]: - rows = await db.fetchall("SELECT * FROM usermanager.users WHERE admin = ?", (user_id,)) + rows = await db.fetchall( + "SELECT * FROM usermanager.users WHERE admin = ?", (user_id,) + ) return [Users(**row) for row in rows] @@ -89,17 +91,23 @@ async def create_usermanager_wallet( async def get_usermanager_wallet(wallet_id: str) -> Optional[Wallets]: - row = await db.fetchone("SELECT * FROM usermanager.wallets WHERE id = ?", (wallet_id,)) + row = await db.fetchone( + "SELECT * FROM usermanager.wallets WHERE id = ?", (wallet_id,) + ) return Wallets(**row) if row else None async def get_usermanager_wallets(admin_id: str) -> Optional[Wallets]: - rows = await db.fetchall("SELECT * FROM usermanager.wallets WHERE admin = ?", (admin_id,)) + rows = await db.fetchall( + "SELECT * FROM usermanager.wallets WHERE admin = ?", (admin_id,) + ) return [Wallets(**row) for row in rows] async def get_usermanager_users_wallets(user_id: str) -> Optional[Wallets]: - rows = await db.fetchall("""SELECT * FROM usermanager.wallets WHERE "user" = ?""", (user_id,)) + rows = await db.fetchall( + """SELECT * FROM usermanager.wallets WHERE "user" = ?""", (user_id,) + ) return [Wallets(**row) for row in rows] diff --git a/lnbits/extensions/withdraw/crud.py b/lnbits/extensions/withdraw/crud.py index f161df74..1992e6ab 100644 --- a/lnbits/extensions/withdraw/crud.py +++ b/lnbits/extensions/withdraw/crud.py @@ -57,7 +57,9 @@ async def create_withdraw_link( async def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]: - row = await db.fetchone("SELECT * FROM withdraw.withdraw_link WHERE id = ?", (link_id,)) + row = await db.fetchone( + "SELECT * FROM withdraw.withdraw_link WHERE id = ?", (link_id,) + ) if not row: return None @@ -97,9 +99,12 @@ async def get_withdraw_links(wallet_ids: Union[str, List[str]]) -> List[Withdraw async def update_withdraw_link(link_id: str, **kwargs) -> Optional[WithdrawLink]: q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()]) await db.execute( - f"UPDATE withdraw.withdraw_link SET {q} WHERE id = ?", (*kwargs.values(), link_id) + f"UPDATE withdraw.withdraw_link SET {q} WHERE id = ?", + (*kwargs.values(), link_id), + ) + row = await db.fetchone( + "SELECT * FROM withdraw.withdraw_link WHERE id = ?", (link_id,) ) - row = await db.fetchone("SELECT * FROM withdraw.withdraw_link WHERE id = ?", (link_id,)) return WithdrawLink.from_row(row) if row else None @@ -134,7 +139,9 @@ async def create_hash_check( async def get_hash_check(the_hash: str, lnurl_id: str) -> Optional[HashCheck]: - rowid = await db.fetchone("SELECT * FROM withdraw.hash_check WHERE id = ?", (the_hash,)) + rowid = await db.fetchone( + "SELECT * FROM withdraw.hash_check WHERE id = ?", (the_hash,) + ) rowlnurl = await db.fetchone( "SELECT * FROM withdraw.hash_check WHERE lnurl_id = ?", (lnurl_id,) ) diff --git a/lnbits/extensions/withdraw/migrations.py b/lnbits/extensions/withdraw/migrations.py index beff4c99..1a13aa6d 100644 --- a/lnbits/extensions/withdraw/migrations.py +++ b/lnbits/extensions/withdraw/migrations.py @@ -47,7 +47,9 @@ async def m002_change_withdraw_table(db): """ ) - for row in [list(row) for row in await db.fetchall("SELECT * FROM withdraw.withdraw_links")]: + for row in [ + list(row) for row in await db.fetchall("SELECT * FROM withdraw.withdraw_links") + ]: usescsv = "" for i in range(row[5]): From 7a18a44948711a79555fe8e51cc9e36ce8a87198 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:12:07 +0100 Subject: [PATCH 22/26] needed migration file --- lnbits/extensions/ngrok/__init__.py | 3 +++ lnbits/extensions/ngrok/migrations.py | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 lnbits/extensions/ngrok/migrations.py diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 26490057..9dc07488 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -1,4 +1,7 @@ from quart import Blueprint +from lnbits.db import Database + +db = Database("ext_example") ngrok_ext: Blueprint = Blueprint("ngrok", __name__, template_folder="templates") diff --git a/lnbits/extensions/ngrok/migrations.py b/lnbits/extensions/ngrok/migrations.py new file mode 100644 index 00000000..f9b8b37d --- /dev/null +++ b/lnbits/extensions/ngrok/migrations.py @@ -0,0 +1,11 @@ +# async def m001_initial(db): + +# await db.execute( +# """ +# CREATE TABLE example.example ( +# id TEXT PRIMARY KEY, +# wallet TEXT NOT NULL, +# time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ +# ); +# """ +# ) From 5003a89a48caa9f63cbf35b29b9f65a75d1cf54d Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:16:28 +0100 Subject: [PATCH 23/26] small fix --- lnbits/extensions/ngrok/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/ngrok/__init__.py b/lnbits/extensions/ngrok/__init__.py index 9dc07488..4933aa7f 100644 --- a/lnbits/extensions/ngrok/__init__.py +++ b/lnbits/extensions/ngrok/__init__.py @@ -1,7 +1,7 @@ from quart import Blueprint from lnbits.db import Database -db = Database("ext_example") +db = Database("ext_ngrok") ngrok_ext: Blueprint = Blueprint("ngrok", __name__, template_folder="templates") From 0e209845ede651017ab4405400067264776dfdf7 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:48:23 +0100 Subject: [PATCH 24/26] Sidebar back --- lnbits/extensions/ngrok/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/ngrok/views.py b/lnbits/extensions/ngrok/views.py index a78b2bcf..1ea5da32 100644 --- a/lnbits/extensions/ngrok/views.py +++ b/lnbits/extensions/ngrok/views.py @@ -25,4 +25,4 @@ ngrok_tunnel = ngrok.connect(5000) @validate_uuids(["usr"], required=True) @check_user_exists() async def index(): - return await render_template("ngrok/index.html", ngrok=string5) + return await render_template("ngrok/index.html", ngrok=string5, user=g.user) From e7ea390d1074b1ed71b0c80fc0a2407e8e6a306b Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:49:39 +0100 Subject: [PATCH 25/26] disabled in .env --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index f0e7c6e4..a18e07bd 100644 --- a/.env.example +++ b/.env.example @@ -17,7 +17,7 @@ LNBITS_DEFAULT_WALLET_NAME="LNbits wallet" LNBITS_DATA_FOLDER="./data" # LNBITS_DATABASE_URL="postgres://user:password@host:port/databasename" -LNBITS_DISABLED_EXTENSIONS="amilk" +LNBITS_DISABLED_EXTENSIONS="amilk, ngrok" LNBITS_FORCE_HTTPS=true LNBITS_SERVICE_FEE="0.0" From 0ea661babbf1b4251599380321b23fd7c8920fa6 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Sat, 3 Jul 2021 16:51:11 +0100 Subject: [PATCH 26/26] disabled ngrok --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index a18e07bd..6ca9a281 100644 --- a/.env.example +++ b/.env.example @@ -17,7 +17,7 @@ LNBITS_DEFAULT_WALLET_NAME="LNbits wallet" LNBITS_DATA_FOLDER="./data" # LNBITS_DATABASE_URL="postgres://user:password@host:port/databasename" -LNBITS_DISABLED_EXTENSIONS="amilk, ngrok" +LNBITS_DISABLED_EXTENSIONS="amilk,ngrok" LNBITS_FORCE_HTTPS=true LNBITS_SERVICE_FEE="0.0"