diff --git a/CHANGES.md b/CHANGES.md index c48e819c..a9fc5b35 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - New: WebUI - New: BackendAPI +- New: Core Lightning GRPC plugin [details](https://github.com/rootzoll/raspiblitz/pull/3109) - Update: Bitcoin Core v23.0 [details](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-23.0.md) - Update: Core Lightning (CLN - formerly C-lightning) v0.11.0.1 [details](https://github.com/ElementsProject/lightning/releases/tag/v0.11.0.1) - Update: LND v0.14.3 [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.14.3-beta) diff --git a/build_sdcard.sh b/build_sdcard.sh index 31beaafb..63bbb7a3 100755 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -751,11 +751,13 @@ if ${fatpack}; then echo "* Optional Packages (may be needed for extended features)" sudo apt install -y qrencode secure-delete fbi ssmtp unclutter xterm python3-pyqt5 xfonts-terminus apache2-utils nginx python3-jinja2 socat libatlas-base-dev hexyl autossh - echo "* Adding lnd ..." + echo "* Adding LND ..." /home/admin/config.scripts/lnd.install.sh install || exit 1 - echo "* Adding c-lightning ..." + echo "* Adding Core Lightning ..." /home/admin/config.scripts/cl.install.sh install || exit 1 + echo "* Adding the cln-grpc plugin ..." + /home/admin/config.scripts/cl-plugin.cln-grpc.sh install || exit 1 # *** UPDATE FALLBACK NODE LIST (only as part of fatpack) *** see https://github.com/rootzoll/raspiblitz/issues/1888 echo "*** FALLBACK NODE LIST ***" diff --git a/home.admin/config.scripts/cl-plugin.cln-grpc.sh b/home.admin/config.scripts/cl-plugin.cln-grpc.sh new file mode 100644 index 00000000..bd718633 --- /dev/null +++ b/home.admin/config.scripts/cl-plugin.cln-grpc.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then + echo + echo "Install the cln-grpc plugin for CLN" + echo "Usage:" + echo "cl-plugin.cln-grpc.sh install - called by build_sdcard.sh" + echo "cl-plugin.cln-grpc.sh [on|off] " + echo + exit 1 +fi + +source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2) + +# netprefix is: "" | t | s +# portprefix is: "" | 1 | 3 +PORT="${portprefix}4772" + +function buildGRPCplugin() { + echo "- build the cln-grpc plugin" + if [ ! -f /home/bitcoin/cl-plugins-available/cln-grpc/debug/cln-grpc ]; then + # check if the source code is present + if [ ! -d /home/bitcoin/lightning/plugins/grpc-plugin ];then + echo "* Adding c-lightning ..." + /home/admin/config.scripts/cl.install.sh install || exit 1 + fi + # rust for cln-grpc, includes rustfmt + sudo -u bitcoin curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ + sudo -u bitcoin sh -s -- -y + cd /home/bitcoin/lightning/plugins/grpc-plugin || exit 1 + # build + sudo -u bitcoin /home/bitcoin/.cargo/bin/cargo build \ + --target-dir /home/bitcoin/cl-plugins-available/cln-grpc + fi +} + +if [ "$1" = install ]; then + buildGRPCplugin + exit 0 + +elif [ "$1" = on ]; then + buildGRPCplugin + + # symlink to plugin directory + sudo ln -s /home/bitcoin/cl-plugins-available/cln-grpc/debug/cln-grpc \ + /home/bitcoin/${netprefix}cl-plugins-enabled/ + + # blitz.conf.sh set [key] [value] [?conffile] + /home/admin/config.scripts/blitz.conf.sh set grpc-port "${PORT}" "${CLCONF}" noquotes + /home/admin/config.scripts/blitz.conf.sh set "${netprefix}cln-grpc-port" "${PORT}" + + # firewall + sudo ufw allow "${PORT}" comment "${netprefix}cln-grpc-port" + # Tor + /home/admin/config.scripts/tor.onion-service.sh "${netprefix}cln-grpc-port" "${PORT}" "${PORT}" + exit 0 + +elif [ "$1" = off ]; then + sed -i "/^grpc-port/d" "${CLCONF}" + rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}cln-grpc-port "off" + # firewall + sudo ufw deny "${PORT}" comment "cln-grpc-port" + # Tor + /home/admin/config.scripts/tor.onion-service.sh off ${netprefix}cln-grpc-port + exit 0 + +else + echo "FAIL - Unknown Parameter $1" + exit 1 +fi diff --git a/home.admin/config.scripts/cl.check.sh b/home.admin/config.scripts/cl.check.sh index 9462ee68..97ade76d 100644 --- a/home.admin/config.scripts/cl.check.sh +++ b/home.admin/config.scripts/cl.check.sh @@ -37,7 +37,6 @@ if [ $(grep -c "^sparko" < ${CLCONF}) -gt 0 ];then echo "# The Sparko plugin is not present but in config" sed -i "/^sparko/d" ${CLCONF} rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/sparko - /home/admin/config.scripts/blitz.conf.sh set ${netprefix}sparko "off" fi fi @@ -47,7 +46,6 @@ if [ $(grep -c "^http-pass" < ${CLCONF}) -gt 0 ];then echo "# The clHTTPplugin is not present but in config" sed -i "/^http-pass/d" ${CLCONF} rm -rf /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin - /home/admin/config.scripts/blitz.conf.sh set clHTTPplugin "off" fi fi @@ -57,7 +55,6 @@ if [ $(grep -c "^feeadjuster" < ${CLCONF}) -gt 0 ];then echo "# The feeadjuster plugin is not present but in config" sed -i "/^feeadjuster/d" ${CLCONF} rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py - /home/admin/config.scripts/blitz.conf.sh set ${netprefix}feeadjuster "off" fi fi @@ -66,4 +63,13 @@ if [ "${LNBitsFunding}" = "${netprefix}cl" ]; then if [ $(grep -c "^rpc-file-mode=0660" < ${CLCONF}) -eq 0 ]; then echo "rpc-file-mode=0660" | tee -a ${CLCONF} fi -fi \ No newline at end of file +fi + +if [ $(grep -c "^grpc-port" < ${CLCONF}) -gt 0 ];then + if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc ]\ + || [ "$(eval echo \$${netprefix}cln-grpc-port)" = "off" ]; then + echo "# The cln-grpc plugin is not present but in config" + sed -i "/^grpc-port/d" ${CLCONF} + rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc + fi +fi diff --git a/home.admin/config.scripts/cl.install.sh b/home.admin/config.scripts/cl.install.sh index 7d06530c..656d13d9 100644 --- a/home.admin/config.scripts/cl.install.sh +++ b/home.admin/config.scripts/cl.install.sh @@ -44,8 +44,6 @@ function installDependencies() gettext # additional requirements sudo apt-get install -y postgresql libpq-dev - # rust for cln-grpc, includes rustfmt - sudo -u bitcoin curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u bitcoin sh -s -- -y # mrkd and mistune needs to be globally available for the build sudo pip3 install mrkd==0.2.0 sudo pip3 install mistune==0.8.4 @@ -381,8 +379,21 @@ alias ${netprefix}clconf=\"sudo\ echo "${netprefix}lightning-cli help" echo - # setting value in the raspiblitz.conf + # setting values in the raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}cl on + # blitz.conf.sh needs sudo access - cannot be run in cl.check.sh + if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/sparko ];then + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}sparko "off" + fi + if [ ! -f /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ];then + /home/admin/config.scripts/blitz.conf.sh set clHTTPplugin "off" + fi + if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py ]; then + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}feeadjuster "off" + fi + if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc ];then + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}cln-grpc "off" + fi # if this is the first lightning mainnet turned on - make default if [ "${CHAIN}" == "mainnet" ] && [ "${lightning}" == "" ]; then