diff --git a/home.admin/97addMobileWallet.sh b/home.admin/97addMobileWallet.sh index a6f6034cb..b3651c916 100755 --- a/home.admin/97addMobileWallet.sh +++ b/home.admin/97addMobileWallet.sh @@ -149,20 +149,22 @@ if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then OPTIONS+=(ZEUS_ANDROID "Zeus to LND (Android)") OPTIONS+=(SPHINX "Sphinx Chat to LND (Android/iOS)") OPTIONS+=(SENDMANY_ANDROID "SendMany to LND (Android)") + OPTIONS+=(FULLYNODED_LND "Fully Noded to LND REST (iOS+Tor)") fi if [ "${lightning}" == "cl" ] || [ "${cl}" == "on" ]; then OPTIONS+=(ZEUS_CLREST "Zeus to C-lightningREST (Android or iOS)") OPTIONS+=(ZEUS_SPARK "Zeus to Sparko (Android or iOS)") OPTIONS+=(SPARK "Spark Wallet to Sparko (Android - EXPERIMENTAL)" ) + OPTIONS+=(FULLYNODED_CL "Fully Noded to CL REST (iOS+Tor)") fi # Additional Options with Tor if [ "${runBehindTor}" = "on" ]; then - OPTIONS+=(FULLY_NODED "Fully Noded (iOS+Tor)") + OPTIONS+=(FULLYNODED_BTC "Fully Noded to bitcoinRPC (iOS+Tor)") fi -CHOICE=$(whiptail --clear --title "Choose Mobile Wallet" --menu "" 14 75 8 "${OPTIONS[@]}" 2>&1 >/dev/tty) +CHOICE=$(whiptail --clear --title "Choose Mobile Wallet" --menu "" 16 75 10 "${OPTIONS[@]}" 2>&1 >/dev/tty) /home/admin/config.scripts/blitz.display.sh hide @@ -307,7 +309,8 @@ Or scan the qr code on the LCD with your mobile phone. /home/admin/config.scripts/bonus.lndconnect.sh zeus-android tor exit 0; ;; - FULLY_NODED) + + FULLYNODED_BTC) appstoreLink="https://apps.apple.com/us/app/fully-noded/id1436425586" /home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/app_fullynoded.png whiptail --title "Install Fully Noded on your iOS device" \ @@ -327,6 +330,49 @@ Or scan the qr code on the LCD with your mobile phone. exit 0; ;; + FULLYNODED_LND) + appstoreLink="https://apps.apple.com/us/app/fully-noded/id1436425586" + /home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/app_fullynoded.png + whiptail --title "Install Fully Noded on your iOS device" \ + --yes-button "Continue" \ + --no-button "StoreLink" \ + --yesno "Open the Apple App Store on your mobile phone.\n\nSearch for --> 'fully noded'\n\nCheck that logo is like on LCD and author is: Denton LLC\nWhen app is installed and started --> Continue." 12 65 + if [ $? -eq 1 ]; then + /home/admin/config.scripts/blitz.display.sh qr ${appstoreLink} + whiptail --title " App Store Link " --msgbox "\ +To install app open the following link:\n +${appstoreLink}\n +Or scan the qr code on the LCD with your mobile phone. +" 11 70 + fi + /home/admin/config.scripts/blitz.display.sh hide + /home/admin/config.scripts/bonus.lndconnect.sh fullynoded-lnd tor + exit 0; + ;; + + FULLYNODED_CL) + if [ ! -L /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ];then + /home/admin/config.scripts/cl-plugin.http.sh on + fi + appstoreLink="https://apps.apple.com/us/app/fully-noded/id1436425586" + /home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/app_fullynoded.png + whiptail --title "Install Fully Noded on your iOS device" \ + --yes-button "Continue" \ + --no-button "StoreLink" \ + --yesno "Open the Apple App Store on your mobile phone.\n\nSearch for --> 'fully noded'\n\nCheck that logo is like on LCD and author is: Denton LLC\nWhen app is installed and started --> Continue." 12 65 + if [ $? -eq 1 ]; then + /home/admin/config.scripts/blitz.display.sh qr ${appstoreLink} + whiptail --title " App Store Link " --msgbox "\ +To install app open the following link:\n +${appstoreLink}\n +Or scan the qr code on the LCD with your mobile phone. +" 11 70 + fi + /home/admin/config.scripts/blitz.display.sh hide + /home/admin/config.scripts/cl-plugin.http.sh connect + exit 0; + ;; + ZEUS_CLREST) /home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/app_zeus.png whiptail --title "Install Zeus on your Android or iOS Phone" \ diff --git a/home.admin/_provision_.sh b/home.admin/_provision_.sh index 3af4fe43e..c4bbd605d 100755 --- a/home.admin/_provision_.sh +++ b/home.admin/_provision_.sh @@ -457,6 +457,15 @@ else echo "Provisioning Sparko - keep default" >> ${logFile} fi +# clHTTPplugin +if [ "${clHTTPplugin}" = "on" ]; then + echo "Provisioning clHTTPplugin - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Setup clHTTPplugin'/g" ${infoFile} + sudo -u admin /home/admin/config.scripts/cl-plugin.http.sh on >> ${logFile} 2>&1 +else + echo "Provisioning clHTTPplugin - keep default" >> ${logFile} +fi + # SPARK if [ "${spark}" = "on" ]; then echo "Provisioning Spark Wallet - run config script" >> ${logFile} diff --git a/home.admin/config.scripts/bonus.lndconnect.sh b/home.admin/config.scripts/bonus.lndconnect.sh index 62f087b83..a7255e8a1 100755 --- a/home.admin/config.scripts/bonus.lndconnect.sh +++ b/home.admin/config.scripts/bonus.lndconnect.sh @@ -4,7 +4,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "# config script to connect mobile apps with lnd connect" echo "# will autodetect dyndns, sshtunnel or TOR" - echo "# bonus.lndconnect.sh [zap-ios|zap-android|zeus-ios|zeus-android|shango-ios|shango-android|sendmany-android] [?ip|tor]" + echo "# bonus.lndconnect.sh [zap-ios|zap-android|zeus-ios|zeus-android|shango-ios|shango-android|sendmany-android|fullynoded-lnd] [?ip|tor]" exit 1 fi @@ -126,6 +126,14 @@ elif [ "${targetWallet}" = "sendmany-android" ]; then port="${ip2torGRPC_PORT}" fi +elif [ "${targetWallet}" = "fullynoded-lnd" ]; then + + port="8080" + usingIP2TOR="LND-REST-API" + forceTOR=1 + host=$(sudo cat /mnt/hdd/tor/lndrest8080/hostname) + connectInfo="- start Fully Noded and go to:\n Settings' -> 'Node Manger' -> 'scan QR'" + else echo "error='unknown target wallet'" exit 1 diff --git a/home.admin/config.scripts/cl-plugin.http.sh b/home.admin/config.scripts/cl-plugin.http.sh new file mode 100644 index 000000000..7b9ca07d2 --- /dev/null +++ b/home.admin/config.scripts/cl-plugin.http.sh @@ -0,0 +1,169 @@ +#!/bin/bash + +# https://github.com/Start9Labs/c-lightning-http-plugin/commits/master +clHTTPpluginVersion="1dbb6537e0ec5fb9b8edde10db6b4cc613ccdb19" + +# command info +if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then + echo + echo "Install, remove, connect the c-lightning-http-plugin" + echo "version: $clHTTPpluginVersion" + echo "Implemented for mainnet only." + echo "Usage:" + echo "cl-plugin.http.sh [on|off|connect] " + echo + exit 1 +fi + +# source <(/home/admin/config.scripts/network.aliases.sh getvars cl ) +source <(/home/admin/config.scripts/network.aliases.sh getvars cl mainnet) + +# add default value to raspi config if needed +configEntry="clHTTPplugin" +configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}") +if [ "${configEntryExists}" == "0" ]; then + echo "# adding default config entry for '${configEntry}'" + sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf" +else + echo "# default config entry for '${configEntry}' exists" +fi + +if [ $1 = connect ];then + toraddress=$(sudo cat /mnt/hdd/tor/clHTTPplugin/hostname) + PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-) + # https://github.com/rootzoll/raspiblitz/issues/2579#issuecomment-936091256 + # http://rpcuser:rpcpassword@xxx.onion:9080 + url="http://lightning:${PASSWORD_B}@${toraddress}:9080" + clear + echo + /home/admin/config.scripts/blitz.display.sh qr "${toraddress}" + echo " +Connect Fully Noded + +In Fully Noded go to 'Settings' > 'Node Manager' > +, from there you will be automatically prompted to add a node: + + add a label + add the rpc user: lightning + add the rpc password is your Password_B + add the onion address (also shown on the display as a QR and below), ensure you add the port at the end: + ${toraddress}:9080" + + qrencode -t ANSIUTF8 "${toraddress}:9080" + + echo " + ignore the macaroon and cert as that is for LND only + +Thats it, Fully Noded will now automatically use those credentials for any lightning related functionality. +You can only have one lightning node at a a time, to add a new one just overwrite the existing credentials. + +In Fully Noded you will see lightning bolt zap buttons in a few places, tap them to see what they do. + +Find the most up-to-date version of this info at: +https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Lightning.md#connect-fully-noded +" + echo + echo "# Press enter to continue to show the full connection URL with all the info above" + read key + /home/admin/config.scripts/blitz.display.sh hide + /home/admin/config.scripts/blitz.display.sh qr "${url}" + clear + echo " +C-lightning connection URL code for Fully Noded: +The string shown is: +$url +" + qrencode -t ANSIUTF8 "${url}" + echo + echo "# Press enter to hide the QRcode from the LCD" + read key + /home/admin/config.scripts/blitz.display.sh hide + exit 0 +fi + +if [ "$1" = "on" ];then + + if [ $(cargo -V 2>/dev/null | grep -c cargo) -eq 0 ];then + echo + echo "# Installing Rust" + echo + # https://github.com/romanz/electrs/blob/master/doc/usage.md#build-dependencies + #sudo -u electrs curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u electrs sh -s -- --default-toolchain 1.39.0 -y + sudo apt update + sudo apt install -y cargo + fi + + if [ ! -f /home/bitcoin/cl-plugins-available/c-lightning-http-plugin ];then + sudo -u bitcoin mkdir /home/bitcoin/cl-plugins-available + cd /home/bitcoin/cl-plugins-available || exit 1 + sudo -u bitcoin git clone https://github.com/Start9Labs/c-lightning-http-plugin.git + cd c-lightning-http-plugin || exit 1 + sudo -u bitcoin git reset --hard ${clHTTPpluginVersion} || exit 1 + echo + echo "# change CL REST port to 9080" + sudo sed -i "s/8080/9080/g" src/rpc.rs + echo + sudo -u bitcoin cargo build --release + sudo chmod a+x /home/bitcoin/cl-plugins-available/c-lightning-http-plugin/target/release/c-lightning-http-plugin + fi + + if [ ! -L /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ];then + sudo ln -s /home/bitcoin/cl-plugins-available/c-lightning-http-plugin/target/release/c-lightning-http-plugin \ + /home/bitcoin/cl-plugins-enabled + fi + + ########## + # Config # + ########## + if ! grep -Eq "^http-pass=" ${CLCONF};then + echo "# Editing ${CLCONF}" + echo "# See: https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Lightning.md#setup-c-lightning-http-plugin" + PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-) + echo " +http-pass=${PASSWORD_B} +" | sudo tee -a ${CLCONF} + + else + echo "# clHTTPplugin is already configured in ${CLCONF}" + fi + + # hidden service to https://xx.onion + /home/admin/config.scripts/internet.hiddenservice.sh clHTTPplugin 9080 9080 + + # setting value in raspi blitz config + sudo sed -i "s/^clHTTPplugin=.*/clHTTPplugin=on/g" /mnt/hdd/raspiblitz.conf + + source /home/admin/raspiblitz.info + if [ "${state}" == "ready" ] && [ "$2" != "norestart" ]; then + echo "# Restart the lightningd.service to activate clHTTPplugin" + sudo systemctl restart lightningd + fi + + echo "# clHTTPplugin was installed" + echo "# Monitor with:" + echo "sudo journalctl | grep clHTTPplugin | tail -n5" + echo "sudo tail -n 100 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log | grep clHTTPplugin" + +fi + +if [ "$1" = "off" ];then + # delete symlink + sudo rm -rf /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin + + echo "# Editing ${CLCONF}" + sudo sed -i "/^http-pass/d" ${CLCONF} + + echo "# Restart the lightningd.service to deactivate clHTTPplugin" + sudo systemctl restart lightningd + + /home/admin/config.scripts/internet.hiddenservice.sh off clHTTPplugin + + # purge + if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then + echo "# Delete plugin" + sudo rm -rf /home/bitcoin/cl-plugins-available/c-lightning-http-plugin + fi + # setting value in raspi blitz config + sudo sed -i "s/^clHTTPplugin=.*/clHTTPplugin=off/g" /mnt/hdd/raspiblitz.conf + echo "# clHTTPplugin was uninstalled" + +fi diff --git a/home.admin/config.scripts/cl.check.sh b/home.admin/config.scripts/cl.check.sh index 2c9c97fed..ee813ca36 100644 --- a/home.admin/config.scripts/cl.check.sh +++ b/home.admin/config.scripts/cl.check.sh @@ -29,6 +29,16 @@ if [ $(grep -c "^sparko" < ${CLCONF}) -gt 0 ];then fi fi +if [ $(grep -c "^http-pass" < ${CLCONF}) -gt 0 ];then + if [ ! -f /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ]\ + || [ "${clHTTPplugin}" != "on" ]; 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 + sed -i "s/^clHTTPplugin=.*/clHTTPplugin=off/g" /mnt/hdd/raspiblitz.conf + fi +fi + if [ $(grep -c "^feeadjuster" < ${CLCONF}) -gt 0 ];then if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py ]\ || [ "$(eval echo \$${netprefix}feeadjuster)" != "on" ]; then diff --git a/home.admin/config.scripts/cl.install-service.sh b/home.admin/config.scripts/cl.install-service.sh index 8487a4edd..f1a96a7c1 100644 --- a/home.admin/config.scripts/cl.install-service.sh +++ b/home.admin/config.scripts/cl.install-service.sh @@ -20,6 +20,13 @@ if [ $(sudo -u bitcoin cat ${CLCONF} | grep -c "^sparko") -gt 0 ];then fi fi +if [ $(sudo -u bitcoin cat ${CLCONF} | grep -c "^http-pass") -gt 0 ];then + if [ ! -f /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ]; then + echo "# The clHTTPplugin is not present but in config" + /home/admin/config.scripts/cl-plugin.http.sh on norestart + fi +fi + if [ $(sudo -u bitcoin cat ${CLCONF} | grep -c "^feeadjuster") -gt 0 ];then if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py ];then echo "# The feeadjuster plugin is not present but in config"