Reuse lnd seed

This commit is contained in:
Ștefan D. Mihăilă 2019-08-22 16:59:28 +02:00
parent 9b0753135c
commit d6f961db89
No known key found for this signature in database
GPG Key ID: 6220AD7846220A52

View File

@ -28,26 +28,30 @@ let
#!/bin/sh #!/bin/sh
set -e set -e
umask 377
${pkgs.coreutils}/bin/sleep 5 ${pkgs.coreutils}/bin/sleep 5
if [ ! -f ${cfg.dataDir}/chain/bitcoin/mainnet/wallet.db ] if [ ! -f /secrets/lnd-seed-mnemonic ]
then then
${pkgs.coreutils}/bin/echo creating LND wallet ${pkgs.coreutils}/bin/echo Creating lnd seed
${pkgs.curl}/bin/curl -s \ ${pkgs.curl}/bin/curl -s \
--cacert /secrets/lnd_cert \ --cacert /secrets/lnd_cert \
-X GET https://127.0.0.1:8080/v1/genseed | ${pkgs.jq}/bin/jq -c '.cipher_seed_mnemonic' > /secrets/lnd-seed-mnemonic -X GET https://127.0.0.1:8080/v1/genseed | ${pkgs.jq}/bin/jq -c '.cipher_seed_mnemonic' > /secrets/lnd-seed-mnemonic
fi
if [ ! -f ${cfg.dataDir}/chain/bitcoin/mainnet/wallet.db ]
then
${pkgs.coreutils}/bin/echo Creating lnd wallet
${pkgs.curl}/bin/curl -s \ ${pkgs.curl}/bin/curl -s \
--cacert /secrets/lnd_cert \ --cacert /secrets/lnd_cert \
-X POST -d "{\"wallet_password\": \"$(${pkgs.coreutils}/bin/cat /secrets/lnd-wallet-password | ${pkgs.coreutils}/bin/tr -d '\n' | ${pkgs.coreutils}/bin/base64 -w0)\", \ -X POST -d "{\"wallet_password\": \"$(${pkgs.coreutils}/bin/cat /secrets/lnd-wallet-password | ${pkgs.coreutils}/bin/tr -d '\n' | ${pkgs.coreutils}/bin/base64 -w0)\", \
\"cipher_seed_mnemonic\": $(${pkgs.coreutils}/bin/cat /secrets/lnd-seed-mnemonic | ${pkgs.coreutils}/bin/tr -d '\n')}" \ \"cipher_seed_mnemonic\": $(${pkgs.coreutils}/bin/cat /secrets/lnd-seed-mnemonic | ${pkgs.coreutils}/bin/tr -d '\n')}" \
https://127.0.0.1:8080/v1/initwallet https://127.0.0.1:8080/v1/initwallet
${pkgs.coreutils}/bin/echo wallet created
else else
${pkgs.coreutils}/bin/echo unlocking wallet ${pkgs.coreutils}/bin/echo Unlocking lnd wallet
${pkgs.curl}/bin/curl -s \ ${pkgs.curl}/bin/curl -s \
-H "Grpc-Metadata-macaroon: $(${pkgs.xxd}/bin/xxd -ps -u -c 1000 ${cfg.dataDir}/chain/bitcoin/mainnet/admin.macaroon)" \ -H "Grpc-Metadata-macaroon: $(${pkgs.xxd}/bin/xxd -ps -u -c 1000 ${cfg.dataDir}/chain/bitcoin/mainnet/admin.macaroon)" \
@ -55,8 +59,6 @@ else
-X POST \ -X POST \
-d "{\"wallet_password\": \"$(${pkgs.coreutils}/bin/cat /secrets/lnd-wallet-password | ${pkgs.coreutils}/bin/tr -d '\n' | ${pkgs.coreutils}/bin/base64 -w0)\"}" \ -d "{\"wallet_password\": \"$(${pkgs.coreutils}/bin/cat /secrets/lnd-wallet-password | ${pkgs.coreutils}/bin/tr -d '\n' | ${pkgs.coreutils}/bin/base64 -w0)\"}" \
https://127.0.0.1:8080/v1/unlockwallet https://127.0.0.1:8080/v1/unlockwallet
${pkgs.coreutils}/bin/echo wallet unlocked
fi fi
exit 0 exit 0