@ -1,10 +1,8 @@
import sqlite3
from os import getenv
from lnbits . helpers import urlsafe_short_hash
from . crud import (
create_account ,
get_user ,
)
from . crud import create_account , get_user
def m000_create_migrations_table ( db ) :
db . execute (
@ -128,7 +126,6 @@ def m002_add_fields_to_apipayments(db):
pass
def m003_create_admin_table ( db ) :
user = None
site_title = None
@ -163,7 +160,6 @@ def m003_create_admin_table(db):
if getenv ( " LNBITS_SERVICE_FEE " ) :
service_fee = getenv ( " LNBITS_SERVICE_FEE " )
db . execute (
"""
CREATE TABLE IF NOT EXISTS admin (
@ -186,11 +182,23 @@ def m003_create_admin_table(db):
INSERT INTO admin ( user , site_title , tagline , primary_color , secondary_color , allowed_users , default_wallet_name , data_folder , disabled_ext , force_https , service_fee )
VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )
""" ,
( user , site_title , tagline , primary_color , secondary_color , allowed_users , default_wallet_name , data_folder , disabled_ext , force_https , service_fee ) ,
(
user ,
site_title ,
tagline ,
primary_color ,
secondary_color ,
allowed_users ,
default_wallet_name ,
data_folder ,
disabled_ext ,
force_https ,
service_fee ,
) ,
)
def m003_create_funding_table ( db ) :
def m003_create_funding_table ( db ) :
# Make the funding table, if it does not already exist
@ -220,7 +228,7 @@ def m003_create_funding_table(db):
LntxbotWallet = db . fetchall ( " SELECT * FROM funding WHERE backend_wallet = ? " , ( " LntxbotWallet " , ) )
OpenNodeWallet = db . fetchall ( " SELECT * FROM funding WHERE backend_wallet = ? " , ( " OpenNodeWallet " , ) )
#If the funding source rows do not exist and there is data in env for them, return the data and put it in a row
# If the funding source rows do not exist and there is data in env for them, return the data and put it in a row
if getenv ( " CLIGHTNING_RPC " ) and CLightningWallet != None :
db . execute (
@ -228,7 +236,7 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint )
VALUES ( ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " CLightningWallet " , getenv ( " CLIGHTNING_RPC " ) ) ,
( urlsafe_short_hash ( ) , " CLightningWallet " , getenv ( " CLIGHTNING_RPC " ) ) ,
)
if getenv ( " LNBITS_INVOICE_MACAROON " ) and LnbitsWallet != None :
db . execute (
@ -236,7 +244,13 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , invoice_key , admin_key )
VALUES ( ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " LnbitsWallet " , getenv ( " LNBITS_ENDPOINT " ) , getenv ( " LNBITS_INVOICE_MACAROON " ) , getenv ( " LNBITS_ADMIN_MACAROON " ) ) ,
(
urlsafe_short_hash ( ) ,
" LnbitsWallet " ,
getenv ( " LNBITS_ENDPOINT " ) ,
getenv ( " LNBITS_INVOICE_MACAROON " ) ,
getenv ( " LNBITS_ADMIN_MACAROON " ) ,
) ,
)
if getenv ( " LND_GRPC_ENDPOINT " ) and LndWallet != None :
db . execute (
@ -244,7 +258,16 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , port , read_key , invoice_key , admin_key , cert )
VALUES ( ? , ? , ? , ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " LndWallet " , getenv ( " LND_GRPC_ENDPOINT " ) , getenv ( " LND_GRPC_PORT " ) , getenv ( " LND_READ_MACAROON " ) , getenv ( " LND_INVOICE_MACAROON " ) , getenv ( " LND_ADMIN_MACAROON " ) , getenv ( " LND_CERT " ) ) ,
(
urlsafe_short_hash ( ) ,
" LndWallet " ,
getenv ( " LND_GRPC_ENDPOINT " ) ,
getenv ( " LND_GRPC_PORT " ) ,
getenv ( " LND_READ_MACAROON " ) ,
getenv ( " LND_INVOICE_MACAROON " ) ,
getenv ( " LND_ADMIN_MACAROON " ) ,
getenv ( " LND_CERT " ) ,
) ,
)
if getenv ( " LND_REST_ENDPOINT " ) and LndRestWallet != None :
@ -253,7 +276,15 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , read_key , invoice_key , admin_key , cert )
VALUES ( ? , ? , ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " LndRestWallet " , getenv ( " LND_REST_ENDPOINT " ) , getenv ( " LND_REST_READ_MACAROON " ) , getenv ( " LND_REST_INVOICE_MACAROON " ) , getenv ( " LND_REST_ADMIN_MACAROON " ) , getenv ( " LND_REST_CERT " ) ) ,
(
urlsafe_short_hash ( ) ,
" LndRestWallet " ,
getenv ( " LND_REST_ENDPOINT " ) ,
getenv ( " LND_REST_READ_MACAROON " ) ,
getenv ( " LND_REST_INVOICE_MACAROON " ) ,
getenv ( " LND_REST_ADMIN_MACAROON " ) ,
getenv ( " LND_REST_CERT " ) ,
) ,
)
if getenv ( " LNPAY_INVOICE_KEY " ) and LNPayWallet != None :
@ -262,7 +293,15 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , read_key , invoice_key , admin_key , cert )
VALUES ( ? , ? , ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " LNPayWallet " , getenv ( " LNPAY_API_ENDPOINT " ) , getenv ( " LNPAY_READ_KEY " ) , getenv ( " LNPAY_INVOICE_KEY " ) , getenv ( " LNPAY_ADMIN_KEY " ) , getenv ( " LNPAY_API_KEY " ) ) ,
(
urlsafe_short_hash ( ) ,
" LNPayWallet " ,
getenv ( " LNPAY_API_ENDPOINT " ) ,
getenv ( " LNPAY_READ_KEY " ) ,
getenv ( " LNPAY_INVOICE_KEY " ) ,
getenv ( " LNPAY_ADMIN_KEY " ) ,
getenv ( " LNPAY_API_KEY " ) ,
) ,
)
if getenv ( " LNTXBOT_INVOICE_KEY " ) and LntxbotWallet != None :
@ -271,7 +310,13 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , invoice_key , admin_key )
VALUES ( ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " LntxbotWallet " , getenv ( " LNTXBOT_API_ENDPOINT " ) , getenv ( " LNTXBOT_INVOICE_KEY " ) , getenv ( " LNTXBOT_ADMIN_KEY " ) ) ,
(
urlsafe_short_hash ( ) ,
" LntxbotWallet " ,
getenv ( " LNTXBOT_API_ENDPOINT " ) ,
getenv ( " LNTXBOT_INVOICE_KEY " ) ,
getenv ( " LNTXBOT_ADMIN_KEY " ) ,
) ,
)
if getenv ( " OPENNODE_INVOICE_KEY " ) and OpenNodeWallet != None :
@ -280,10 +325,15 @@ def m003_create_funding_table(db):
INSERT INTO funding ( id , backend_wallet , endpoint , invoice_key , admin_key )
VALUES ( ? , ? , ? , ? , ? )
""" ,
( urlsafe_short_hash ( ) , " OpenNodeWallet " , getenv ( " OPENNODE_API_ENDPOINT " ) , getenv ( " OPENNODE_INVOICE_KEY " ) , getenv ( " OPENNODE_ADMIN_KEY " ) ) ,
(
urlsafe_short_hash ( ) ,
" OpenNodeWallet " ,
getenv ( " OPENNODE_API_ENDPOINT " ) ,
getenv ( " OPENNODE_INVOICE_KEY " ) ,
getenv ( " OPENNODE_ADMIN_KEY " ) ,
) ,
)
if getenv ( " LNBITS_BACKEND_WALLET_CLASS " ) :
db . execute (
"""
@ -291,7 +341,5 @@ def m003_create_funding_table(db):
SET active = ?
WHERE backend_wallet = ?
""" ,
(
1 , getenv ( " LNBITS_BACKEND_WALLET_CLASS " )
) ,
( 1 , getenv ( " LNBITS_BACKEND_WALLET_CLASS " ) ) ,
)