From 12f93a89369d21817bc5c78b7484367986609448 Mon Sep 17 00:00:00 2001 From: /geco Date: Sun, 23 Dec 2018 14:31:58 +0100 Subject: [PATCH] rest call modified --- home.admin/_background.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index dad10d0..402e113 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -11,7 +11,6 @@ infoFile="/home/admin/raspiblitz.info" configFile="/mnt/hdd/raspiblitz.conf" # LOGS see: sudo journalctl -f -u background -echo "_background.sh STARTED" # Check if HDD contains configuration configExists=$(ls ${configFile} | grep -c '.conf') @@ -19,6 +18,8 @@ if [ ${configExists} -eq 1 ]; then source ${configFile} fi +echo "_background.sh STARTED" + counter=0 while [ 1 ] do @@ -121,12 +122,18 @@ do locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) if [ ${locked} -gt 0 ]; then + # get password c + walletPasswordBase64=$(cat /root/lnd.autounlock.pwd | tr -d '\n' | base64 -w0) + echo "walletPasswordBase64 --> ${walletPasswordBase64}" + macaroonData=$(xxd -ps -u -c 1000 /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon) + echo "macaroonData --> ${macaroonData}" + # unlock thru REST call curl -s \ - -H "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon))" \ + -H "Grpc-Metadata-macaroon: ${macaroonData})" \ --cacert /home/bitcoin/.lnd/tls.cert \ - -X POST -d "{\"wallet_password\": \"$(cat /root/lnd.autounlock.pwd | tr -d '\n' | base64 -w0)\"}" \ - https://localhost:8080/v1/unlockwallet > /dev/null 2>&1 + -X POST -d "{\"wallet_password\": \"${walletPasswordBase64}\"}" \ + https://localhost:8080/v1/unlockwallet 2>&1 else echo "lncli says not locked"