use python script to unlock

This commit is contained in:
/geco 2018-12-24 00:04:46 +01:00
parent 8e2f3c2780
commit 180851b81a
2 changed files with 22 additions and 9 deletions

View File

@ -125,15 +125,19 @@ do
echo "STARTING AUTO-UNLOCK ..."
# building REST command
walletPasswordBase64=$(cat /root/lnd.autounlock.pwd | tr -d '\n' | base64 -w0)
MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon)"
# POSTDATA="'{ \"wallet_password\":\"${walletPasswordBase64}\" }'"
POSTDATA="\"{ \\\"wallet_password\\\":\\\"${walletPasswordBase64}\\\" }\""
echo "MACAROON:${MACAROON_HEADER}"
echo "POSTDATA:${POSTDATA}"
result=$(curl -X POST -d ${POSTDATA} --cacert /home/bitcoin/.lnd/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/unlockwallet)
echo "RESULT:${result}"
passwordC=$(cat /root/lnd.autounlock.pwd)
sudo python /home/admin/config.scripts/lnd.unlock.py $passwordC
#walletPasswordBase64=$(cat /root/lnd.autounlock.pwd | tr -d '\n' | base64 -w0)
#MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon)"
#POSTDATA="'{ \"wallet_password\":\"${walletPasswordBase64}\" }'"
#echo "MACAROON:${MACAROON_HEADER}"
#echo "POSTDATA:${POSTDATA}"
#command="sudo sh -c "curl -X POST -d ${POSTDATA} --cacert /home/bitcoin/.lnd/tls.cert --header \"$MACAROON_HEADER\" https://localhost:8080/v1/unlockwallet"
#echo "COMMAND:${command}"
#result=$(echo \"restlisten=\" >> /mnt/hdd/lnd/lnd.conf")
#echo "RESULT:${result}"
else
echo "lncli says not locked"
fi

View File

@ -0,0 +1,9 @@
# parameter #1: password c to unlock wallet
import base64, codecs, json, requests, sys
url = 'https://localhost:8080/v1/unlockwallet'
cert_path = '/mnt/hdd/lnd/tls.cert'
data = {
'wallet_password': base64.b64encode(sys.argv[1:]).decode()
}
r = requests.post(url, verify=cert_path, data=json.dumps(data))
print(r.json())