From 2d18153b1d40704ab569ae14826d1cafb04682ab Mon Sep 17 00:00:00 2001 From: Black Coffee Date: Wed, 28 Sep 2022 15:05:37 +0100 Subject: [PATCH] Added front end and work on db migrations and saving --- lnbits/Pipfile | 62 + lnbits/extensions/gerty/config.json | 2 +- lnbits/extensions/gerty/crud.py | 50 +- lnbits/extensions/gerty/migrations.py | 21 +- lnbits/extensions/gerty/models.py | 22 +- .../gerty/templates/gerty/index.html | 1262 +++++++++-------- 6 files changed, 841 insertions(+), 578 deletions(-) create mode 100644 lnbits/Pipfile diff --git a/lnbits/Pipfile b/lnbits/Pipfile new file mode 100644 index 00000000..3517399d --- /dev/null +++ b/lnbits/Pipfile @@ -0,0 +1,62 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +aiofiles = "==0.8.0" +anyio = "==3.6.1" +asyncio = "==3.4.3" +attrs = "==21.4.0" +bech32 = "==1.2.0" +bitstring = "==3.1.9" +cerberus = "==1.3.4" +certifi = "==2022.6.15" +cffi = "==1.15.0" +click = "==8.1.3" +ecdsa = "==0.18.0" +embit = "==0.5.0" +environs = "==9.5.0" +fastapi = "==0.79.0" +h11 = "==0.12.0" +httpcore = "==0.15.0" +httptools = "==0.4.0" +httpx = "==0.23.0" +idna = "==3.3" +jinja2 = "==3.0.1" +lnurl = "==0.3.6" +loguru = "==0.6.0" +markupsafe = "==2.1.1" +marshmallow = "==3.17.0" +outcome = "==1.2.0" +psycopg2-binary = "==2.9.3" +pycparser = "==2.21" +pycryptodomex = "==3.15.0" +pydantic = "==1.9.1" +pyngrok = "==5.1.0" +pyparsing = "==3.0.9" +pypng = "==0.20220715.0" +pyqrcode = "==1.2.1" +pyscss = "==1.4.0" +python-dotenv = "==0.20.0" +pyyaml = "==6.0" +represent = "==1.6.0.post0" +rfc3986 = "==1.5.0" +secp256k1 = "==0.14.0" +shortuuid = "==1.0.9" +six = "==1.16.0" +sniffio = "==1.2.0" +sqlalchemy-aio = "==0.17.0" +sqlalchemy = "==1.3.23" +sse-starlette = "==0.10.3" +starlette = "==0.19.1" +typing-extensions = "==4.3.0" +uvicorn = "==0.18.2" +uvloop = "==0.16.0" +watchfiles = "==0.16.0" +websockets = "==10.3" + +[dev-packages] + +[requires] +python_version = "3.9" diff --git a/lnbits/extensions/gerty/config.json b/lnbits/extensions/gerty/config.json index 158ac52a..a36437be 100644 --- a/lnbits/extensions/gerty/config.json +++ b/lnbits/extensions/gerty/config.json @@ -2,5 +2,5 @@ "name": "Gerty", "short_description": "Desktop bitcoin Assistant", "icon": "sentiment_satisfied", - "contributors": ["arcbtc"] + "contributors": ["arcbtc", "blackcoffeebtc"] } diff --git a/lnbits/extensions/gerty/crud.py b/lnbits/extensions/gerty/crud.py index 9eeb1a4a..fee57dba 100644 --- a/lnbits/extensions/gerty/crud.py +++ b/lnbits/extensions/gerty/crud.py @@ -10,8 +10,33 @@ async def create_gerty(wallet_id: str, data: Gerty) -> Gerty: gerty_id = urlsafe_short_hash() await db.execute( """ - INSERT INTO gerty.gertys (id, name, wallet, lnbits_wallets, mempool_endpoint, sats_quote, exchange, onchain_stats, ln_stats) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO gerty.gertys ( + id, + name, + wallet, + lnbits_wallets, + mempool_endpoint, + exchange, + show_lnbits_wallets_balance, + show_sats_quote, + show_pieter_wuille_facts, + show_exchange_market_rate, + show_onchain_difficulty_epoch_progress, + show_onchain_difficulty_retarget_date, + show_onchain_difficulty_blocks_remaining, + show_onchain_difficulty_epoch_time_remaining, + show_onchain_mempool_recommended_fees, + show_onchain_mempool_number_of_tx, + show_mining_current_hash_rate, + show_mining_current_difficulty, + show_lightning_channel_count, + show_lightning_node_count, + show_lightning_tor_node_count, + show_lightning_clearnet_nodes, + show_lightning_unannounced_nodes, + show_lightning_average_channel_capacity + ) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( gerty_id, @@ -19,10 +44,25 @@ async def create_gerty(wallet_id: str, data: Gerty) -> Gerty: data.wallet, data.lnbits_wallets, data.mempool_endpoint, - data.sats_quote, data.exchange, - data.onchain_stats, - data.ln_stats, + data.show_lnbits_wallets_balance, + data.show_sats_quote, + data.show_pieter_wuille_facts, + data.show_exchange_market_rate, + data.show_onchain_difficulty_epoch_progress, + data.show_onchain_difficulty_retarget_date, + data.show_onchain_difficulty_blocks_remaining, + data.show_onchain_difficulty_epoch_time_remaining, + data.show_onchain_mempool_recommended_fees, + data.show_onchain_mempool_number_of_tx, + data.show_mining_current_hash_rate, + data.show_mining_current_difficulty, + data.show_lightning_channel_count, + data.show_lightning_node_count, + data.show_lightning_tor_node_count, + data.show_lightning_clearnet_nodes, + data.show_lightning_unannounced_nodes, + data.show_lightning_average_channel_capacity ), ) diff --git a/lnbits/extensions/gerty/migrations.py b/lnbits/extensions/gerty/migrations.py index d3bba79c..5e21495a 100644 --- a/lnbits/extensions/gerty/migrations.py +++ b/lnbits/extensions/gerty/migrations.py @@ -10,10 +10,25 @@ async def m001_initial(db): wallet TEXT NOT NULL, lnbits_wallets TEXT, mempool_endpoint TEXT, - sats_quote BOOL, exchange TEXT, - onchain_stats BOOL, - ln_stats BOOL + show_lnbits_wallets_balance BOOL, + show_sats_quote BOOL, + show_pieter_wuille_facts BOOL, + show_exchange_market_rate BOOL, + show_onchain_difficulty_epoch_progress BOOL, + show_onchain_difficulty_retarget_date BOOL, + show_onchain_difficulty_blocks_remaining BOOL, + show_onchain_difficulty_epoch_time_remaining BOOL, + show_onchain_mempool_recommended_fees BOOL, + show_onchain_mempool_number_of_tx BOOL, + show_mining_current_hash_rate BOOL, + show_mining_current_difficulty BOOL, + show_lightning_channel_count BOOL, + show_lightning_node_count BOOL, + show_lightning_tor_node_count BOOL, + show_lightning_clearnet_nodes BOOL, + show_lightning_unannounced_nodes BOOL, + show_lightning_average_channel_capacity BOOL ); """ ) \ No newline at end of file diff --git a/lnbits/extensions/gerty/models.py b/lnbits/extensions/gerty/models.py index c3590f03..bf3465d6 100644 --- a/lnbits/extensions/gerty/models.py +++ b/lnbits/extensions/gerty/models.py @@ -12,10 +12,26 @@ class Gerty(BaseModel): wallet: str lnbits_wallets: str = Query(None) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"} mempool_endpoint: str = Query(None) # Mempool endpoint to use - sats_quote: bool = Query(False) # Fetch Satoshi quotes exchange: str = Query(None) # BTC <-> Fiat exchange rate to pull ie "USD", in 0.0001 and sats - onchain_stats: bool = Query(False) # Onchain stats - ln_stats: bool = Query(False) # ln Sats + show_lnbits_wallets_balance: bool = Query(False) + show_sats_quote: bool = Query(False) + show_pieter_wuille_facts: bool = Query(False) + show_exchange_market_rate: bool = Query(False) + show_onchain_difficulty_epoch_progress: bool = Query(False) + show_onchain_difficulty_retarget_date: bool = Query(False) + show_onchain_difficulty_blocks_remaining: bool = Query(False) + show_onchain_difficulty_epoch_time_remaining: bool = Query(False) + show_onchain_mempool_recommended_fees: bool = Query(False) + show_onchain_mempool_number_of_tx: bool = Query(False) + show_mining_current_hash_rate: bool = Query(False) + show_mining_current_difficulty: bool = Query(False) + show_lightning_channel_count: bool = Query(False) + show_lightning_node_count: bool = Query(False) + show_lightning_tor_node_count: bool = Query(False) + show_lightning_clearnet_nodes: bool = Query(False) + show_lightning_unannounced_nodes: bool = Query(False) + show_lightning_average_channel_capacity: bool = Query(False) + @classmethod def from_row(cls, row: Row) -> "Gerty": diff --git a/lnbits/extensions/gerty/templates/gerty/index.html b/lnbits/extensions/gerty/templates/gerty/index.html index 7ba0e029..657b68a6 100644 --- a/lnbits/extensions/gerty/templates/gerty/index.html +++ b/lnbits/extensions/gerty/templates/gerty/index.html @@ -1,575 +1,705 @@ -{% extends "base.html" %} {% from "macros.jinja" import window_vars with context -%} {% block page %} -
-
- - - New Gerty - - - - -
-
-
Gerty
-
-
- Export to CSV -
+{% extends "base.html" %} {% from "macros.jinja" import window_vars with context %} {% block page %} +
+
+ + + New Gerty + + + + + +
+
+
Gerty
+
+
+ Export to CSV +
+
+ + {% raw %} + + + + {% endraw %} + +
+
- - {% raw %} - - - {% endraw %} - - - -
- -
- - -
{{SITE_TITLE}} Gerty extension
-
- - - - {% include "gerty/_api_docs.html" %} - - -
-
- - - - - - - Hit enter to add values - - Used for getting onchain/ln stats - Gets random quotes from satoshi - Gets Onchain Statistics - Gets Lightning-Network Statistics -
- Create Gerty - Update Gerty - Cancel +
+ + +
{{ SITE_TITLE }} Gerty extension
+
+ + + + {% include "gerty/_api_docs.html" %} + + +
- - - -
+ + + + + + + + Hit enter to add values + + + + Used for getting onchain/ln stats + + +

Use the toggles below to control what your Gerty will display

+ + + + + + Displays random quotes from Satoshi + + + Show accurate facts about Pieter Wuille + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Create Gerty + + Update Gerty + + Cancel + +
+
+
+
+
{% endblock %} {% block scripts %} {{ window_vars(user) }} - + }) + {% endblock %}