From e85a78854ee63103617b81a5b0d25fe52341ae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 1 Oct 2024 11:36:22 +0200 Subject: [PATCH] feat: make LNBITS_ADMIN_UI the default (#2726) * feat: make LNBITS_ADMIN_UI the default * fix create fake admin --- .env.example | 4 +-- Makefile | 4 +++ lnbits/settings.py | 2 +- tools/create_fake_admin.py | 56 ++++++++++++++++++-------------------- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/.env.example b/.env.example index 1ce551c7b..25f32f8de 100644 --- a/.env.example +++ b/.env.example @@ -9,8 +9,8 @@ # configurations defined in `ReadOnlySettings` will still be read from the environment variables. # The rest of the settings will be stored in your database and you will be able to change them # only through the Admin UI. -# Disable this to make LNbits use this config file again. -LNBITS_ADMIN_UI=false +# Disable this and clear `settings` table from database to make LNbits use this config file again. +LNBITS_ADMIN_UI=true # Change theme LNBITS_SITE_TITLE="LNbits" diff --git a/Makefile b/Makefile index 1763604b8..b6052c01f 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,9 @@ checkeditorconfig: dev: poetry run lnbits --reload +docker: + docker build -t lnbits/lnbits . + test-wallets: LNBITS_DATA_FOLDER="./tests/data" \ LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \ @@ -84,6 +87,7 @@ migration: poetry run python tools/conv.py openapi: + LNBITS_ADMIN_UI=False \ LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \ LNBITS_DATA_FOLDER="./tests/data" \ PYTHONUNBUFFERED=1 \ diff --git a/lnbits/settings.py b/lnbits/settings.py index c55f88e04..f4aeb07cf 100644 --- a/lnbits/settings.py +++ b/lnbits/settings.py @@ -619,7 +619,7 @@ class ReadOnlySettings( PersistenceSettings, SuperUserSettings, ): - lnbits_admin_ui: bool = Field(default=False) + lnbits_admin_ui: bool = Field(default=True) @validator( "lnbits_allowed_funding_sources", diff --git a/tools/create_fake_admin.py b/tools/create_fake_admin.py index bd962cfe3..b76e28113 100644 --- a/tools/create_fake_admin.py +++ b/tools/create_fake_admin.py @@ -21,58 +21,56 @@ conn = sqlite3.connect(file) cursor = conn.cursor() old_account = cursor.execute( - "SELECT * FROM accounts WHERE id = ?", (adminkey,) + "SELECT * FROM accounts WHERE id = :id", {"id": adminkey} ).fetchone() if old_account: print("fake admin does already exist") sys.exit(1) -cursor.execute("INSERT INTO accounts (id) VALUES (?)", (adminkey,)) +cursor.execute("INSERT INTO accounts (id) VALUES (:adminkey)", {"adminkey": adminkey}) wallet_id = uuid4().hex cursor.execute( """ INSERT INTO wallets (id, name, "user", adminkey, inkey) - VALUES (?, ?, ?, ?, ?) + VALUES (:wallet_id, :name, :user, :adminkey, :inkey) """, - ( - wallet_id, - "TEST WALLET", - adminkey, - adminkey, - uuid4().hex, # invoice key is not important - ), + { + "wallet_id": wallet_id, + "name": "TEST WALLET", + "user": adminkey, + "adminkey": adminkey, + "inkey": uuid4().hex, # invoice key is not important + }, ) expiration_date = time.time() + 420 # 1 btc in sats amount = 100_000_000 -internal_id = f"internal_{shortuuid.uuid()}" +payment_hash = shortuuid.uuid() +internal_id = f"internal_{payment_hash}" cursor.execute( """ INSERT INTO apipayments - (wallet, checking_id, bolt11, hash, preimage, - amount, status, memo, fee, extra, webhook, expiry, pending) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + (wallet, checking_id, hash, amount, status, memo, fee, expiry, pending) + VALUES + (:wallet_id, :checking_id, :payment_hash, :amount, + :status, :memo, :fee, :expiry, :pending) """, - ( - wallet_id, - internal_id, - "test_admin_internal", - "test_admin_internal", - None, - amount * 1000, - "success", - "test_admin_internal", - 0, - None, - "", - expiration_date, - False, # TODO: remove this in next release - ), + { + "wallet_id": wallet_id, + "checking_id": internal_id, + "payment_hash": payment_hash, + "amount": amount * 1000, + "status": "success", + "memo": "fake admin", + "fee": 0, + "expiry": expiration_date, + "pending": False, + }, ) print(f"created test admin: {adminkey} with {amount} sats")