mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-19 05:33:47 +01:00
refactor: move encrypt() function to helpers
This commit is contained in:
parent
3d3632a06f
commit
7c6c7a2bf6
@ -12,11 +12,14 @@ import sqlite3
|
||||
import base64
|
||||
import lnurl
|
||||
import requests
|
||||
import hashlib
|
||||
import time
|
||||
import json
|
||||
import bech32
|
||||
|
||||
|
||||
from .helpers import encrypt
|
||||
|
||||
|
||||
# DATABASE = 'database.db'
|
||||
|
||||
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
|
||||
|
||||
|
||||
def encrypt_string(hash_string):
|
||||
sha_signature = hashlib.sha256(hash_string.encode()).hexdigest()
|
||||
return sha_signature
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
|
||||
@ -144,10 +142,10 @@ def lnurlwallet():
|
||||
data = r.json()
|
||||
print(r.json())
|
||||
|
||||
adminkey = encrypt_string(payment_hash)[0:20]
|
||||
inkey = encrypt_string(adminkey)[0:20]
|
||||
thewal = encrypt_string(inkey)[0:20]
|
||||
theid = encrypt_string(thewal)[0:20]
|
||||
adminkey = encrypt(payment_hash)[0:20]
|
||||
inkey = encrypt(adminkey)[0:20]
|
||||
thewal = encrypt(inkey)[0:20]
|
||||
theid = encrypt(thewal)[0:20]
|
||||
thenme = "Bitcoin LN Wallet"
|
||||
|
||||
con = db_connect()
|
||||
@ -160,8 +158,8 @@ def lnurlwallet():
|
||||
con = db_connect()
|
||||
cur = con.cursor()
|
||||
|
||||
adminkey = encrypt_string(theid)
|
||||
inkey = encrypt_string(adminkey)
|
||||
adminkey = encrypt(theid)
|
||||
inkey = encrypt(adminkey)
|
||||
|
||||
cur.execute(
|
||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||
@ -262,8 +260,8 @@ def wallet():
|
||||
con = db_connect()
|
||||
cur = con.cursor()
|
||||
|
||||
adminkey = encrypt_string(thewal)
|
||||
inkey = encrypt_string(adminkey)
|
||||
adminkey = encrypt(thewal)
|
||||
inkey = encrypt(adminkey)
|
||||
|
||||
cur.execute(
|
||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||
@ -305,8 +303,8 @@ def wallet():
|
||||
con = db_connect()
|
||||
cur = con.cursor()
|
||||
|
||||
adminkey = encrypt_string(theid)
|
||||
inkey = encrypt_string(adminkey)
|
||||
adminkey = encrypt(theid)
|
||||
inkey = encrypt(adminkey)
|
||||
|
||||
cur.execute(
|
||||
"INSERT INTO wallets (hash, balance, transactions, name, user, adminkey, inkey) VALUES ('"
|
||||
@ -347,8 +345,8 @@ def wallet():
|
||||
con = db_connect()
|
||||
cur = con.cursor()
|
||||
|
||||
adminkey = encrypt_string(theid)
|
||||
inkey = encrypt_string(adminkey)
|
||||
adminkey = encrypt(theid)
|
||||
inkey = encrypt(adminkey)
|
||||
|
||||
cur.execute(
|
||||
"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()
|
Loading…
Reference in New Issue
Block a user