BT
5 years ago
committed by
GitHub
16 changed files with 58 additions and 253 deletions
@ -1 +0,0 @@ |
|||||
docker.io |
|
@ -1,135 +0,0 @@ |
|||||
#!/usr/bin/env python3 |
|
||||
|
|
||||
''' |
|
||||
Copyright © 2018-2019 LNCM Contributors |
|
||||
|
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
you may not use this file except in compliance with the License. |
|
||||
You may obtain a copy of the License at |
|
||||
|
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
|
||||
|
|
||||
Unless required by applicable law or agreed to in writing, software |
|
||||
distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
See the License for the specific language governing permissions and |
|
||||
limitations under the License. |
|
||||
|
|
||||
Documented logic |
|
||||
|
|
||||
1. Check if theres already a wallet. If there is, then exit. |
|
||||
2. Check for sesame.txt |
|
||||
3. If doesn't exist then check for whether we should save the password (save_password_control_file exists) or not |
|
||||
4. If sesame.txt exists import password in. |
|
||||
5. If sesame.txt doesn't exist ans we don't save the password,create a password and save it in temporary path as defined in temp_password_file_path |
|
||||
6. Now start the wallet creation. Look for a seed defined in seed_filename , if not existing then generate a wallet based on the seed by LND. |
|
||||
|
|
||||
''' |
|
||||
import base64, codecs, json, requests, os |
|
||||
import random, string |
|
||||
|
|
||||
# Generate seed |
|
||||
url = 'https://localhost:8080/v1/genseed' |
|
||||
# Initialize wallet |
|
||||
url2 = 'https://localhost:8080/v1/initwallet' |
|
||||
cert_path = '/home/umbrel/lnd/tls.cert' |
|
||||
seed_filename = '/home/umbrel/secrets/seed.txt' |
|
||||
|
|
||||
# save password control file (Add this file if we want to save passwords) |
|
||||
save_password_control_file = '/home/umbrel/.save_password' |
|
||||
# Create password for writing |
|
||||
temp_password_file_path = '/tmp/.password.txt' |
|
||||
|
|
||||
''' |
|
||||
Functions have 2 spaces |
|
||||
''' |
|
||||
def randompass(stringLength=10): |
|
||||
letters = string.ascii_letters |
|
||||
return ''.join(random.choice(letters) for i in range(stringLength)) |
|
||||
|
|
||||
def main(): |
|
||||
if not os.path.exists(save_password_control_file): |
|
||||
# Generate password but dont save it in usual spot |
|
||||
password_str=randompass(stringLength=15) |
|
||||
temp_password_file = open(temp_password_file_path, "w") |
|
||||
# Check if there is an existing file, if not generate a random password |
|
||||
if not os.path.exists("/home/umbrel/secrets/lnd-password.txt"): |
|
||||
# sesame file doesnt exist |
|
||||
password_str=randompass(stringLength=15) |
|
||||
if not os.path.exists(save_password_control_file): |
|
||||
# Use tempory file if there is a password control file there |
|
||||
temp_password_file = open(temp_password_file_path, "w") |
|
||||
temp_password_file.write(password_str) |
|
||||
temp_password_file.close() |
|
||||
else: |
|
||||
# Use sesame.txt if password_control_file exists |
|
||||
password_file = open("/home/umbrel/secrets/lnd-password.txt","w") |
|
||||
password_file.write(password_str) |
|
||||
password_file.close() |
|
||||
else: |
|
||||
# Get password from file if sesame file already exists |
|
||||
password_str = open('/home/umbrel/secrets/lnd-password.txt', 'r').read().rstrip() |
|
||||
|
|
||||
# Convert password to byte encoded |
|
||||
password_bytes = str(password_str).encode('utf-8') |
|
||||
# Step 1 get seed from web or file |
|
||||
|
|
||||
# Send request to generate seed if seed file doesnt exist |
|
||||
if not os.path.exists(seed_filename): |
|
||||
r = requests.get(url, verify=cert_path) |
|
||||
if r.status_code == 200: |
|
||||
json_seed_creation = r.json() |
|
||||
json_seed_mnemonic = json_seed_creation['cipher_seed_mnemonic'] |
|
||||
json_enciphered_seed = json_seed_creation['enciphered_seed'] |
|
||||
seed_file = open(seed_filename, "w") |
|
||||
for word in json_seed_mnemonic: |
|
||||
seed_file.write(word + "\n") |
|
||||
seed_file.close() |
|
||||
data = { 'cipher_seed_mnemonic': json_seed_mnemonic, 'wallet_password': base64.b64encode(password_bytes).decode()} |
|
||||
# Data doesnt get set if cant create the seed but that is fine, handle it later |
|
||||
else: |
|
||||
# Seed exists |
|
||||
seed_file = open(seed_filename, "r") |
|
||||
seed_file_words = seed_file.readlines() |
|
||||
import_file_array = [] |
|
||||
for importword in seed_file_words: |
|
||||
import_file_array.append(importword.replace("\n", "")) |
|
||||
# Generate init wallet file from what was posted |
|
||||
data = { 'cipher_seed_mnemonic': import_file_array, 'wallet_password': base64.b64encode(password_bytes).decode()} |
|
||||
|
|
||||
# Step 2: Create wallet |
|
||||
try: |
|
||||
data |
|
||||
except NameError: |
|
||||
print("data isn't defined") |
|
||||
pass |
|
||||
else: |
|
||||
# Data is defined so proceed |
|
||||
r2 = requests.post(url2, verify=cert_path, data=json.dumps(data)) |
|
||||
if r2.status_code == 200: |
|
||||
# If create wallet was successful |
|
||||
print("Create wallet is successful") |
|
||||
else: |
|
||||
print("Create wallet is not successful") |
|
||||
|
|
||||
|
|
||||
''' |
|
||||
Main entrypoint function |
|
||||
|
|
||||
Testing creation notes: |
|
||||
rm /home/lncm/seed.txt |
|
||||
rm /media/important/important/lnd/sesame.txt |
|
||||
|
|
||||
docker stop compose_lndbox_1 ; rm -fr /media/important/important/lnd/data/chain/ ; docker start compose_lndbox_1 |
|
||||
''' |
|
||||
|
|
||||
if __name__ == '__main__': |
|
||||
if os.path.exists("/home/umbrel/lnd"): |
|
||||
if not os.path.exists("/home/umbrel/lnd/data/chain/bitcoin/mainnet/wallet.db"): |
|
||||
main() |
|
||||
else: |
|
||||
print('Wallet already exists! Please delete .lnd/data/chain and then restart LND') |
|
||||
else: |
|
||||
print('LND directory does not exist!') |
|
||||
|
|
||||
|
|
@ -1,28 +0,0 @@ |
|||||
#!/usr/bin/env python3 |
|
||||
|
|
||||
import base64, codecs, json, requests |
|
||||
url = 'https://localhost:8080/v1/unlockwallet' |
|
||||
cert_path = '/home/umbrel/lnd/tls.cert' |
|
||||
password_str = open('/home/umbrel/secrets/lnd-password.txt', 'r').read().rstrip() |
|
||||
password_bytes = str(password_str).encode('utf-8') |
|
||||
data = { |
|
||||
'wallet_password': base64.b64encode(password_bytes).decode(), |
|
||||
} |
|
||||
|
|
||||
|
|
||||
def main(): |
|
||||
try: |
|
||||
r = requests.post(url, verify=cert_path, data=json.dumps(data)) |
|
||||
except: |
|
||||
# Silence connection errors when lnd is not running |
|
||||
pass |
|
||||
else: |
|
||||
try: |
|
||||
print(r.json()) |
|
||||
except: |
|
||||
# JSON will fail to decode when unlocked already since response is empty |
|
||||
pass |
|
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
|
||||
main() |
|
@ -0,0 +1,13 @@ |
|||||
|
#!/bin/bash -e |
||||
|
echo "Installing Docker" |
||||
|
on_chroot << EOF |
||||
|
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt |
||||
|
curl -fsSL https://get.docker.com | sh |
||||
|
EOF |
||||
|
|
||||
|
echo "Adding user to the 'docker' group" |
||||
|
echo "Also fixing permissions on folders" |
||||
|
on_chroot << EOF |
||||
|
usermod -a -G docker $FIRST_USER_NAME |
||||
|
chown -R $FIRST_USER_NAME:$FIRST_USER_NAME /home/$FIRST_USER_NAME |
||||
|
EOF |
@ -0,0 +1 @@ |
|||||
|
git |
@ -1,7 +0,0 @@ |
|||||
echo "Adding lncm to DOCKER group" |
|
||||
echo "Also fixing permissions on folders" |
|
||||
on_chroot << EOF |
|
||||
usermod -a -G docker $FIRST_USER_NAME |
|
||||
chown -R $FIRST_USER_NAME:$FIRST_USER_NAME /home/$FIRST_USER_NAME |
|
||||
EOF |
|
||||
|
|
@ -1,6 +0,0 @@ |
|||||
chmod 644 files/lnd.conf |
|
||||
echo "Copying lnd.conf to overwrite the existing LND.conf" |
|
||||
cp files/lnd.conf ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/lnd/lnd.conf |
|
||||
on_chroot << EOF |
|
||||
chown -R ${FIRST_USER_NAME}:${FIRST_USER_NAME} /home/${FIRST_USER_NAME} |
|
||||
EOF |
|
@ -1,38 +0,0 @@ |
|||||
[Application Options] |
|
||||
|
|
||||
listen=0.0.0.0:9735 |
|
||||
rpclisten=0.0.0.0:10009 |
|
||||
restlisten=0.0.0.0:8080 |
|
||||
maxpendingchannels=3 |
|
||||
minchansize=1337 |
|
||||
alias=Umbrel Node |
|
||||
color=#5351FB |
|
||||
|
|
||||
; Makes routing faster but have to use images built with experimental tag |
|
||||
[Routing] |
|
||||
routing.assumechanvalid=1 |
|
||||
|
|
||||
[Bitcoin] |
|
||||
; If the Bitcoin chain should be active. Atm, only a single chain can be |
|
||||
; active. |
|
||||
bitcoin.active=1 |
|
||||
bitcoin.mainnet=1 |
|
||||
; Use neutrino for now, but maybe it could be permanent and then switch |
|
||||
; to a full node once its working? |
|
||||
bitcoin.node=neutrino |
|
||||
bitcoin.defaultchanconfs=2 |
|
||||
|
|
||||
; Add neutrino peers |
|
||||
; TODO: umbrel to set up a neutrino peer to support umbrel nodes |
|
||||
[neutrino] |
|
||||
neutrino.addpeer=bb2.breez.technology |
|
||||
neutrino.addpeer=mainnet1-btcd.zaphq.io |
|
||||
neutrino.addpeer=mainnet2-btcd.zaphq.io |
|
||||
|
|
||||
[tor] |
|
||||
tor.active=1 |
|
||||
tor.control=9051 |
|
||||
tor.socks=9050 |
|
||||
tor.v3=1 |
|
||||
tor.dns=soa.nodes.lightning.directory:53 |
|
||||
|
|
Loading…
Reference in new issue