-
Notifications
You must be signed in to change notification settings - Fork 0
/
zeusconnect.py
38 lines (28 loc) · 911 Bytes
/
zeusconnect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask, render_template, url_for
import os
import subprocess
import PIL
import qrcode
import json
app = Flask(__name__)
def load_cofig():
with open('config.json', 'r') as f:
config = json.load(f)
return config
@app.route("/")
def connect():
# Open configuration file:
config = load_cofig()
path = config.get("lnd_macaroon")
if path.startswith("<"):
return render_template('configure.html')
#~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
macaroon = subprocess.check_output(f'xxd -p -c2000 {path}', shell=True).decode()
img = qrcode.make(macaroon)
qr = 'connection_qr.png'
img.save(os.getcwd() + '/static/' + qr, 'PNG')
return render_template('connect.html', macaroon=macaroon, qr=qr)
if __name__ == '__main__':
config = load_cofig()
port = config.get("port")
app.run(host='0.0.0.0', port=port, debug=True)