mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-12 21:59:19 +02:00
prepare lnd wallet creation if running as second
This commit is contained in:
parent
7de8aaf802
commit
3a88ca5789
@ -364,6 +364,7 @@ if [ "${lndNode}" != "${choice}" ]; then
|
||||
if [ "${choice}" = "on" ]; then
|
||||
echo "# turning ON"
|
||||
/home/admin/config.scripts/lnd.install.sh on mainnet
|
||||
sudo /home/admin/config.scripts/lnd.install.sh display-seed mainnet
|
||||
if [ "${testnet}" == "on" ]; then
|
||||
/home/admin/config.scripts/lnd.install.sh on testnet
|
||||
fi
|
||||
|
@ -275,7 +275,7 @@ if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
echo "WALLET --> SEED + SCB " >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (SEED & SCB)'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py scb ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py mainnet scb ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SCB failed'/g" ${infoFile}
|
||||
@ -291,7 +291,7 @@ if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
echo "WALLET --> SEED" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (SEED)'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${seedWords}" ${seedPassword}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py mainnet seed ${passwordC} "${seedWords}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
@ -307,7 +307,7 @@ if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
echo "WALLET --> NEW" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (NEW)'/g" ${infoFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py new ${passwordC})
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py mainnet new ${passwordC})
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
|
@ -786,7 +786,7 @@ if [ "${lightning}" == "lnd" ];then
|
||||
if [ "${passwordFlagExists}" == "1" ]; then
|
||||
echo "Found /mnt/hdd/passwordc.flag .. changing password" >> ${logFile}
|
||||
oldPasswordC=$(sudo cat /mnt/hdd/passwordc.flag)
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py change-password "${oldPasswordC}" "${passwordC}" >> ${logFile}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py mainnet change-password "${oldPasswordC}" "${passwordC}" >> ${logFile}
|
||||
sudo shred -u /mnt/hdd/passwordc.flag
|
||||
else
|
||||
echo "No /mnt/hdd/passwordc.flag" >> ${logFile}
|
||||
|
@ -365,7 +365,7 @@ elif [ "${abcd}" = "c" ]; then
|
||||
sleep 2
|
||||
|
||||
err=""
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py change-password $oldPassword $newPassword)
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py mainnet change-password $oldPassword $newPassword)
|
||||
if [ "${err}" != "" ]; then
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Was not able to change password\n\n${err}\n${errMore}" 10 52
|
||||
clear
|
||||
|
@ -15,10 +15,10 @@ if sys.version_info < (3, 0):
|
||||
# display config script info
|
||||
if len(sys.argv) <= 1 or sys.argv[1] in ["-h", "--help", "help"]:
|
||||
print("# creating or recovering the LND wallet")
|
||||
print("# lnd.initwallet.py new [walletpassword] [?seedpassword]")
|
||||
print("# lnd.initwallet.py seed [walletpassword] [\"seeds-words-seperated-spaces\"] [?seedpassword]")
|
||||
print("# lnd.initwallet.py scb [walletpassword] [\"seeds-words-seperated-spaces\"] [filepathSCB] [?seedpassword]")
|
||||
print("# lnd.initwallet.py change-password [walletpassword-old] [walletpassword-new]")
|
||||
print("# lnd.initwallet.py new [mainnet|testnet|signet] [walletpassword] [?seedpassword]")
|
||||
print("# lnd.initwallet.py seed [mainnet|testnet|signet] [walletpassword] [\"seeds-words-seperated-spaces\"] [?seedpassword]")
|
||||
print("# lnd.initwallet.py scb [mainnet|testnet|signet] [walletpassword] [\"seeds-words-seperated-spaces\"] [filepathSCB] [?seedpassword]")
|
||||
print("# lnd.initwallet.py change-password [mainnet|testnet|signet] [walletpassword-old] [walletpassword-new]")
|
||||
print("err='missing parameters'")
|
||||
sys.exit(1)
|
||||
|
||||
@ -166,15 +166,22 @@ def change_password(stub, wallet_password="", wallet_password_new=""):
|
||||
sys.exit(1)
|
||||
|
||||
def parse_args():
|
||||
network = ""
|
||||
wallet_password = ""
|
||||
wallet_password_new = ""
|
||||
seed_words = ""
|
||||
seed_password = ""
|
||||
filepath_scb = ""
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
network = sys.argv[2]
|
||||
else:
|
||||
print("err='missing parameters'")
|
||||
sys.exit(1)
|
||||
|
||||
if mode == "new":
|
||||
if len(sys.argv) > 2:
|
||||
wallet_password = sys.argv[2]
|
||||
if len(sys.argv) > 3:
|
||||
wallet_password = sys.argv[3]
|
||||
if len(wallet_password) < 8:
|
||||
print("err='wallet password is too short'")
|
||||
sys.exit(1)
|
||||
@ -182,17 +189,17 @@ def parse_args():
|
||||
print("err='missing parameters'")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) > 3:
|
||||
seed_password = sys.argv[3]
|
||||
if len(sys.argv) > 4:
|
||||
seed_password = sys.argv[4]
|
||||
|
||||
elif mode == "change-password":
|
||||
|
||||
if len(sys.argv) > 3:
|
||||
wallet_password = sys.argv[2]
|
||||
if len(sys.argv) > 4:
|
||||
wallet_password = sys.argv[3]
|
||||
if len(wallet_password) < 8:
|
||||
print("err='wallet password is too short'")
|
||||
sys.exit(1)
|
||||
wallet_password_new = sys.argv[3]
|
||||
wallet_password_new = sys.argv[4]
|
||||
if len(wallet_password_new ) < 8:
|
||||
print("err='wallet password new is too short'")
|
||||
sys.exit(1)
|
||||
@ -202,8 +209,8 @@ def parse_args():
|
||||
|
||||
elif mode == "seed" or mode == "scb":
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
wallet_password = sys.argv[2]
|
||||
if len(sys.argv) > 3:
|
||||
wallet_password = sys.argv[3]
|
||||
if len(wallet_password) < 8:
|
||||
print("err='wallet password is too short'")
|
||||
sys.exit(1)
|
||||
@ -211,8 +218,8 @@ def parse_args():
|
||||
print("err='not correct amount of parameter - missing wallet password'")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) > 3:
|
||||
seed_word_str = sys.argv[3]
|
||||
if len(sys.argv) > 4:
|
||||
seed_word_str = sys.argv[4]
|
||||
seed_words = seed_word_str.split(" ")
|
||||
if len(seed_words) < 24:
|
||||
print("err='not 24 seed words separated by just spaces (surrounded with \")'")
|
||||
@ -223,13 +230,13 @@ def parse_args():
|
||||
|
||||
if mode == "seed":
|
||||
|
||||
if len(sys.argv) > 4:
|
||||
seed_password = sys.argv[4]
|
||||
if len(sys.argv) > 5:
|
||||
seed_password = sys.argv[5]
|
||||
|
||||
elif mode == "scb":
|
||||
|
||||
if len(sys.argv) > 4:
|
||||
filepath_scb = sys.argv[4]
|
||||
if len(sys.argv) > 5:
|
||||
filepath_scb = sys.argv[5]
|
||||
scb_file = Path(filepath_scb)
|
||||
if scb_file.is_file():
|
||||
print("# OK SCB file exists")
|
||||
@ -240,26 +247,40 @@ def parse_args():
|
||||
print("err='not correct amount of parameter - missing seed filepathSCB'")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) > 5:
|
||||
seed_password = sys.argv[4]
|
||||
if len(sys.argv) > 6:
|
||||
seed_password = sys.argv[5]
|
||||
|
||||
else:
|
||||
|
||||
print("err='unknown mode parameter - run without any parameters to see options'")
|
||||
sys.exit(1)
|
||||
|
||||
return wallet_password, seed_words, seed_password, filepath_scb, wallet_password_new
|
||||
return network, wallet_password, seed_words, seed_password, filepath_scb, wallet_password_new
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
network, wallet_password, seed_words, seed_password, file_path_scb, wallet_password_new = parse_args()
|
||||
|
||||
grpcEndpoint="localhost:0"
|
||||
if network == "mainnet":
|
||||
grpcEndpoint="localhost:10009"
|
||||
elif network == "testnet":
|
||||
grpcEndpoint="localhost:11009"
|
||||
elif network == "signet":
|
||||
grpcEndpoint="localhost:13009"
|
||||
print("err='lnd does not support signet yet'")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("err='chain not supported'")
|
||||
sys.exit(1)
|
||||
|
||||
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
|
||||
cert = open('/mnt/hdd/lnd/tls.cert', 'rb').read()
|
||||
ssl_creds = grpc.ssl_channel_credentials(cert)
|
||||
channel = grpc.secure_channel('localhost:10009', ssl_creds)
|
||||
channel = grpc.secure_channel(grpcEndpoint, ssl_creds)
|
||||
stub = rpcstub.WalletUnlockerStub(channel)
|
||||
|
||||
wallet_password, seed_words, seed_password, file_path_scb, wallet_password_new = parse_args()
|
||||
|
||||
if mode == "new":
|
||||
print("# *** CREATING NEW LND WALLET ***")
|
||||
new(stub, wallet_password)
|
||||
|
@ -4,7 +4,7 @@
|
||||
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
||||
echo
|
||||
echo "Install or remove LND services on parallel chains"
|
||||
echo "lnd.install.sh [on|off] [mainnet|testnet|signet]"
|
||||
echo "lnd.install.sh [on|off|display-seed] [mainnet|testnet|signet]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
@ -57,7 +57,6 @@ source /home/admin/raspiblitz.info
|
||||
if ! grep -Eq "^${netprefix}lnd=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${netprefix}lnd=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# switch on
|
||||
@ -179,6 +178,47 @@ alias ${netprefix}lncli=\"sudo -u bitcoin /usr/local/bin/lncli\
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "display-seed" ]; then
|
||||
|
||||
# check if sudo
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root (with sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get network and aliasses from second parameter (default mainnet)
|
||||
displayNetwork=$2
|
||||
if [ "${displayNetwork}" == "" ]; then
|
||||
displayNetwork="mainnet"
|
||||
fi
|
||||
|
||||
# check if seedword file exists
|
||||
seedwordFile="/mnt/hdd/lnd/data/chain/${network}/${CHAIN}/seedwords.info"
|
||||
echo "# seewordFile(${seedwordFile})"
|
||||
seedwordFileExists=$(ls ${seedwordFile} 2>/dev/null | grep -c "seedwords.info")
|
||||
echo "# seewordFileExists(${seewordFileExists})"
|
||||
if [ "${seedwordFileExists}" == "1" ]; then
|
||||
source ${seedwordFile}
|
||||
#echo "# seedwords(${seedwords})"
|
||||
#echo "# seedwords6x4(${seedwords6x4})"
|
||||
ack=0
|
||||
while [ ${ack} -eq 0 ]
|
||||
do
|
||||
whiptail --title "LND ${displayNetwork} Wallet" \
|
||||
--msgbox "This is your LND ${displayNetwork} wallet seed. Store these numbered words in a safe location:\n\n${seedwords6x4}" 13 76
|
||||
whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55
|
||||
if [ $? -eq 1 ]; then
|
||||
ack=1
|
||||
fi
|
||||
done
|
||||
else
|
||||
walletFile="/mnt/hdd/lnd/data/chain/${network}/${CHAIN}/wallet.db"
|
||||
whiptail --title "LND ${displayNetwork} Wallet Info" --msgbox "Your LND ${displayNetwork} wallet was already created before - there are no seed words available.\n\nTo secure your wallet secret you can manually backup the file: ${walletFile}" 11 76
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# switch off
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user