mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-26 19:47:05 +02:00
Spark Wallet integration (#2585)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
- New: C-lightning v0.10.1 [details](https://github.com/ElementsProject/lightning/releases/tag/v0.10.1)
|
||||
- New: C-lightningREST v0.5.1 [details](https://github.com/Ride-The-Lightning/c-lightning-REST/releases/tag/v0.5.1)
|
||||
- New: CL Spark Wallet v0.3.0rc with BOLT12 offers [details](https://github.com/shesek/spark-wallet/releases)
|
||||
- New: CL plugin: Sparko [details](https://github.com/fiatjaf/sparko)
|
||||
- New: CL plugin: CLBOSS The C-Lightning Node Manager [details](https://github.com/ZmnSCPxj/clboss#clboss-the-c-lightning-node-manager)
|
||||
- New: Refactored Setup-Process [details](https://github.com/rootzoll/raspiblitz/issues/1126#issuecomment-829757665)
|
||||
|
@@ -33,6 +33,7 @@ There are further Services that can be switched on:
|
||||
* **Telegraf metrics** [details](https://github.com/rootzoll/raspiblitz/issues/1369)
|
||||
* **Chantools** (Fund Rescue) [details](https://github.com/guggero/chantools/blob/master/README.md)
|
||||
* **Suez** (Channel Visualization for LND & CL) [details](https://github.com/prusnak/suez#suez)
|
||||
* **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)
|
||||
|
||||
|
@@ -95,6 +95,9 @@ fi
|
||||
if [ "${sparko}" == "on" ]; then
|
||||
OPTIONS+=(SPARKO "Sparko Webwallet")
|
||||
fi
|
||||
if [ "${spark}" == "on" ]; then
|
||||
OPTIONS+=(SPARK "Spark Wallet")
|
||||
fi
|
||||
if [ "${ElectRS}" == "on" ]; then
|
||||
OPTIONS+=(ELECTRS "Electrum Rust Server")
|
||||
fi
|
||||
@@ -248,6 +251,9 @@ case $CHOICE in
|
||||
SPARKO)
|
||||
/home/admin/config.scripts/cl-plugin.sparko.sh menu mainnet
|
||||
;;
|
||||
SPARK)
|
||||
/home/admin/config.scripts/cl.spark.sh menu mainnet
|
||||
;;
|
||||
LNBITS)
|
||||
/home/admin/config.scripts/bonus.lnbits.sh menu
|
||||
;;
|
||||
|
@@ -14,6 +14,7 @@ if [ ${#lnd} -eq 0 ]; then lnd="off"; fi
|
||||
if [ ${#cl} -eq 0 ]; then cl="off"; fi
|
||||
if [ ${#crtlWebinterface} -eq 0 ]; then crtlWebinterface="off"; fi
|
||||
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
|
||||
if [ ${#spark} -eq 0 ]; then spark="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
@@ -24,6 +25,7 @@ OPTIONS+=(r "RTL for LND $CHAIN" ${rtlWebinterface})
|
||||
OPTIONS+=(c "C-lightning on $CHAIN" ${cl})
|
||||
OPTIONS+=(t "RTL for CL on $CHAIN" ${crtlWebinterface})
|
||||
OPTIONS+=(s "Sparko for CL on $CHAIN" ${sparko})
|
||||
OPTIONS+=(m "Spark for CL on $CHAIN" ${spark})
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Services ' \
|
||||
--checklist ' use spacebar to activate/de-activate ' \
|
||||
@@ -162,6 +164,28 @@ else
|
||||
echo "# Sparko on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# spark process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "m")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${spark}" != "${choice}" ]; then
|
||||
echo "# Spark Wallet on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cl.spark.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
/home/admin/config.scripts/cl.spark.sh menu $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on Spark Wallet on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cl.spark.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Spark Wallet on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
exit 0
|
||||
|
@@ -14,6 +14,7 @@ if [ ${#tlnd} -eq 0 ]; then tlnd="off"; fi
|
||||
if [ ${#tcrtlWebinterface} -eq 0 ]; then tcrtlWebinterface="off"; fi
|
||||
if [ ${#tcl} -eq 0 ]; then tcl="off"; fi
|
||||
if [ ${#tsparko} -eq 0 ]; then tsparko="off"; fi
|
||||
if [ ${#tspark} -eq 0 ]; then tspark="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
@@ -24,6 +25,7 @@ OPTIONS+=(r "RTL for LND $CHAIN" ${trtlWebinterface})
|
||||
OPTIONS+=(c "C-lightning on $CHAIN" ${tcl})
|
||||
OPTIONS+=(t "RTL for CL on $CHAIN" ${tcrtlWebinterface})
|
||||
OPTIONS+=(s "Sparko for CL on $CHAIN" ${tsparko})
|
||||
OPTIONS+=(m "Spark Wallet fro CL on $CHAIN" ${tspark})
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Services ' \
|
||||
--checklist ' use spacebar to activate/de-activate ' \
|
||||
@@ -162,7 +164,27 @@ else
|
||||
echo "# Sparko on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
|
||||
# tspark process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "m")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${tspark}" != "${choice}" ]; then
|
||||
echo "# Spark Wallet on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cl.spark.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
/home/admin/config.scripts/cl.spark.sh menu $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on Spark Wallet on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cl.spark.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Spark Wallet on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
|
@@ -25,6 +25,7 @@ if [ ${#lit} -eq 0 ]; then lit="off"; fi
|
||||
if [ ${#whitepaper} -eq 0 ]; then whitepaper="off"; fi
|
||||
if [ ${#chantools} -eq 0 ]; then chantools="off"; fi
|
||||
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
|
||||
if [ ${#spark} -eq 0 ]; then spark="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
@@ -58,6 +59,7 @@ fi
|
||||
if [ "${lightning}" == "cl" ] || [ "${cl}" == "on" ]; then
|
||||
OPTIONS+=(c 'C-Lightning RTL Webinterface' ${crtlWebinterface})
|
||||
OPTIONS+=(k 'C-Lightning Sparko WebWallet' ${sparko})
|
||||
OPTIONS+=(m 'C-Lightning Spark Wallet' ${spark})
|
||||
fi
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Mainnet Services ' \
|
||||
@@ -496,6 +498,28 @@ else
|
||||
echo "# Sparko on mainnet Setting unchanged."
|
||||
fi
|
||||
|
||||
# spark wallet process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "m")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${spark}" != "${choice}" ]; then
|
||||
echo "# Spark Wallet on mainnet Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cl.spark.sh ${choice} mainnet
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
/home/admin/config.scripts/cl.spark.sh menu mainnet
|
||||
else
|
||||
l1="# !!! FAIL on Spark Wallet on mainnet install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cl.spark.sh on mainnet"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Spark Wallet on mainnet Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
exit 0
|
||||
|
@@ -451,10 +451,19 @@ fi
|
||||
# SPARKO
|
||||
if [ "${sparko}" = "on" ]; then
|
||||
echo "Provisioning Sparko - run config script" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup SPARKO (takes time)'/g" ${infoFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup SPARKO'/g" ${infoFile}
|
||||
sudo -u admin /home/admin/config.scripts/cl-plugin.sparko.sh on mainnet >> ${logFile} 2>&1
|
||||
else
|
||||
echo "Provisioning RTL CL - keep default" >> ${logFile}
|
||||
echo "Provisioning Sparko - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# SPARK
|
||||
if [ "${spark}" = "on" ]; then
|
||||
echo "Provisioning Spark Wallet - run config script" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup SPARK WALLET'/g" ${infoFile}
|
||||
sudo -u admin /home/admin/config.scripts/cl.spark.sh on mainnet >> ${logFile} 2>&1
|
||||
else
|
||||
echo "Provisioning Spark Wallet - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
#LOOP - install only if LiT won't be installed
|
||||
|
180
home.admin/config.scripts/cl.spark.sh
Normal file
180
home.admin/config.scripts/cl.spark.sh
Normal file
@@ -0,0 +1,180 @@
|
||||
#!/bin/bash
|
||||
|
||||
#https://github.com/shesek/spark-wallet/releases
|
||||
SPARKVERSION="v0.3.0rc"
|
||||
|
||||
# command info
|
||||
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
||||
echo
|
||||
echo "Install, remove or get info about the Spark Wallet for C-lightning"
|
||||
echo "version: $SPARKVERSION"
|
||||
echo "Usage:"
|
||||
echo "cl.spark.sh [on|off|menu] <testnet|mainnet|signet> "
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>)
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
|
||||
systemdService="${netprefix}spark"
|
||||
|
||||
|
||||
# show info menu
|
||||
if [ "$1" = "menu" ]; then
|
||||
|
||||
# get network info
|
||||
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}spark-wallet/hostname)
|
||||
toraddresstext="Hidden Service address for the Tor Browser (QRcode on LCD):\n$toraddress"
|
||||
if [ ${#toraddress} -eq 0 ];then
|
||||
toraddresstext="Activate Tor to access the web interface from outside of the local network."
|
||||
else
|
||||
/home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
|
||||
fi
|
||||
fingerprint=$(openssl x509 -in /home/bitcoin/.lightning/spark-tls/cert.pem -fingerprint -noout | cut -d"=" -f2)
|
||||
|
||||
whiptail --title "\
|
||||
spark - $CHAIN" --msgbox "Open in your local web browser:
|
||||
https://${localip}:${portprefix}8000\n
|
||||
username: blitz
|
||||
password: 'your Password B'\n
|
||||
Accept the self-signed SSL certificate with the fingerprint:
|
||||
${fingerprint}\n
|
||||
${toraddresstext}
|
||||
" 17 67
|
||||
|
||||
/home/admin/config.scripts/blitz.display.sh hide
|
||||
|
||||
echo "# please wait ..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# add default value to raspiblitz.conf if needed
|
||||
configEntry="${netprefix}spark="
|
||||
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 = on ];then
|
||||
|
||||
# check and install NodeJS
|
||||
/home/admin/config.scripts/bonus.nodejs.sh on
|
||||
|
||||
# set up npm-global
|
||||
sudo -u bitcoin mkdir /home/bitcoin/.npm-global
|
||||
sudo -u bitcoin npm config set prefix '/home/bitcoin/.npm-global'
|
||||
sudo bash -c "echo 'PATH=$PATH:/home/bitcoin/.npm-global/bin' >> /home/bitcoin/.bashrc"
|
||||
|
||||
echo "# Create data folder on the disk"
|
||||
echo "# make sure the data directory exists"
|
||||
sudo mkdir -p /mnt/hdd/app-data/.spark-wallet
|
||||
echo "# symlink"
|
||||
sudo rm -rf /home/bitcoin/.spark-wallet # not a symlink.. delete it silently
|
||||
sudo ln -s /mnt/hdd/app-data/.spark-wallet/ /home/bitcoin/.spark-wallet
|
||||
sudo chown bitcoin:bitcoin -R /mnt/hdd/app-data/.spark-wallet
|
||||
|
||||
cd /home/bitcoin || exit 1
|
||||
sudo -u bitcoin git clone https://github.com/shesek/spark-wallet
|
||||
cd spark-wallet || exit 1
|
||||
sudo -u bitcoin git reset --hard ${SPARKVERSION} || exit 1
|
||||
sudo -u bitcoin npm run dist:npm || exit 1
|
||||
|
||||
if [ ! -f /home/bitcoin/.spark-wallet/tls/key.pem ];then
|
||||
# create a self signed cert https://github.com/fiatjaf/spark#how-to-use
|
||||
/home/admin/config.scripts/internet.selfsignedcert.sh
|
||||
# spark looks for specific filenames
|
||||
sudo -u bitcoin mkdir -p /home/bitcoin/.spark-wallet/tls/
|
||||
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.key \
|
||||
/home/bitcoin/.spark-wallet/tls/key.pem
|
||||
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.cert \
|
||||
/home/bitcoin/.spark-wallet/tls/cert.pem
|
||||
fi
|
||||
|
||||
##########
|
||||
# Config #
|
||||
##########
|
||||
if [ -f /home/bitcoin/.spark-wallet/${netprefix}config ];then
|
||||
echo "# ${netprefix}spark config is already present"
|
||||
else
|
||||
PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-)
|
||||
echo "\
|
||||
login=blitz:${PASSWORD_B}
|
||||
host=0.0.0.0
|
||||
proxy=socks5h://127.0.0.1:9050
|
||||
tls-path=/home/bitcoin/.lightning/spark-tls
|
||||
onion
|
||||
" | sudo -u bitcoin tee /home/bitcoin/.spark-wallet/${netprefix}config
|
||||
fi
|
||||
|
||||
#################
|
||||
# SYSTEMD SERVICE
|
||||
#################
|
||||
# https://raw.githubusercontent.com/shesek/spark-wallet/master/scripts/spark-wallet.service
|
||||
echo "# Create Systemd Service: ${systemdService}.service"
|
||||
echo "
|
||||
# Systemd unit for ${systemdService}
|
||||
|
||||
[Unit]
|
||||
Description=${systemdService} Lightning Wallet
|
||||
Wants=${netprefix}lightningd.service
|
||||
After=${netprefix}lightningd.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/home/bitcoin/spark-wallet
|
||||
ExecStart=/home/bitcoin/spark-wallet/dist/cli.js\
|
||||
--ln-path /home/bitcoin/.lightning/${CLNETWORK} --port 8000\
|
||||
--config /home/bitcoin/.spark-wallet/config
|
||||
User=bitcoin
|
||||
Restart=on-failure
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
# Hardening measures
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${systemdService}.service
|
||||
sudo chown root:root /etc/systemd/system/${systemdService}.service
|
||||
|
||||
echo "# Allowing port ${portprefix}8000 through the firewall"
|
||||
sudo ufw allow "${portprefix}8000" comment "${netprefix}spark-wallet"
|
||||
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh ${netprefix}spark-wallet 443 ${portprefix}8000
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}spark=.*/${netprefix}spark=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
sudo systemctl enable ${systemdService}
|
||||
sudo systemctl start ${systemdService}
|
||||
echo "# OK - the ${systemdService}.service is now enabled & started"
|
||||
echo "# Monitor with: sudo journalctl -f -u ${systemdService}"
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
if [ $1 = off ];then
|
||||
|
||||
sudo systemctl stop ${systemdService} 2>/dev/null
|
||||
sudo systemctl disable ${systemdService} 2>/dev/null
|
||||
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh off ${netprefix}spark-wallet
|
||||
|
||||
# purge
|
||||
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
|
||||
echo "# Delete user and home directory"
|
||||
/home/bitcoin/spark-wallet
|
||||
fi
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}spark=.*/${netprefix}spark=off/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# ${netprefix}spark was uninstalled"
|
||||
fi
|
Reference in New Issue
Block a user