Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rootfiles/etc/sv/bitcoind-testnet3/log/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec vlogger -t bitcoind-testnet3 -p daemon
2 changes: 2 additions & 0 deletions rootfiles/etc/sv/bitcoind-testnet3/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec chpst -u bitcoind /home/bitcoind/bitcoin-26.1/bin/bitcoind -conf=/home/bitcoind/testnet3.conf 2>&1
2 changes: 2 additions & 0 deletions rootfiles/etc/sv/lnd-testnet3/log/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec vlogger -t lnd-testnet3 -p daemon
12 changes: 12 additions & 0 deletions rootfiles/etc/sv/lnd-testnet3/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# shellcheck source=/dev/null
[ -r conf ] && . ./conf
exec 2>&1
# wait for OS to acquire a clock sync.
# random date in the past: Oct 22 06:40:00 PM UTC 2023
while [ "$(date +%s)" -lt 1698000000 ]
do
echo "service start suspended until clock sync"
sleep 5
done
exec chpst -u lnd /home/lnd/lnd-linux-arm64-v0.17.4-beta/lnd -C /home/lnd/lnd.testnet3.conf 2>&1
36 changes: 36 additions & 0 deletions rootfiles/home/bitcoind/testnet3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
testnet=1
datadir=/ssd/bitcoind/testnet3

# lower resources since we're running on a raspberry pi.
maxuploadtarget=2048
maxconnections=80
# allow local electrs and others to grab as much data as they need.
whitelist=127.0.0.1

# make bitcoin p2p accessible over tor but use clearnet for ipv4 and ipv6.
onion=127.0.0.1:9050
# cat /ssd/tor/bitcoind/hostname
externalip=${hostname.onion}
# force discovering own clearnet addresses.
discover=1

# listen to RPC commands.
server=1
rpcbind=127.0.0.1
rpcport=18332
rpcallowip=127.0.0.1
# rpcauth.py rpc
# ${rpcauth}
rpcauth=${rpcauth_hash}

# push data over ZMQ to lnd
zmqpubrawblock=tcp://127.0.0.1:18331
zmqpubrawtx=tcp://127.0.0.1:18330

# no use for built-in hot wallet.
disablewallet=1

# log to stderr for the syslog to pick it up.
printtoconsole=1
#nodebuglogfile=1
logtimestamps=0
41 changes: 41 additions & 0 deletions rootfiles/home/lnd/lnd.testnet3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; https://docs.lightning.engineering/lightning-network-tools/lnd/lnd.conf

[application options]
alias=nakamochi
;wallet-unlock-password-file=/home/lnd/walletunlock.txt
debuglevel=info
maxpendingchannels=10
datadir=/ssd/lnd/data
logdir=/ssd/lnd/logs
maxlogfiles=3
tlsautorefresh=true
tlsextradomain=${hostname.onion}
externalhosts=${hostname.onion}
listen=[::]:9735
rpclisten=0.0.0.0:10009
restlisten=0.0.0.0:10010

[autopilot]
autopilot.active=false

[bitcoin]
bitcoin.active=true
bitcoin.chaindir=/ssd/lnd/data/chain/testnet3
bitcoin.mainnet=false
bitcoin.testnet=true
bitcoin.regtest=false
bitcoin.simnet=false
bitcoin.node=bitcoind

[bitcoind]
bitcoind.rpchost=127.0.0.1
bitcoind.rpcuser=rpc
bitcoind.rpcpass=${rpcauth}
bitcoind.zmqpubrawblock=tcp://127.0.0.1:18331
bitcoind.zmqpubrawtx=tcp://127.0.0.1:18330
; Defaults to CONSERVATIVE
; bitcoind.estimatemode=ECONOMICAL

[tor]
tor.active=true
tor.skip-proxy-for-clearnet-targets=true
42 changes: 30 additions & 12 deletions tools/finalize-nakamochi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ run_main()
fi

# check for existing lightning wallet
# only check for mainnet wallet as accidentally deleting it might lose funds, other stuff is not so important
if [[ -f "$SSD_MOUNT_POINT/lnd/data/chain/bitcoin/mainnet/wallet.db" ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Existing lightning wallet found on SSD."
Expand All @@ -164,6 +165,7 @@ run_main()
echo -n "Removing wallet unlock file and clearing LND config ... "
rm -f "$USD_MOUNT_POINT"/home/lnd/walletunlock.txt
sed -i "s/^wallet-unlock-password-file=.*/;wallet-unlock-password-file=\/home\/lnd\/walletunlock.txt/" "$USD_MOUNT_POINT"/home/lnd/lnd.mainnet.conf
sed -i "s/^wallet-unlock-password-file=.*/;wallet-unlock-password-file=\/home\/lnd\/walletunlock.txt/" "$USD_MOUNT_POINT"/home/lnd/lnd.testnet3.conf
echo "done."
else
echo "Aborted."
Expand All @@ -188,7 +190,9 @@ run_main()
echo -n "Generating onion services ... "
onion_tmp_dir="$(mktemp -d)"
mkp224o -d "$onion_tmp_dir" -n 1 b
mkp224o -d "$onion_tmp_dir" -n 1 tb
mkp224o -d "$onion_tmp_dir" -n 1 l
mkp224o -d "$onion_tmp_dir" -n 1 tl
echo "done."
fi

Expand All @@ -197,7 +201,9 @@ run_main()
if [[ "$skip_mkp224o" -eq 0 ]]; then
mkdir -p "$SSD_MOUNT_POINT"/tor/{bitcoind,lnd}
cp -r "$onion_tmp_dir"/b*/* "$SSD_MOUNT_POINT"/tor/bitcoind/
cp -r "$onion_tmp_dir"/tb*/* "$SSD_MOUNT_POINT"/tor/bitcoind-testnet3/
cp -r "$onion_tmp_dir"/l*/* "$SSD_MOUNT_POINT"/tor/lnd/
cp -r "$onion_tmp_dir"/tl*/* "$SSD_MOUNT_POINT"/tor/lnd-testnet3/
fi
onion_user_group="$(grep tor "$USD_MOUNT_POINT"/etc/passwd | cut -d: -f 3-4)"
chown -R "$onion_user_group" "$SSD_MOUNT_POINT"/tor
Expand All @@ -217,20 +223,32 @@ run_main()
echo "done."

# modify bitcoin configuration
bitcoind_conf="$USD_MOUNT_POINT"/home/bitcoind/mainnet.conf
echo -n "Finalizing bitcoin configuration ($bitcoind_conf) ..."
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind/hostname)"
patch_bitcoind_conf "$bitcoind_conf" "$bitcoind_rpcauth" "$bitcoind_rpcpass" "$bitcoind_onion_hostname"
echo "done."
grep rpc "$bitcoind_conf"
for bitcoind_network in mainnet testnet3; do
bitcoind_conf="$USD_MOUNT_POINT"/home/bitcoind/$bitcoind_network.conf
echo -n "Finalizing bitcoin configuration ($bitcoind_conf) ..."
if [[ "$bitcoind_network" == "mainnet" ]]; then
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind/hostname)"
else
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind-$bitcoind_network/hostname)"
fi
patch_bitcoind_conf "$bitcoind_conf" "$bitcoind_rpcauth" "$bitcoind_rpcpass" "$bitcoind_onion_hostname"
echo "done."
grep rpc "$bitcoind_conf"
done

# modify lnd configuration
lnd_conf="$USD_MOUNT_POINT"/home/lnd/lnd.mainnet.conf
echo -n "Finalizing lnd configuration ($lnd_conf) ..."
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd/hostname)"
patch_lnd_conf "$lnd_conf" "$bitcoind_rpcuser" "$bitcoind_rpcpass" "$lnd_onion_hostname"
echo "done."
grep rpc "$lnd_conf"
for bitcoind_network in mainnet testnet3; do
lnd_conf="$USD_MOUNT_POINT"/home/lnd/lnd.$bitcoind_network.conf
echo -n "Finalizing lnd configuration ($lnd_conf) ..."
if [[ "$bitcoind_network" == "mainnet" ]]; then
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd/hostname)"
else
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd-$bitcoind_network/hostname)"
fi
patch_lnd_conf "$lnd_conf" "$bitcoind_rpcuser" "$bitcoind_rpcpass" "$lnd_onion_hostname"
echo "done."
grep rpc "$lnd_conf"
done

# fix bitcoin and lnd user/group on SSD to match uSD (just in case)
echo -n "Checking / fixing bitcoin and lnd user/group on SSD ... "
Expand Down