6 changed files with 106 additions and 8 deletions
@ -0,0 +1,11 @@ |
|||||
|
FROM alpine:3.10 |
||||
|
|
||||
|
RUN apk add --no-cache curl jq |
||||
|
|
||||
|
RUN mkdir /lnd/ |
||||
|
|
||||
|
COPY unlock.sh /bin/unlock |
||||
|
|
||||
|
RUN chmod +x /bin/unlock |
||||
|
|
||||
|
ENTRYPOINT ["unlock"] |
@ -0,0 +1,46 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
HOST=localhost:8080 |
||||
|
TLS_CERT=/lnd/tls.cert |
||||
|
MACAROON="$(xxd -p /run/secrets/lnd-admin | tr -d '\n')" |
||||
|
PASS="$(cat /run/secrets/lnd-password | tr -d '\n' | base64 | tr -d '\n')" |
||||
|
UNLOCK_PAYLOAD="$(jq -nc --arg wallet_password ${PASS} '{$wallet_password}')" |
||||
|
|
||||
|
lncurl() { |
||||
|
url_path=$1 |
||||
|
data=$2 |
||||
|
|
||||
|
curl --fail --silent --show-error \ |
||||
|
--cacert "${TLS_CERT}" \ |
||||
|
--header "Grpc-Metadata-macaroon: ${MACAROON}" \ |
||||
|
--data "${data}" \ |
||||
|
"https://${HOST}/v1/${url_path}" |
||||
|
} |
||||
|
|
||||
|
while true; do |
||||
|
# First make sure that port is open |
||||
|
while ! nc -z localhost 8080; do |
||||
|
>&2 echo "Waiting for ${HOST} port to open…" |
||||
|
sleep 3 |
||||
|
done |
||||
|
>&2 echo "Port ${HOST} is open" |
||||
|
|
||||
|
# Wait a bit more in case the port was just opened |
||||
|
sleep 1 |
||||
|
|
||||
|
>&2 echo "Trying ${HOST}/getinfo…" |
||||
|
INFO=$(lncurl getinfo) |
||||
|
if [ "$?" = "0" ]; then |
||||
|
>&2 echo "Response: ${INFO}" |
||||
|
alias="$(echo "${INFO}" | jq '.alias')" |
||||
|
>&2 echo "Wallet for ${alias} unlocked!" |
||||
|
exit 0 |
||||
|
fi |
||||
|
>&2 echo "${HOST}/getinfo FAILED, out=${INFO}" |
||||
|
|
||||
|
>&2 echo "Trying ${HOST}/unlockwallet…" |
||||
|
RESULT=$(lncurl unlockwallet "${UNLOCK_PAYLOAD}") |
||||
|
>&2 echo "${HOST}/unlockwallet completed with: exit-code=$?, out=${RESULT}" |
||||
|
|
||||
|
sleep 16 |
||||
|
done |
@ -1,10 +1,51 @@ |
|||||
version: '3.7' |
version: '3.7' |
||||
|
x-logging: &default-logging |
||||
|
driver: journald |
||||
|
options: |
||||
|
tag: "{{.Name}}" |
||||
|
|
||||
|
x-utility: &default-utility |
||||
|
image: "alpine:3.11" |
||||
|
logging: *default-logging |
||||
|
network_mode: host |
||||
|
|
||||
services: |
services: |
||||
|
web: |
||||
|
image: nginx:1.17.8 |
||||
|
logging: *default-logging |
||||
|
volumes: |
||||
|
- ${HOME}/nginx:/etc/nginx |
||||
|
restart: on-failure |
||||
|
network_mode: host |
||||
|
bitcoin: |
||||
|
image: lncm/bitcoind:v0.19.0.1 |
||||
|
logging: *default-logging |
||||
|
volumes: |
||||
|
- ${HOME}/bitcoin:/root/.bitcoin |
||||
|
restart: on-failure |
||||
|
network_mode: host |
||||
lnd: |
lnd: |
||||
image: lncm/lnd:v0.8.0-experimental |
image: lncm/lnd:v0.8.0-experimental |
||||
|
logging: *default-logging |
||||
volumes: |
volumes: |
||||
- /home/umbrel/lnd:/root/.lnd |
- ${HOME}/lnd:/root/.lnd |
||||
- /var/lib/tor:/var/lib/tor |
- /var/lib/tor:/var/lib/tor |
||||
- /run/tor:/run/tor |
- /run/tor:/run/tor |
||||
restart: on-failure |
restart: on-failure |
||||
|
depends_on: [ bitcoin, web ] |
||||
|
network_mode: host |
||||
|
lnd-unlock: |
||||
|
build: ${HOME}/build/lnd-unlock/ |
||||
|
depends_on: [ lnd ] |
||||
|
logging: *default-logging |
||||
|
secrets: |
||||
|
- lnd-password |
||||
|
- lnd-admin |
||||
|
volumes: |
||||
|
- "${HOME}/lnd/tls.cert:/lnd/tls.cert:ro" |
||||
network_mode: host |
network_mode: host |
||||
|
secrets: |
||||
|
lnd-password: |
||||
|
file: ${HOME}/secrets/lnd-password.txt |
||||
|
lnd-admin: |
||||
|
file: ${HOME}/lnd/data/chain/bitcoin/mainnet/admin.macaroon |
||||
|
Loading…
Reference in new issue