Add LNbits

This commit is contained in:
Taylor Helsper 2020-06-27 21:12:54 -05:00
parent 0390a7b559
commit f80fc78d27
12 changed files with 193 additions and 27 deletions

View File

@ -12,8 +12,7 @@ ExecStartPre=/usr/bin/wait_on_lnd.sh
Environment=FLASK_ENV=development Environment=FLASK_ENV=development
WorkingDirectory=/opt/mynode/lnbits WorkingDirectory=/opt/mynode/lnbits
#ExecStart=/usr/local/bin/pipenv run flask run --host 0.0.0.0 ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && /usr/local/bin/pipenv run flask run --host 0.0.0.0'
ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && /usr/local/bin/pipenv --python 3.7 run flask run --host 0.0.0.0'
#ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && python3 /usr/local/bin/pipenv --python 3.7 run gunicorn -b :5000 lnbits:app -k gevent' #ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && python3 /usr/local/bin/pipenv --python 3.7 run gunicorn -b :5000 lnbits:app -k gevent'
User=bitcoin User=bitcoin

View File

@ -15,7 +15,7 @@ date
rm -rf /var/log/* rm -rf /var/log/*
# Create any necessary users # Create any necessary users
sudo adduser --disabled-password --gecos "" lnbits || true
# Check if upgrades use tor # Check if upgrades use tor
TORIFY="" TORIFY=""
@ -450,32 +450,36 @@ fi
# Upgrade LNBits # Upgrade LNBits
# LNBITS_UPGRADE_URL=https://github.com/lnbits/lnbits/archive/raspiblitz.tar.gz LNBITS_UPGRADE_URL=https://github.com/lnbits/lnbits/archive/raspiblitz.tar.gz
# LNBITS_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnbits_url LNBITS_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnbits_url
# CURRENT="" CURRENT=""
# if [ -f $LNBITS_UPGRADE_URL_FILE ]; then if [ -f $LNBITS_UPGRADE_URL_FILE ]; then
# CURRENT=$(cat $LNBITS_UPGRADE_URL_FILE) CURRENT=$(cat $LNBITS_UPGRADE_URL_FILE)
# fi fi
# if [ "$CURRENT" != "$LNBITS_UPGRADE_URL" ]; then if [ "$CURRENT" != "$LNBITS_UPGRADE_URL" ]; then
# cd /opt/mynode cd /opt/mynode
# rm -rf lnbits rm -rf lnbits
# sudo -u bitcoin wget $LNBITS_UPGRADE_URL -O lnbits.tar.gz sudo -u bitcoin wget $LNBITS_UPGRADE_URL -O lnbits.tar.gz
# sudo -u bitcoin tar -xvf lnbits.tar.gz sudo -u bitcoin tar -xvf lnbits.tar.gz
# sudo -u bitcoin rm lnbits.tar.gz sudo -u bitcoin rm lnbits.tar.gz
# sudo -u bitcoin mv lnbits-* lnbits sudo -u bitcoin mv lnbits-* lnbits
# cd lnbits cd lnbits
# # Install with python 3.7 (Only use "pipenv install --python 3.7" once or it will rebuild the venv!) # Copy over config file
# sudo -u bitcoin pipenv --python 3.7 install --dev cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env
# sudo -u bitcoin pipenv run pip install python-dotenv chown bitcoin:bitcoin /opt/mynode/lnbits/.env
# sudo -u bitcoin pipenv run pip install -r requirements.txt
# sudo -u bitcoin pipenv run pip install lnd-grpc
# sudo -u bitcoin pipenv run flask migrate || true
# mkdir -p /home/bitcoin/.mynode/ # Install with python 3.7 (Only use "pipenv install --python 3.7" once or it will rebuild the venv!)
# chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ sudo -u bitcoin pipenv --python 3.7 install
# echo $LNBITS_UPGRADE_URL > $LNBITS_UPGRADE_URL_FILE sudo -u bitcoin pipenv run pip install python-dotenv
# fi sudo -u bitcoin pipenv run pip install -r requirements.txt
sudo -u bitcoin pipenv run pip install lnd-grpc
sudo -u bitcoin pipenv run flask migrate
mkdir -p /home/bitcoin/.mynode/
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
echo $LNBITS_UPGRADE_URL > $LNBITS_UPGRADE_URL_FILE
fi
# Install LND Connect # Install LND Connect

View File

@ -251,6 +251,10 @@ chown bitcoin:bitcoin /opt/mynode/RTL/RTL-Config.json
cp /usr/share/mynode/btc_rpc_explorer_env /opt/mynode/btc-rpc-explorer/.env cp /usr/share/mynode/btc_rpc_explorer_env /opt/mynode/btc-rpc-explorer/.env
chown bitcoin:bitcoin /opt/mynode/btc-rpc-explorer/.env chown bitcoin:bitcoin /opt/mynode/btc-rpc-explorer/.env
# LNBits Config
cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env
chown bitcoin:bitcoin /opt/mynode/lnbits/.env
# Update files that need RPC password (needed if upgrades overwrite files) # Update files that need RPC password (needed if upgrades overwrite files)
PW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw) PW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw)

View File

@ -0,0 +1,46 @@
FLASK_APP=lnbits
FLASK_ENV=production
LNBITS_SITE_TITLE=LNbits
LNBITS_ALLOWED_USERS="all"
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
LNBITS_DATA_FOLDER="/mnt/hdd/mynode/lnbits"
LNBITS_DISABLED_EXTENSIONS="amilk,events"
LNBITS_FORCE_HTTPS=0
LNBITS_SERVICE_FEE="0.0"
# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet, CLightningWallet, LnbitsWallet
LNBITS_BACKEND_WALLET_CLASS=LndWallet
CLIGHTNING_RPC="/home/bob/.lightning/bitcoin/lightning-rpc"
LNBITS_ENDPOINT=127.0.0.1:5000
LNBITS_INVOICE_MACAROON=LNBITS_INVOICE_MACAROON
LNBITS_ADMIN_MACAROON=LNBITS_ADMIN_MACAROON
LND_GRPC_ENDPOINT=127.0.0.1
LND_GRPC_PORT=10009
LND_CERT="/mnt/hdd/mynode/lnd/tls.cert"
LND_ADMIN_MACAROON="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/admin.macaroon"
LND_INVOICE_MACAROON="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/invoice.macaroon"
LND_READ_MACAROON="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/read.macaroon"
LND_REST_ENDPOINT=https://localhost:10080/
LND_REST_CERT="/mnt/hdd/mynode/lnd/tls.cert"
LND_REST_ADMIN_MACAROON="HEXSTRING"
LND_REST_INVOICE_MACAROON="HEXSTRING"
LND_REST_READ_MACAROON="HEXSTRING"
LNPAY_API_ENDPOINT=https://lnpay.co/v1/
LNPAY_API_KEY=LNPAY_API_KEY
LNPAY_ADMIN_KEY=LNPAY_ADMIN_KEY
LNPAY_INVOICE_KEY=LNPAY_INVOICE_KEY
LNPAY_READ_KEY=LNPAY_READ_KEY
LNTXBOT_API_ENDPOINT=https://lntxbot.bigsun.xyz/
LNTXBOT_ADMIN_KEY=LNTXBOT_ADMIN_KEY
LNTXBOT_INVOICE_KEY=LNTXBOT_INVOICE_KEY
OPENNODE_API_ENDPOINT=https://api.opennode.com/
OPENNODE_ADMIN_KEY=OPENNODE_ADMIN_KEY
OPENNODE_INVOICE_KEY=OPENNODE_INVOICE_KEY

View File

@ -53,6 +53,16 @@ def disable_rtl():
os.system("systemctl disable rtl --no-pager") os.system("systemctl disable rtl --no-pager")
def is_lnbits_enabled():
return is_service_enabled("lnbits")
def enable_lnbits():
os.system("systemctl enable lnbits --no-pager")
os.system("systemctl start lnbits --no-pager")
def disable_lnbits():
os.system("systemctl stop lnbits --no-pager")
os.system("systemctl disable lnbits --no-pager")
def is_btcrpcexplorer_enabled(): def is_btcrpcexplorer_enabled():
if os.path.isfile(BTCRPCEXPLORER_ENABLED_FILE): if os.path.isfile(BTCRPCEXPLORER_ENABLED_FILE):
return True return True

View File

@ -266,6 +266,8 @@ def index():
lnd_ready = is_lnd_ready() lnd_ready = is_lnd_ready()
rtl_status_color = "gray" rtl_status_color = "gray"
rtl_status = "Lightning Wallet" rtl_status = "Lightning Wallet"
lnbits_status_color = "gray"
lnbits_status = "Lightning Wallet"
electrs_status_color = "gray" electrs_status_color = "gray"
electrs_active = is_electrs_active() electrs_active = is_electrs_active()
lndhub_status_color = "gray" lndhub_status_color = "gray"
@ -378,6 +380,15 @@ def index():
else: else:
rtl_status_color = "green" rtl_status_color = "green"
# Find LNbits status
if lnd_ready:
if is_lnbits_enabled():
status_code = get_service_status_code("lnbits")
if status_code != 0:
lnbits_status_color = "red"
else:
lnbits_status_color = "green"
# Find electrs status # Find electrs status
if is_electrs_enabled(): if is_electrs_enabled():
status_code = get_service_status_code("electrs") status_code = get_service_status_code("electrs")
@ -489,6 +500,9 @@ def index():
"rtl_status_color": rtl_status_color, "rtl_status_color": rtl_status_color,
"rtl_status": rtl_status, "rtl_status": rtl_status,
"rtl_enabled": is_rtl_enabled(), "rtl_enabled": is_rtl_enabled(),
"lnbits_status_color": lnbits_status_color,
"lnbits_status": lnbits_status,
"lnbits_enabled": is_lnbits_enabled(),
"lndhub_status_color": lndhub_status_color, "lndhub_status_color": lndhub_status_color,
"lndhub_enabled": is_lndhub_enabled(), "lndhub_enabled": is_lndhub_enabled(),
"explorer_ready": explorer_ready, "explorer_ready": explorer_ready,
@ -610,6 +624,15 @@ def page_toggle_rtl():
enable_rtl() enable_rtl()
return redirect("/") return redirect("/")
@app.route("/toggle-lnbits")
def page_toggle_lnbits():
check_logged_in()
if is_lnbits_enabled():
disable_lnbits()
else:
enable_lnbits()
return redirect("/")
@app.route("/toggle-btcrpcexplorer") @app.route("/toggle-btcrpcexplorer")
def page_toggle_btcrpcexplorer(): def page_toggle_btcrpcexplorer():
check_logged_in() check_logged_in()

View File

@ -217,6 +217,7 @@ def page_status():
electrs_status_log = get_journalctl_log("electrs") electrs_status_log = get_journalctl_log("electrs")
netdata_status_log = get_journalctl_log("netdata") netdata_status_log = get_journalctl_log("netdata")
rtl_status_log = get_journalctl_log("rtl") rtl_status_log = get_journalctl_log("rtl")
lnbits_status_log = get_journalctl_log("lnbits")
docker_status_log = get_journalctl_log("docker") docker_status_log = get_journalctl_log("docker")
docker_image_build_status_log = get_journalctl_log("docker_images") docker_image_build_status_log = get_journalctl_log("docker_images")
@ -273,6 +274,9 @@ def page_status():
"rtl_status_log": rtl_status_log, "rtl_status_log": rtl_status_log,
"rtl_status": get_service_status_basic_text("rtl"), "rtl_status": get_service_status_basic_text("rtl"),
"rtl_status_color": get_service_status_color("rtl"), "rtl_status_color": get_service_status_color("rtl"),
"lnbits_status_log": lnbits_status_log,
"lnbits_status": get_service_status_basic_text("lnbits"),
"lnbits_status_color": get_service_status_color("lnbits"),
"docker_status_log": docker_status_log, "docker_status_log": docker_status_log,
"docker_status": get_service_status_basic_text("docker"), "docker_status": get_service_status_basic_text("docker"),
"docker_status_color": get_service_status_color("docker"), "docker_status_color": get_service_status_color("docker"),

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -163,4 +163,24 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="app_tile">
<div class="app_status_icon {{ lnbits_status_color }}"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/lnbits.png")}}"/></div>
<div class="app_title">LNbits</div>
<div class="app_status">{% if not lnd_ready %}Waiting on LND...{% else %}{{ lnbits_status }}{% endif %}</div>
<div class="app_contents">
{% if product_key_skipped %}
Premium Feature
{% else %}
{% if lnd_ready %}
{% if lnbits_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="lnbits">LNbits</a>
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-lnbits">Disable</a>
{% else %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-lnbits">Enable</a>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
</div> </div>

View File

@ -23,6 +23,11 @@
window.open(url,'_blank'); window.open(url,'_blank');
}) })
$("#lnbits").on("click", function() {
url = 'http://'+location.hostname+':5000'
window.open(url,'_blank');
})
$("#lnd_admin").on("click", function() { $("#lnd_admin").on("click", function() {
url = 'http://'+location.hostname+':3004' url = 'http://'+location.hostname+':3004'
window.open(url,'_blank'); window.open(url,'_blank');
@ -103,6 +108,10 @@
window.location.href="/toggle-caravan" window.location.href="/toggle-caravan"
}); });
$("#toggle-lnbits").on("click", function() {
window.location.href="/toggle-lnbits"
});
function lndconnect() { function lndconnect() {
$("#lndconnect_form").submit(); $("#lndconnect_form").submit();
lndconnect_dialog.dialog( "close" ); lndconnect_dialog.dialog( "close" );

View File

@ -51,6 +51,11 @@
$("#rtl_status").show(); $("#rtl_status").show();
}); });
$("#show_lnbits_status").on("click", function() {
$("#show_lnbits_status").hide(0);
$("#lnbits_status").show();
});
$("#show_docker_status").on("click", function() { $("#show_docker_status").on("click", function() {
$("#show_docker_status").hide(0); $("#show_docker_status").hide(0);
$("#docker_status").show(); $("#docker_status").show();
@ -335,6 +340,15 @@
<div id="rtl_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{rtl_status_log}}</pre></div> <div id="rtl_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{rtl_status_log}}</pre></div>
<div class="divider"></div> <div class="divider"></div>
<div class="settings_block_subheader">LNbits Status</div>
<div class="settings_block_subheader_status">
<div class="settings_block_subheader_status_icon {{ lnbits_status_color }}"></div>
{{ lnbits_status }}
</div>
<button id="show_lnbits_status" class="ui-button ui-widget ui-corner-all settings_button_small">Show Log</button>
<div id="lnbits_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{lnbits_status_log}}</pre></div>
<div class="divider"></div>
<div class="settings_block_subheader">Docker Status</div> <div class="settings_block_subheader">Docker Status</div>
<div class="settings_block_subheader_status"> <div class="settings_block_subheader_status">
<div class="settings_block_subheader_status_icon {{ docker_status_color }}"></div> <div class="settings_block_subheader_status_icon {{ docker_status_color }}"></div>

View File

@ -550,6 +550,39 @@ if [ "$CURRENT" != "$BTCRPCEXPLORER_UPGRADE_URL" ]; then
fi fi
# Install LNBits
LNBITS_UPGRADE_URL=https://github.com/lnbits/lnbits/archive/raspiblitz.tar.gz
LNBITS_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnbits_url
CURRENT=""
if [ -f $LNBITS_UPGRADE_URL_FILE ]; then
CURRENT=$(cat $LNBITS_UPGRADE_URL_FILE)
fi
if [ "$CURRENT" != "$LNBITS_UPGRADE_URL" ]; then
cd /opt/mynode
rm -rf lnbits
sudo -u bitcoin wget $LNBITS_UPGRADE_URL -O lnbits.tar.gz
sudo -u bitcoin tar -xvf lnbits.tar.gz
sudo -u bitcoin rm lnbits.tar.gz
sudo -u bitcoin mv lnbits-* lnbits
cd lnbits
# Copy over config file
cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env
chown bitcoin:bitcoin /opt/mynode/lnbits/.env
# Install with python 3.7 (Only use "pipenv install --python 3.7" once or it will rebuild the venv!)
sudo -u bitcoin pipenv --python 3.7 install
sudo -u bitcoin pipenv run pip install python-dotenv
sudo -u bitcoin pipenv run pip install -r requirements.txt
sudo -u bitcoin pipenv run pip install lnd-grpc
sudo -u bitcoin pipenv run flask migrate
mkdir -p /home/bitcoin/.mynode/
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
echo $LNBITS_UPGRADE_URL > $LNBITS_UPGRADE_URL_FILE
fi
# Install LND Connect # Install LND Connect
LNDCONNECTARCH="lndconnect-linux-armv7" LNDCONNECTARCH="lndconnect-linux-armv7"
if [ $IS_X86 = 1 ]; then if [ $IS_X86 = 1 ]; then