diff --git a/rootfs/standard/etc/systemd/system/lnbits.service b/rootfs/standard/etc/systemd/system/lnbits.service index f55100d4..5f114c28 100644 --- a/rootfs/standard/etc/systemd/system/lnbits.service +++ b/rootfs/standard/etc/systemd/system/lnbits.service @@ -12,8 +12,7 @@ ExecStartPre=/usr/bin/wait_on_lnd.sh Environment=FLASK_ENV=development 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 --python 3.7 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 && python3 /usr/local/bin/pipenv --python 3.7 run gunicorn -b :5000 lnbits:app -k gevent' User=bitcoin diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 747a0821..79da6b1b 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -15,7 +15,7 @@ date rm -rf /var/log/* # Create any necessary users -sudo adduser --disabled-password --gecos "" lnbits || true + # Check if upgrades use tor TORIFY="" @@ -450,32 +450,36 @@ fi # Upgrade 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 +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 -# # 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 --dev -# 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 || true + # Copy over config file + cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env + chown bitcoin:bitcoin /opt/mynode/lnbits/.env -# mkdir -p /home/bitcoin/.mynode/ -# chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ -# echo $LNBITS_UPGRADE_URL > $LNBITS_UPGRADE_URL_FILE -# fi + # 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 diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index dbba1b48..bf037a38 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -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 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) PW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw) diff --git a/rootfs/standard/usr/share/mynode/lnbits.env b/rootfs/standard/usr/share/mynode/lnbits.env new file mode 100644 index 00000000..432d10ee --- /dev/null +++ b/rootfs/standard/usr/share/mynode/lnbits.env @@ -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 \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/enable_disable_functions.py b/rootfs/standard/var/www/mynode/enable_disable_functions.py index 9a13414a..d03a1121 100644 --- a/rootfs/standard/var/www/mynode/enable_disable_functions.py +++ b/rootfs/standard/var/www/mynode/enable_disable_functions.py @@ -53,6 +53,16 @@ def disable_rtl(): 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(): if os.path.isfile(BTCRPCEXPLORER_ENABLED_FILE): return True diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 435706b0..aeddc6d6 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -266,6 +266,8 @@ def index(): lnd_ready = is_lnd_ready() rtl_status_color = "gray" rtl_status = "Lightning Wallet" + lnbits_status_color = "gray" + lnbits_status = "Lightning Wallet" electrs_status_color = "gray" electrs_active = is_electrs_active() lndhub_status_color = "gray" @@ -378,6 +380,15 @@ def index(): else: 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 if is_electrs_enabled(): status_code = get_service_status_code("electrs") @@ -489,6 +500,9 @@ def index(): "rtl_status_color": rtl_status_color, "rtl_status": rtl_status, "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_enabled": is_lndhub_enabled(), "explorer_ready": explorer_ready, @@ -610,6 +624,15 @@ def page_toggle_rtl(): enable_rtl() 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") def page_toggle_btcrpcexplorer(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 1d0c46b0..fd1ff61a 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -217,6 +217,7 @@ def page_status(): electrs_status_log = get_journalctl_log("electrs") netdata_status_log = get_journalctl_log("netdata") rtl_status_log = get_journalctl_log("rtl") + lnbits_status_log = get_journalctl_log("lnbits") docker_status_log = get_journalctl_log("docker") 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": get_service_status_basic_text("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": get_service_status_basic_text("docker"), "docker_status_color": get_service_status_color("docker"), diff --git a/rootfs/standard/var/www/mynode/static/images/lnbits.png b/rootfs/standard/var/www/mynode/static/images/lnbits.png new file mode 100644 index 00000000..0f28714c Binary files /dev/null and b/rootfs/standard/var/www/mynode/static/images/lnbits.png differ diff --git a/rootfs/standard/var/www/mynode/templates/includes/apps.html b/rootfs/standard/var/www/mynode/templates/includes/apps.html index b63c087c..92975c49 100644 --- a/rootfs/standard/var/www/mynode/templates/includes/apps.html +++ b/rootfs/standard/var/www/mynode/templates/includes/apps.html @@ -163,4 +163,24 @@ {% endif %} +