feat: make LNBITS_ADMIN_UI the default (#2726)

* feat: make LNBITS_ADMIN_UI the default
* fix create fake admin
This commit is contained in:
dni ⚡ 2024-10-01 11:36:22 +02:00 committed by GitHub
parent a28e334c5f
commit e85a78854e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 32 deletions

View file

@ -9,8 +9,8 @@
# configurations defined in `ReadOnlySettings` will still be read from the environment variables. # 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 # The rest of the settings will be stored in your database and you will be able to change them
# only through the Admin UI. # only through the Admin UI.
# Disable this to make LNbits use this config file again. # Disable this and clear `settings` table from database to make LNbits use this config file again.
LNBITS_ADMIN_UI=false LNBITS_ADMIN_UI=true
# Change theme # Change theme
LNBITS_SITE_TITLE="LNbits" LNBITS_SITE_TITLE="LNbits"

View file

@ -38,6 +38,9 @@ checkeditorconfig:
dev: dev:
poetry run lnbits --reload poetry run lnbits --reload
docker:
docker build -t lnbits/lnbits .
test-wallets: test-wallets:
LNBITS_DATA_FOLDER="./tests/data" \ LNBITS_DATA_FOLDER="./tests/data" \
LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \ LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \
@ -84,6 +87,7 @@ migration:
poetry run python tools/conv.py poetry run python tools/conv.py
openapi: openapi:
LNBITS_ADMIN_UI=False \
LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \ LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \
LNBITS_DATA_FOLDER="./tests/data" \ LNBITS_DATA_FOLDER="./tests/data" \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \

View file

@ -619,7 +619,7 @@ class ReadOnlySettings(
PersistenceSettings, PersistenceSettings,
SuperUserSettings, SuperUserSettings,
): ):
lnbits_admin_ui: bool = Field(default=False) lnbits_admin_ui: bool = Field(default=True)
@validator( @validator(
"lnbits_allowed_funding_sources", "lnbits_allowed_funding_sources",

View file

@ -21,58 +21,56 @@ conn = sqlite3.connect(file)
cursor = conn.cursor() cursor = conn.cursor()
old_account = cursor.execute( old_account = cursor.execute(
"SELECT * FROM accounts WHERE id = ?", (adminkey,) "SELECT * FROM accounts WHERE id = :id", {"id": adminkey}
).fetchone() ).fetchone()
if old_account: if old_account:
print("fake admin does already exist") print("fake admin does already exist")
sys.exit(1) 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 wallet_id = uuid4().hex
cursor.execute( cursor.execute(
""" """
INSERT INTO wallets (id, name, "user", adminkey, inkey) INSERT INTO wallets (id, name, "user", adminkey, inkey)
VALUES (?, ?, ?, ?, ?) VALUES (:wallet_id, :name, :user, :adminkey, :inkey)
""", """,
( {
wallet_id, "wallet_id": wallet_id,
"TEST WALLET", "name": "TEST WALLET",
adminkey, "user": adminkey,
adminkey, "adminkey": adminkey,
uuid4().hex, # invoice key is not important "inkey": uuid4().hex, # invoice key is not important
), },
) )
expiration_date = time.time() + 420 expiration_date = time.time() + 420
# 1 btc in sats # 1 btc in sats
amount = 100_000_000 amount = 100_000_000
internal_id = f"internal_{shortuuid.uuid()}" payment_hash = shortuuid.uuid()
internal_id = f"internal_{payment_hash}"
cursor.execute( cursor.execute(
""" """
INSERT INTO apipayments INSERT INTO apipayments
(wallet, checking_id, bolt11, hash, preimage, (wallet, checking_id, hash, amount, status, memo, fee, expiry, pending)
amount, status, memo, fee, extra, webhook, expiry, pending) VALUES
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (:wallet_id, :checking_id, :payment_hash, :amount,
:status, :memo, :fee, :expiry, :pending)
""", """,
( {
wallet_id, "wallet_id": wallet_id,
internal_id, "checking_id": internal_id,
"test_admin_internal", "payment_hash": payment_hash,
"test_admin_internal", "amount": amount * 1000,
None, "status": "success",
amount * 1000, "memo": "fake admin",
"success", "fee": 0,
"test_admin_internal", "expiry": expiration_date,
0, "pending": False,
None, },
"",
expiration_date,
False, # TODO: remove this in next release
),
) )
print(f"created test admin: {adminkey} with {amount} sats") print(f"created test admin: {adminkey} with {amount} sats")