diff --git a/CHANGES.md b/CHANGES.md index a4f67a1b4..2e2ed443a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ## What's new in Version 1.9.0 of RaspiBlitz? +- New: CL Watchtower (The Eye of Satoshi) [details](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin) - New: Support of X708 UPS HAT [details](https://github.com/rootzoll/raspiblitz/pull/3087) - Update: Bitcoin Core v24.0 [details](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md) - Update: LND v0.15.5 [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.15.5-beta diff --git a/README.md b/README.md index a357f8075..0da15243c 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ There are further Services that can be switched on: - **CL Spark Wallet** (WalletUI with BOLT12 offers) [details](https://github.com/shesek/spark-wallet#progressive-web-app) - **CL plugin: Sparko** (WalletUI & HTTP-RPC bridge) [details](https://github.com/fiatjaf/sparko#the-sparko-plugin) - **CL plugin: CLBOSS** (Automated Node Manager) [details](https://github.com/ZmnSCPxj/clboss#clboss-the-c-lightning-node-manager) +- **CL plugin: The Eye of Satoshi** (Watchtower) [details](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin) - **Tallycoin Connect** (Use Tallycoin with your own node) [details](https://github.com/djbooth007/tallycoin_connect) - **ItchySats** (Non-custodial peer-to-peer CFD trading) [details](https://github.com/itchysats/itchysats) diff --git a/home.admin/00settingsMenuBasics.sh b/home.admin/00settingsMenuBasics.sh index 4e1fab5e1..15121890f 100755 --- a/home.admin/00settingsMenuBasics.sh +++ b/home.admin/00settingsMenuBasics.sh @@ -17,6 +17,7 @@ if [ ${#circuitbreaker} -eq 0 ]; then circuitbreaker="off"; fi if [ ${#clboss} -eq 0 ]; then clboss="off"; fi if [ ${#clEncryptedHSM} -eq 0 ]; then clEncryptedHSM="off"; fi if [ ${#clAutoUnlock} -eq 0 ]; then clAutoUnlock="off"; fi +if [ ${#clWatchtowerClient} -eq 0 ]; then clWatchtowerClient="off"; fi if [ ${#blitzapi} -eq 0 ]; then blitzapi="off"; fi echo "# map LND to on/off" @@ -95,6 +96,12 @@ if [ "${clAutoUnlock}" == "on" ]; then clAutoUnlockMenu='on' fi +echo "# map clWatchtowerClient to on/off" +clWatchtowerClientMenu='off' +if [ "${clWatchtowerClient}" == "on" ]; then + clWatchtowerClientMenu='on' +fi + echo "# map keysend to on/off (may take time)" keysend="on" source <(sudo /home/admin/config.scripts/lnd.keysend.sh status) @@ -147,6 +154,7 @@ OPTIONS+=(n 'CL CORE LIGHTNING NODE' ${clNode}) if [ "${clNode}" == "on" ]; then OPTIONS+=(o '-CL CLBOSS Automatic Node Manager' ${clbossMenu}) OPTIONS+=(h '-CL Wallet Encryption' ${clEncryptedHSMMenu}) + OPTIONS+=(w '-CL Watchtower Client' ${clWatchtowerClientMenu}) if [ "${clEncryptedHSM}" == "on" ]; then OPTIONS+=(q '-CL Auto-Unlock' ${clAutoUnlockMenu}) fi @@ -500,6 +508,28 @@ else echo "clAutoUnlock Setting unchanged." fi +# clWatchtowerClient process choice +choice="off"; check=$(echo "${CHOICES}" | grep -c "w") +if [ ${check} -eq 1 ]; then choice="on"; fi +if [ "${clWatchtowerClient}" != "${choice}" ] && [ "${clNode}" == "on" ]; then + echo "CL WATCHTOWER CLIENT Setting changed .." + anychange=1 + + if [ ${choice} = on ]; then + if /home/admin/config.scripts/cl-plugin.watchtower-client.sh info; then + sudo /home/admin/config.scripts/cl-plugin.watchtower-client.sh on + else + echo "CL WATCHTOWER CLIENT install was cancelled." + sleep 2 + fi + else + sudo /home/admin/config.scripts/cl-plugin.watchtower-client.sh off + fi + needsReboot=0 +else + echo "CL WATCHTOWER CLIENT Setting unchanged." +fi + # parallel testnet process choice choice="off"; check=$(echo "${CHOICES}" | grep -c "p") if [ ${check} -eq 1 ]; then choice="on"; fi diff --git a/home.admin/99clMenu.sh b/home.admin/99clMenu.sh index 7968d17a5..9a9406391 100644 --- a/home.admin/99clMenu.sh +++ b/home.admin/99clMenu.sh @@ -33,6 +33,9 @@ if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then fi OPTIONS+=(CASHOUT "Withdraw all funds onchain ($CHAIN)") OPTIONS+=(SEED "Show Wallet Seed Words") +if [ "${clWatchtowerClient}" == "on" ] && [ "${CHAIN}" == "mainnet" ]; then + OPTIONS+=(WATCHTOWER "Watchtower Client Options") +fi OPTIONS+=(REPAIR-CL "Repair options for Core Lightning") if [ "${lightning}" != "cl" ] && [ "${CHAIN}" == "mainnet" ]; then OPTIONS+=(SWITCHLN "Use Core Lightning as default") @@ -81,6 +84,9 @@ case $CHOICE in NAME) sudo /home/admin/config.scripts/cl.setname.sh $CHAIN ;; + WATCHTOWER) + /home/admin/config.scripts/cl-plugin.watchtower-client.sh info + ;; SUEZ) clear if [ ! -f /home/bitcoin/suez/suez ];then diff --git a/home.admin/_provision_.sh b/home.admin/_provision_.sh index aefd0e78f..5b35d9858 100755 --- a/home.admin/_provision_.sh +++ b/home.admin/_provision_.sh @@ -424,6 +424,24 @@ else echo "Provisioning clHTTPplugin - keep default" >> ${logFile} fi +# clboss +if [ "${clboss}" = "on" ]; then + echo "Provisioning clboss - run config script" >> ${logFile} + /home/admin/_cache.sh set message "Setup clboss" + sudo -u admin /home/admin/config.scripts/cl-plugin.clboss.sh on >> ${logFile} 2>&1 +else + echo "Provisioning clboss - keep default" >> ${logFile} +fi + +# clWatchtowerClient +if [ "${clWatchtowerClient}" = "on" ]; then + echo "Provisioning clWatchtowerClient - run config script" >> ${logFile} + /home/admin/_cache.sh set message "Setup clWatchtowerClient" + sudo -u admin /home/admin/config.scripts/cl-plugin.watchtower-client.sh on >> ${logFile} 2>&1 +else + echo "Provisioning clWatchtowerClient - keep default" >> ${logFile} +fi + # SPARK if [ "${spark}" = "on" ]; then echo "Provisioning Spark Wallet - run config script" >> ${logFile} diff --git a/home.admin/config.scripts/cl-plugin.watchtower-client.sh b/home.admin/config.scripts/cl-plugin.watchtower-client.sh new file mode 100644 index 000000000..0c7378aae --- /dev/null +++ b/home.admin/config.scripts/cl-plugin.watchtower-client.sh @@ -0,0 +1,125 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then + echo + echo "Install the rust-teos watchtower-client plugin for CLN" + echo "Usage:" + echo "cl-plugin.watchtower-client.sh on " + echo "cl-plugin.watchtower-client.sh off " + echo "cl-plugin.watchtower-client.sh info" + echo + exit 1 +fi + +echo "# cl-plugin.watchtower-client.sh $*" + +source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2) +source /mnt/hdd/raspiblitz.conf #to get runBehindTor +plugin="watchtower-client" +pkg_dependencies="libssl-dev" + + +if [ "$1" = info ]; then + whiptail --title "The Eye of Satoshi CLN Watchtower" \ + --msgbox " +This is a watchtower client plugin to interact with an Eye of Satoshi tower, and +eventually with any BOLT13 compliant watchtower. + +The plugin manages all the client-side logic to send appointment to a number of +registered towers every time a new commitment transaction is generated. +It also keeps a summary of the messages sent to the towers and their responses. + +Usage (from the command line): + +cl registertower : registers the user id (compressed public key) with a given tower. +cl gettowerinfo : gets all the locally stored data about a given tower. +cl retrytower : tries to send pending appointment to a (previously) unreachable tower. +cl abandontower : deletes all data associated with a given tower. +cl listtowers: lists all registered towers. +cl getappointment : queries a given tower about an appointment. +cl getsubscriptioninfo : gets the subscription information by querying the tower. +cl getappointmentreceipt : pulls a given appointment receipt from the local database. +cl getregistrationreceipt : pulls the latest registration receipt from the local database. + +Links with more info: +https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin +" 0 0 + exit 0 +fi + + +if [ "$1" = "on" ];then + + # rust for rust-teos, includes rustfmt + sudo -u bitcoin curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ + sudo -u bitcoin sh -s -- -y + + #Cleanup existing + if [ -d "/home/bitcoin/cl-plugins-available/plugins/${plugin}/" ]; then + sudo rm -rf "/home/bitcoin/cl-plugins-available/plugins/${plugin}/" + fi + + if [ -d "/home/bitcoin/cl-plugins-available/rust-teos/" ]; then + sudo rm -rf "/home/bitcoin/cl-plugins-available/rust-teos/" + fi + + #Clone source repository + cd /home/bitcoin/cl-plugins-available || exit 1 + sudo -u bitcoin git clone https://github.com/talaia-labs/rust-teos.git + + #Install additional dependencies + sudo apt-get install -y ${pkg_dependencies} > /dev/null + + #Compile + cd /home/bitcoin/cl-plugins-available/rust-teos || exit 1 + sudo -u bitcoin /home/bitcoin/.cargo/bin/cargo install --path watchtower-plugin \ + --target-dir /home/bitcoin/cl-plugins-available/${plugin} + + #Symlink to enable + if [ ! -L /home/bitcoin/${netprefix}cl-plugins-enabled/${plugin} ]; then + echo "Running: sudo -u bitcoin ln -s /home/bitcoin/cl-plugins-available/${plugin}/release/${plugin} /home/bitcoin/${netprefix}cl-plugins-enabled/${plugin}" + sudo -u bitcoin ln -s /home/bitcoin/cl-plugins-available/${plugin}/release/${plugin} /home/bitcoin/${netprefix}cl-plugins-enabled/${plugin} + fi + + #check if toronly node, then add watchtower-proxy config to CL + if [ "$runBehindTor" = on ]; then + echo "watchtower-proxy=127.0.0.1:9050" | sudo tee -a ${CLCONF} + fi + + # setting value in raspiblitz.conf + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clWatchtowerClient "on" + + source <(/home/admin/_cache.sh get state) + if [ "${state}" == "ready" ]; then + echo "# Restart the ${netprefix}lightningd.service to activate watchtower-client" + sudo systemctl restart ${netprefix}lightningd + fi + +fi + + +if [ "$1" = off ];then + # delete symlink + sudo rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/${plugin} + + # delete watchtower-proxy config line from ${CLCONF} + sudo sed -i '/watchtower-proxy=/d' ${CLCONF} + + echo "# Restart the ${netprefix}lightningd.service to deactivate ${plugin}" + sudo systemctl restart ${netprefix}lightningd + + # purge + if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then + echo "# Delete plugin and source code" + sudo rm -rf /home/bitcoin/cl-plugins-available/rust-teos* + sudo rm -rf /home/bitcoin/cl-plugins-available/${plugin} + fi + + + # setting value in raspi blitz config + /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clWatchtowerClient "off" + echo "# watchtower-client was uninstalled for ${CHAIN}" + +fi +