TEST: LNbits as fundingsource in regtest (#1402)
* lnbits funding source * add create_fake_user to workflow * change quotes in workflow ymal * not use interactive docker exec * update tools/create_fake_admin to not use lnbits imports * formatting Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
parent
36c881c4ce
commit
5a0b217d63
4 changed files with 125 additions and 3 deletions
80
tools/create_fake_admin.py
Normal file
80
tools/create_fake_admin.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# Python script to create a fake admin user for sqlite3,
|
||||
# for regtest setup as LNbits funding source
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
import time
|
||||
from uuid import uuid4
|
||||
|
||||
import shortuuid
|
||||
|
||||
adminkey = "d08a3313322a4514af75d488bcc27eee"
|
||||
sqfolder = "./data"
|
||||
|
||||
if not sqfolder or not os.path.isdir(sqfolder):
|
||||
print("missing LNBITS_DATA_FOLDER")
|
||||
sys.exit(1)
|
||||
|
||||
file = os.path.join(sqfolder, "database.sqlite3")
|
||||
conn = sqlite3.connect(file)
|
||||
cursor = conn.cursor()
|
||||
|
||||
old_account = cursor.execute(
|
||||
"SELECT * FROM accounts WHERE id = ?", (adminkey,)
|
||||
).fetchone()
|
||||
if old_account:
|
||||
print("fake admin does already exist")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
cursor.execute("INSERT INTO accounts (id) VALUES (?)", (adminkey,))
|
||||
|
||||
wallet_id = uuid4().hex
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO wallets (id, name, "user", adminkey, inkey)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
wallet_id,
|
||||
"TEST WALLET",
|
||||
adminkey,
|
||||
adminkey,
|
||||
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()}"
|
||||
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO apipayments
|
||||
(wallet, checking_id, bolt11, hash, preimage,
|
||||
amount, pending, memo, fee, extra, webhook, expiry)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
wallet_id,
|
||||
internal_id,
|
||||
"test_admin_internal",
|
||||
"test_admin_internal",
|
||||
None,
|
||||
amount * 1000,
|
||||
False,
|
||||
"test_admin_internal",
|
||||
0,
|
||||
None,
|
||||
"",
|
||||
expiration_date,
|
||||
),
|
||||
)
|
||||
|
||||
print(f"created test admin: {adminkey} with {amount} sats")
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue