mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 12:02:39 +02:00
refactor: move encrypt() function to helpers
This commit is contained in:
@@ -12,11 +12,14 @@ import sqlite3
|
|||||||
import base64
|
import base64
|
||||||
import lnurl
|
import lnurl
|
||||||
import requests
|
import requests
|
||||||
import hashlib
|
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import bech32
|
import bech32
|
||||||
|
|
||||||
|
|
||||||
|
from .helpers import encrypt
|
||||||
|
|
||||||
|
|
||||||
# DATABASE = 'database.db'
|
# DATABASE = 'database.db'
|
||||||
|
|
||||||
INVOICE_KEY = "YOUR-LNTXBOT-INVOICE-KEY" # In the lntxbot bot on telegram type "/api"
|
INVOICE_KEY = "YOUR-LNTXBOT-INVOICE-KEY" # In the lntxbot bot on telegram type "/api"
|
||||||
@@ -34,11 +37,6 @@ def db_connect(db_path=DEFAULT_PATH):
|
|||||||
return con
|
return con
|
||||||
|
|
||||||
|
|
||||||
def encrypt_string(hash_string):
|
|
||||||
sha_signature = hashlib.sha256(hash_string.encode()).hexdigest()
|
|
||||||
return sha_signature
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
|
|
||||||
@@ -144,10 +142,10 @@ def lnurlwallet():
|
|||||||
data = r.json()
|
data = r.json()
|
||||||
print(r.json())
|
print(r.json())
|
||||||
|
|
||||||
adminkey = encrypt_string(payment_hash)[0:20]
|
adminkey = encrypt(payment_hash)[0:20]
|
||||||
inkey = encrypt_string(adminkey)[0:20]
|
inkey = encrypt(adminkey)[0:20]
|
||||||
thewal = encrypt_string(inkey)[0:20]
|
thewal = encrypt(inkey)[0:20]
|
||||||
theid = encrypt_string(thewal)[0:20]
|
theid = encrypt(thewal)[0:20]
|
||||||
thenme = "Bitcoin LN Wallet"
|
thenme = "Bitcoin LN Wallet"
|
||||||
|
|
||||||
con = db_connect()
|
con = db_connect()
|
||||||
@@ -160,8 +158,8 @@ def lnurlwallet():
|
|||||||
con = db_connect()
|
con = db_connect()
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
adminkey = encrypt_string(theid)
|
adminkey = encrypt(theid)
|
||||||
inkey = encrypt_string(adminkey)
|
inkey = encrypt(adminkey)
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||||
@@ -262,8 +260,8 @@ def wallet():
|
|||||||
con = db_connect()
|
con = db_connect()
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
adminkey = encrypt_string(thewal)
|
adminkey = encrypt(thewal)
|
||||||
inkey = encrypt_string(adminkey)
|
inkey = encrypt(adminkey)
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||||
@@ -305,8 +303,8 @@ def wallet():
|
|||||||
con = db_connect()
|
con = db_connect()
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
adminkey = encrypt_string(theid)
|
adminkey = encrypt(theid)
|
||||||
inkey = encrypt_string(adminkey)
|
inkey = encrypt(adminkey)
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||||
@@ -347,8 +345,8 @@ def wallet():
|
|||||||
con = db_connect()
|
con = db_connect()
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
adminkey = encrypt_string(theid)
|
adminkey = encrypt(theid)
|
||||||
inkey = encrypt_string(adminkey)
|
inkey = encrypt(adminkey)
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||||
|
5
LNbits/helpers.py
Normal file
5
LNbits/helpers.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
|
def encrypt(string: str):
|
||||||
|
return hashlib.sha256(string.encode()).hexdigest()
|
Reference in New Issue
Block a user