Skip to content

Instantly share code, notes, and snippets.

@AnotherDroog
Created December 29, 2018 06:12
Show Gist options
  • Save AnotherDroog/d6efd53bcdba1efca0622c265a690105 to your computer and use it in GitHub Desktop.
Save AnotherDroog/d6efd53bcdba1efca0622c265a690105 to your computer and use it in GitHub Desktop.
lnd unlock script
[Unit]
Description=LND Lightning Daemon
Requires=bitcoind.service
After=bitcoind.service
[Service]
ExecStart=/usr/local/bin/lnd
ExecStartPost=+/etc/lnd/unlock
User=ln
Group=ln
Type=simple
KillMode=process
TimeoutSec=180
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
#located at /etc/lnd/pwd
<place-password-here>
#located at /etc/lnd/unlock
#!/bin/sh
/bin/sleep 5s
LN_ROOT=/home/lnd/.lnd
curl -s \
-H "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 ${LN_ROOT}/data/chain/bitcoin/mainnet/admin.macaroon)" \
--cacert ${LN_ROOT}/tls.cert \
-d "{\"wallet_password\": \"$(cat /etc/lnd/pwd | tr -d '\n' | base64 -w0)\"}" \
https://localhost:8080/v1/unlockwallet > /dev/null 2>&1
echo "$? $(date)" >> /etc/lnd/unlocks.log
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment