mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-30 14:06:08 +02:00
Adapt scripts to provide key-value connection details for BlitzAPI (#3112)
This commit is contained in:
@@ -4,7 +4,14 @@
|
|||||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
echo "# config script to connect mobile apps with lnd connect"
|
echo "# config script to connect mobile apps with lnd connect"
|
||||||
echo "# will autodetect dyndns, sshtunnel or TOR"
|
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|fullynoded-lnd] [?ip|tor]"
|
echo "# bonus.lndconnect.sh [zap-ios|zap-android|zeus-ios|zeus-android|shango-ios|shango-android|sendmany-android|fullynoded-lnd] [?ip|tor] [?key-value]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if lnd is on
|
||||||
|
source <(/home/admin/_cache.sh get lnd)
|
||||||
|
if [ "${lnd}" != on ]; then
|
||||||
|
echo "error='lnd not active'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -206,6 +213,11 @@ fi
|
|||||||
# see spec here: https://github.com/LN-Zap/lndconnect/blob/master/lnd_connect_uri.md
|
# see spec here: https://github.com/LN-Zap/lndconnect/blob/master/lnd_connect_uri.md
|
||||||
lndconnect="lndconnect://${host}:${port}${macaroonParameter}${certParameter}"
|
lndconnect="lndconnect://${host}:${port}${macaroonParameter}${certParameter}"
|
||||||
|
|
||||||
|
if [ "$3" == "key-value" ]; then
|
||||||
|
echo "lndconnect='${lndconnect}'"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# display qr code image on LCD
|
# display qr code image on LCD
|
||||||
sudo /home/admin/config.scripts/blitz.display.sh qr "${lndconnect}"
|
sudo /home/admin/config.scripts/blitz.display.sh qr "${lndconnect}"
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ if [ $# -eq 0 ]||[ "$1" = "-h" ]||[ "$1" = "--help" ];then
|
|||||||
echo "The same macaroon and certs will be used for the parallel networks"
|
echo "The same macaroon and certs will be used for the parallel networks"
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "cl.rest.sh [on|off|connect] <mainnet|testnet|signet>"
|
echo "cl.rest.sh [on|off|connect] <mainnet|testnet|signet> [?key-value]"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -23,14 +23,24 @@ echo "# Running 'cl.rest.sh $*'"
|
|||||||
|
|
||||||
if [ "$1" = connect ];then
|
if [ "$1" = connect ];then
|
||||||
echo "# Allowing port ${portprefix}6100 through the firewall"
|
echo "# Allowing port ${portprefix}6100 through the firewall"
|
||||||
sudo ufw allow "${portprefix}6100" comment "${netprefix}clrest"
|
sudo ufw allow "${portprefix}6100" comment "${netprefix}clrest" 1>/dev/null
|
||||||
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||||
# hidden service to https://xx.onion
|
# hidden service to https://xx.onion
|
||||||
/home/admin/config.scripts/tor.onion-service.sh ${netprefix}clrest 443 ${portprefix}6100
|
/home/admin/config.scripts/tor.onion-service.sh ${netprefix}clrest 443 ${portprefix}6100 1>/dev/null
|
||||||
|
|
||||||
toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}clrest/hostname)
|
toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}clrest/hostname)
|
||||||
hex_macaroon=$(xxd -plain /home/bitcoin/c-lightning-REST/certs/access.macaroon | tr -d '\n')
|
hex_macaroon=$(xxd -plain /home/bitcoin/c-lightning-REST/certs/access.macaroon | tr -d '\n')
|
||||||
url="https://${localip}:${portprefix}6100/"
|
url="https://${localip}:${portprefix}6100/"
|
||||||
|
lndconnect="lndconnect://${toraddress}:443?macaroon=${hex_macaroon}"
|
||||||
|
|
||||||
|
if [ "$3" == "key-value" ]; then
|
||||||
|
echo "toraddress='${toraddress}'"
|
||||||
|
echo "local='${url}'"
|
||||||
|
echo "macaroon='${hex_macaroon}'"
|
||||||
|
echo "connectstring='${lndconnect}'"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
#string="${url}?${hex_macaroon}"
|
#string="${url}?${hex_macaroon}"
|
||||||
#sudo /home/admin/config.scripts/blitz.display.sh qr "$string"
|
#sudo /home/admin/config.scripts/blitz.display.sh qr "$string"
|
||||||
#clear
|
#clear
|
||||||
|
@@ -3,7 +3,14 @@
|
|||||||
# command info
|
# command info
|
||||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
echo "tool to export macaroons & tls.cert"
|
echo "tool to export macaroons & tls.cert"
|
||||||
echo "lnd.export.sh [hexstring|scp|http|btcpay]"
|
echo "lnd.export.sh [hexstring|scp|http|btcpay] [?key-value]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if lnd is on
|
||||||
|
source <(/home/admin/_cache.sh get lnd)
|
||||||
|
if [ "${lnd}" != on ]; then
|
||||||
|
echo "error='lnd not active'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -59,13 +66,14 @@ if [ ${#exportType} -eq 0 ]; then
|
|||||||
########################
|
########################
|
||||||
elif [ "${exportType}" = "hexstring" ]; then
|
elif [ "${exportType}" = "hexstring" ]; then
|
||||||
|
|
||||||
|
adminMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon)
|
||||||
|
invoiceMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/invoice.macaroon)
|
||||||
|
readonlyMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/readonly.macaroon)
|
||||||
clear
|
clear
|
||||||
echo "###### HEXSTRING EXPORT ######"
|
echo "###### HEXSTRING EXPORT ######"
|
||||||
echo ""
|
echo ""
|
||||||
adminMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon)
|
|
||||||
echo "adminMacaroon=${adminMacaroon}"
|
echo "adminMacaroon=${adminMacaroon}"
|
||||||
echo ""
|
echo ""
|
||||||
invoiceMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/invoice.macaroon)
|
|
||||||
echo "invoiceMacaroon=${invoiceMacaroon}"
|
echo "invoiceMacaroon=${invoiceMacaroon}"
|
||||||
echo ""
|
echo ""
|
||||||
readonlyMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/readonly.macaroon)
|
readonlyMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/readonly.macaroon)
|
||||||
@@ -80,6 +88,13 @@ elif [ "${exportType}" = "hexstring" ]; then
|
|||||||
########################
|
########################
|
||||||
elif [ "${exportType}" = "btcpay" ]; then
|
elif [ "${exportType}" = "btcpay" ]; then
|
||||||
|
|
||||||
|
# lnd needs to be unlocked
|
||||||
|
source <(/home/admin/_cache.sh get ln_lnd_mainnet_locked)
|
||||||
|
if [ "${ln_lnd_mainnet_locked}" == "1" ]; then
|
||||||
|
echo "error='lnd wallet needs to be unlocked'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# take public IP as default
|
# take public IP as default
|
||||||
# TODO: IP2TOR --> check if there is a forwarding for LND REST oe ask user to set one up
|
# TODO: IP2TOR --> check if there is a forwarding for LND REST oe ask user to set one up
|
||||||
#ip="${publicIP}"
|
#ip="${publicIP}"
|
||||||
@@ -101,6 +116,11 @@ elif [ "${exportType}" = "btcpay" ]; then
|
|||||||
# construct connection string
|
# construct connection string
|
||||||
connectionString="type=lnd-rest;server=https://${ip}:${port}/;macaroon=${macaroon};certthumbprint=${certthumb}"
|
connectionString="type=lnd-rest;server=https://${ip}:${port}/;macaroon=${macaroon};certthumbprint=${certthumb}"
|
||||||
|
|
||||||
|
if [ "$2" == "key-value" ]; then
|
||||||
|
echo "connectionString='${connectionString}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo "###### BTCPAY CONNECTION STRING ######"
|
echo "###### BTCPAY CONNECTION STRING ######"
|
||||||
echo ""
|
echo ""
|
||||||
|
@@ -102,8 +102,8 @@ HiddenServicePort $toPort 127.0.0.1:$fromPort" | sudo tee -a "${torrc_services}"
|
|||||||
sudo cp "${torrc_services}" /var/cache/raspiblitz/tmp
|
sudo cp "${torrc_services}" /var/cache/raspiblitz/tmp
|
||||||
sudo chmod 777 /var/cache/raspiblitz/tmp
|
sudo chmod 777 /var/cache/raspiblitz/tmp
|
||||||
sudo chown -R admin:admin /var/cache/raspiblitz/tmp
|
sudo chown -R admin:admin /var/cache/raspiblitz/tmp
|
||||||
sudo awk 'NF > 0 {blank=0} NF == 0 {blank++} blank < 2' "${torrc_services}" > /var/cache/raspiblitz/tmp
|
sudo awk 'NF > 0 {blank=0} NF == 0 {blank++} blank < 2' "${torrc_services}" > /var/cache/raspiblitz/tmp/services
|
||||||
sudo mv /var/cache/raspiblitz/tmp "${torrc_services}"
|
sudo mv /var/cache/raspiblitz/tmp/services "${torrc_services}"
|
||||||
sudo chmod 644 "${torrc_services}"
|
sudo chmod 644 "${torrc_services}"
|
||||||
sudo chown bitcoin:bitcoin "${torrc_services}"
|
sudo chown bitcoin:bitcoin "${torrc_services}"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user