diff --git a/rootfiles/etc/sv/bitcoind-testnet3/log/run b/rootfiles/etc/sv/bitcoind-testnet3/log/run new file mode 100755 index 0000000..bcf3ad5 --- /dev/null +++ b/rootfiles/etc/sv/bitcoind-testnet3/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t bitcoind-testnet3 -p daemon diff --git a/rootfiles/etc/sv/bitcoind-testnet3/run b/rootfiles/etc/sv/bitcoind-testnet3/run new file mode 100755 index 0000000..10e76fa --- /dev/null +++ b/rootfiles/etc/sv/bitcoind-testnet3/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec chpst -u bitcoind /home/bitcoind/bitcoin-26.1/bin/bitcoind -conf=/home/bitcoind/testnet3.conf 2>&1 diff --git a/rootfiles/etc/sv/lnd-testnet3/log/run b/rootfiles/etc/sv/lnd-testnet3/log/run new file mode 100755 index 0000000..04eccc4 --- /dev/null +++ b/rootfiles/etc/sv/lnd-testnet3/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t lnd-testnet3 -p daemon diff --git a/rootfiles/etc/sv/lnd-testnet3/run b/rootfiles/etc/sv/lnd-testnet3/run new file mode 100755 index 0000000..cf7e246 --- /dev/null +++ b/rootfiles/etc/sv/lnd-testnet3/run @@ -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 diff --git a/rootfiles/home/bitcoind/testnet3.conf b/rootfiles/home/bitcoind/testnet3.conf new file mode 100644 index 0000000..d52f977 --- /dev/null +++ b/rootfiles/home/bitcoind/testnet3.conf @@ -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 diff --git a/rootfiles/home/lnd/lnd.testnet3.conf b/rootfiles/home/lnd/lnd.testnet3.conf new file mode 100644 index 0000000..b68f05f --- /dev/null +++ b/rootfiles/home/lnd/lnd.testnet3.conf @@ -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 diff --git a/tools/finalize-nakamochi.sh b/tools/finalize-nakamochi.sh index c064cd7..0724219 100755 --- a/tools/finalize-nakamochi.sh +++ b/tools/finalize-nakamochi.sh @@ -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." @@ -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." @@ -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 @@ -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 @@ -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 ... "