Skip to content

Commit

Permalink
feat: add BTCPAY-CLN to CONNECT raspiblitz#3155
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Jun 2, 2022
1 parent 56cfb1d commit b805e1e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
14 changes: 11 additions & 3 deletions home.admin/99connectMenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ OPTIONS+=(MOBILE "Connect Mobile Wallet")
if [ "${ElectRS}" == "on" ]; then
OPTIONS+=(ELECTRS "Electrum Rust Server")
fi
if [ "${BTCPayServer}" == "on" ]; then
OPTIONS+=(BTCPAY "Show LND connection string")
if [ "${BTCPayServer}" == "on" ] && [ "${lnd}" = "on" ]; then
OPTIONS+=(BTCPAY-LND "Show LND connection string")
fi
if [ "${BTCPayServer}" == "on" ] && [ "${cl}" = "on" ]; then
OPTIONS+=(BTCPAY-CLN "Show CLN connection string")
fi
OPTIONS+=(${network}RPC "Connect Specter Desktop or JoinMarket")
OPTIONS+=(BISQ "Connect Bisq to this node")
Expand Down Expand Up @@ -50,11 +53,16 @@ case $CHOICE in
/home/admin/97addMobileWallet.sh;;
ELECTRS)
/home/admin/config.scripts/bonus.electrs.sh menu;;
BTCPAY)
BTCPAY-LND)
/home/admin/config.scripts/lnd.export.sh btcpay
echo "Press ENTER to return to main menu."
read key
exit 0;;
BTCPAY-CLN)
/home/admin/config.scripts/bonus.btcpayserver.sh cln-lightning-rpc-access
echo "Press ENTER to return to main menu."
read key
exit 0;;
RESET)
sudo /home/admin/config.scripts/lnd.credentials.sh reset
sudo /home/admin/config.scripts/lnd.credentials.sh sync
Expand Down
42 changes: 39 additions & 3 deletions home.admin/config.scripts/bonus.btcpayserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BTCPayVersion="v1.5.4"
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "Config script to switch BTCPay Server on or off"
echo "Usage:"
echo "bonus.btcpayserver.sh [on|off|menu|write-tls-macaroon]"
echo "bonus.btcpayserver.sh [on|off|menu|write-tls-macaroon|cln-lightning-rpc-access]"
echo "installs BTCPayServer $BTCPayVersion with NBXplorer $NBXplorerVersion"
echo "To update to the latest release published on github run:"
echo "bonus.btcpayserver.sh update"
Expand Down Expand Up @@ -211,6 +211,38 @@ BTC.lightning=type=lnd-rest;server=https://127.0.0.1:8080/;macaroonfilepath=/hom
exit 0
fi

# cln-lightning-rpc-access
if [ "$1" = "cln-lightning-rpc-access" ]; then
if [ "${cl}" = "on" ]; then
source <(/home/admin/config.scripts/network.aliases.sh getvars cl mainnet)

if [ $(grep -c "^rpc-file-mode=0660" < ${CLCONF}) -eq 0 ]; then
echo "rpc-file-mode=0660" | tee -a ${CLCONF}
if [ "${state}" == "ready" ]; then
sudo systemctl restart lightningd
fi
fi

echo "# make sure btcpay is member of the bitcoin group"
sudo /usr/sbin/usermod --append --groups bitcoin btcpay

if [ "${state}" == "ready" ]; then
sudo systemctl restart btcpayserver
fi
else
echo "# Install CLN first"
exit 1
fi

echo "
In the BTCPayServer Lightning Wallet settings 'Connect to a Lightning node' page
fill in the 'Connection configuration for your custom Lightning node:' box on with:
type=clightning;server=unix:///home/bitcoin/.lightning/bitcoin/lightning-rpc
"
exit 0
fi

# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# INSTALL BTCPAYSERVER"
Expand Down Expand Up @@ -498,8 +530,12 @@ WantedBy=multi-user.target
fi

sudo -u btcpay mkdir -p /home/btcpay/.btcpayserver/Main/
/home/admin/config.scripts/bonus.btcpayserver.sh write-tls-macaroon

if [ ${lnd} = on ]; then
/home/admin/config.scripts/bonus.btcpayserver.sh write-tls-macaroon
fi
if [ ${cl} = on ]; then
/home/admin/config.scripts/bonus.btcpayserver.sh cln-lightning-rpc-access
fi
else
echo "# BTCPay Server is already installed."
if [ "${state}" == "ready" ]; then
Expand Down
7 changes: 7 additions & 0 deletions home.admin/config.scripts/cl.check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ if [ "${LNBitsFunding}" = "${netprefix}cl" ]; then
fi
fi

if [ "${BTCPayServer}" = "on" ] && [ "${CHAIN}" = "mainnet" ] ; then
# https://github.com/rootzoll/raspiblitz/issues/3007
if [ $(grep -c "^rpc-file-mode=0660" < ${CLCONF}) -eq 0 ]; then
echo "rpc-file-mode=0660" | tee -a ${CLCONF}
fi
fi

if [ $(grep -c "^grpc-port" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc ]\
|| [ "$(eval echo \$${netprefix}cln-grpc-port)" = "off" ]; then
Expand Down

0 comments on commit b805e1e

Please sign in to comment.