enable tor for cln and lnbits

This commit is contained in:
Riccardo Balbo 2024-10-26 11:36:03 +02:00
parent 33c4314212
commit 4fb873b105
5 changed files with 69 additions and 3 deletions

View File

@ -471,7 +471,11 @@ services:
healthcheck: healthcheck:
<<: *healthcheck <<: *healthcheck
test: ["CMD-SHELL", "su clightning -c 'lightning-cli --network=regtest getinfo'"] test: ["CMD-SHELL", "su clightning -c 'lightning-cli --network=regtest getinfo'"]
depends_on: *depends_on_bitcoin depends_on:
tor:
condition: service_healthy
restart: true
<<: *depends_on_bitcoin
env_file: *env_file env_file: *env_file
command: command:
- 'lightningd' - 'lightningd'
@ -490,6 +494,7 @@ services:
- "${STACKER_CLN_REST_PORT}:3010" - "${STACKER_CLN_REST_PORT}:3010"
volumes: volumes:
- stacker_cln:/home/clightning/.lightning - stacker_cln:/home/clightning/.lightning
- tordata:/home/clightning/.tor
labels: labels:
ofelia.enabled: "true" ofelia.enabled: "true"
ofelia.job-exec.stacker_cln_channel_cron.schedule: "@every 1m" ofelia.job-exec.stacker_cln_channel_cron.schedule: "@every 1m"
@ -614,7 +619,12 @@ services:
ports: ports:
- "${LNBITS_WEB_PORT}:5000" - "${LNBITS_WEB_PORT}:5000"
depends_on: depends_on:
- stacker_lnd tor:
condition: service_healthy
restart: true
stacker_lnd:
condition: service_healthy
restart: true
environment: environment:
- LNBITS_ADMIN_UI=true - LNBITS_ADMIN_UI=true
- LNBITS_BACKEND_WALLET_CLASS=LndWallet - LNBITS_BACKEND_WALLET_CLASS=LndWallet
@ -624,6 +634,7 @@ services:
- LND_GRPC_MACAROON=/app/.lnd/regtest/admin.macaroon - LND_GRPC_MACAROON=/app/.lnd/regtest/admin.macaroon
volumes: volumes:
- ./docker/lnd/stacker:/app/.lnd - ./docker/lnd/stacker:/app/.lnd
- tordata:/app/.tor
labels: labels:
CONNECT: "localhost:${LNBITS_WEB_PORT}" CONNECT: "localhost:${LNBITS_WEB_PORT}"
cpu_shares: "${CPU_SHARES_LOW}" cpu_shares: "${CPU_SHARES_LOW}"

View File

@ -1 +1,3 @@
HiddenServicePort 10009 stacker_lnd:10009 HiddenServicePort 10009 stacker_lnd:10009
HiddenServicePort 3010 stacker_cln:3010
HiddenServicePort 5000 lnbits:5000

36
sndev
View File

@ -56,12 +56,19 @@ docker__stacker_lnd() {
docker__stacker_cln() { docker__stacker_cln() {
t=$1 t=$1
if [ "$t" = "-t" ]; then if [ "$t" = "-t" ]; then
shift shift
else else
t="" t=""
fi fi
if [ "$1" = "get_onion" ]; then
onion="$(docker__exec -t stacker_cln cat /home/clightning/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion:3010"
exit 0
fi
docker__exec $t -u clightning stacker_cln lightning-cli --regtest "$@" docker__exec $t -u clightning stacker_cln lightning-cli --regtest "$@"
} }
@ -414,6 +421,9 @@ sndev__stacker_clncli() {
sndev__help_stacker_clncli() { sndev__help_stacker_clncli() {
docker__stacker_cln help docker__stacker_cln help
echo
echo "EXTRA:"
echo " get_onion get the onion address"
} }
sndev__stacker_litcli() { sndev__stacker_litcli() {
@ -551,6 +561,29 @@ sndev__stacker_lnd() {
fi fi
} }
sndev__help_lnbits() {
help="
USAGE
$ sndev stacker_lnbits get_onion get the onion address
"
}
sndev__lnbits() {
shift
if [ -z "$1" ]; then
echo "no command provided"
sndev__help_lnbits
exit 1
fi
if [ "$1" = "get_onion" ];
then
onion="$(docker__exec -t lnbits cat /app/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion:5000"
fi
}
sndev__help_tor() { sndev__help_tor() {
help=" help="
@ -637,6 +670,9 @@ COMMANDS
stacker_litcli litcli passthrough on litd stacker_litcli litcli passthrough on litd
tor get_onion get the onion address tor get_onion get the onion address
stacker_lnd get_cert get the tls cert stacker_lnd get_cert get the tls cert
stacker_lnd get_onion get the onion address
stacker_cln get_onion get the onion address
lndbits get_onion get the onion address
" "
echo "$help" echo "$help"
} }

View File

@ -4,6 +4,14 @@ For testing cln as an attached receiving wallet, you'll need a rune and the cert
`stacker_cln:3010` `stacker_cln:3010`
# host and port (onion)
Run:
```bash
sndev stacker_clncli get_onion
```
# create rune # create rune
```bash ```bash

View File

@ -22,3 +22,12 @@ Or simply copy the keys from here:
( These keys can be found under `Node URL, API keys and API docs`. ) ( These keys can be found under `Node URL, API keys and API docs`. )
To use the same URL to connect to LNbits in the browser and server during local development, `localhost:<port>` is mapped to `lnbits:5000` on the server. To use the same URL to connect to LNbits in the browser and server during local development, `localhost:<port>` is mapped to `lnbits:5000` on the server.
# tor onion url
Run the following command to get the onion url:
```bash
sndev lnbits get_onion
```