Merge CL Watchtower #3394 (#3501)

* Bonus script to install CLN Watchtower client rust-teos ("The Eye of Satoshi") (#3404)

* TEoS watchtower bonus install script

* Add Menu items

* add READ & CHANGES info

* On Purge, delete source and plugin

* Add sys pkg_dependecies

* Cleanup before clone

* Add cl plugins to _provision.sh and Info menu

Co-authored-by: rootzoll <christian@geektank.de>

* adapt info

* Add Watchtower info to menu

Co-authored-by: steepdawn974 <92274076+steepdawn974@users.noreply.github.com>
This commit is contained in:
/rootzoll 2022-12-08 12:56:30 +01:00 committed by GitHub
parent 9fe1c47048
commit e19b5911cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 181 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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 <testnet|mainnet|signet>"
echo "cl-plugin.watchtower-client.sh off <testnet|mainnet|signet> <purge>"
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 <tower_id>: registers the user id (compressed public key) with a given tower.
cl gettowerinfo <tower_id>: gets all the locally stored data about a given tower.
cl retrytower <tower_id>: tries to send pending appointment to a (previously) unreachable tower.
cl abandontower <tower_id>: deletes all data associated with a given tower.
cl listtowers: lists all registered towers.
cl getappointment <tower_id> <locator>: queries a given tower about an appointment.
cl getsubscriptioninfo <tower_id>: gets the subscription information by querying the tower.
cl getappointmentreceipt <tower_id> <locator>: pulls a given appointment receipt from the local database.
cl getregistrationreceipt <tower_id>: 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