Skip to content

Commit 8b7cbd6

Browse files
committed
Basic support for testnet3 (WIP)
1 parent 00cadcf commit 8b7cbd6

File tree

7 files changed

+127
-14
lines changed

7 files changed

+127
-14
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec vlogger -t bitcoind-testnet3 -p daemon
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec chpst -u bitcoind /home/bitcoind/bitcoin-26.1/bin/bitcoind -conf=/home/bitcoind/testnet3.conf 2>&1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec vlogger -t lnd-testnet3 -p daemon

rootfiles/etc/sv/lnd-testnet3/run

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# shellcheck source=/dev/null
3+
[ -r conf ] && . ./conf
4+
exec 2>&1
5+
# wait for OS to acquire a clock sync.
6+
# random date in the past: Oct 22 06:40:00 PM UTC 2023
7+
while [ "$(date +%s)" -lt 1698000000 ]
8+
do
9+
echo "service start suspended until clock sync"
10+
sleep 5
11+
done
12+
exec chpst -u lnd /home/lnd/lnd-linux-arm64-v0.17.4-beta/lnd -C /home/lnd/lnd.testnet3.conf 2>&1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
testnet=1
2+
datadir=/ssd/bitcoind/testnet3
3+
4+
# lower resources since we're running on a raspberry pi.
5+
maxuploadtarget=2048
6+
maxconnections=80
7+
# allow local electrs and others to grab as much data as they need.
8+
whitelist=127.0.0.1
9+
10+
# make bitcoin p2p accessible over tor but use clearnet for ipv4 and ipv6.
11+
onion=127.0.0.1:9050
12+
# cat /ssd/tor/bitcoind/hostname
13+
externalip=${hostname.onion}
14+
# force discovering own clearnet addresses.
15+
discover=1
16+
17+
# listen to RPC commands.
18+
server=1
19+
rpcbind=127.0.0.1
20+
rpcport=18332
21+
rpcallowip=127.0.0.1
22+
# rpcauth.py rpc
23+
# ${rpcauth}
24+
rpcauth=${rpcauth_hash}
25+
26+
# push data over ZMQ to lnd
27+
zmqpubrawblock=tcp://127.0.0.1:18331
28+
zmqpubrawtx=tcp://127.0.0.1:18330
29+
30+
# no use for built-in hot wallet.
31+
disablewallet=1
32+
33+
# log to stderr for the syslog to pick it up.
34+
printtoconsole=1
35+
#nodebuglogfile=1
36+
logtimestamps=0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; https://docs.lightning.engineering/lightning-network-tools/lnd/lnd.conf
2+
3+
[application options]
4+
alias=nakamochi
5+
;wallet-unlock-password-file=/home/lnd/walletunlock.txt
6+
debuglevel=info
7+
maxpendingchannels=10
8+
datadir=/ssd/lnd/data
9+
logdir=/ssd/lnd/logs
10+
maxlogfiles=3
11+
tlsautorefresh=true
12+
tlsextradomain=${hostname.onion}
13+
externalhosts=${hostname.onion}
14+
listen=[::]:9735
15+
rpclisten=0.0.0.0:10009
16+
restlisten=0.0.0.0:10010
17+
18+
[autopilot]
19+
autopilot.active=false
20+
21+
[bitcoin]
22+
bitcoin.active=true
23+
bitcoin.chaindir=/ssd/lnd/data/chain/testnet3
24+
bitcoin.mainnet=false
25+
bitcoin.testnet=true
26+
bitcoin.regtest=false
27+
bitcoin.simnet=false
28+
bitcoin.node=bitcoind
29+
30+
[bitcoind]
31+
bitcoind.rpchost=127.0.0.1
32+
bitcoind.rpcuser=rpc
33+
bitcoind.rpcpass=${rpcauth}
34+
bitcoind.zmqpubrawblock=tcp://127.0.0.1:18331
35+
bitcoind.zmqpubrawtx=tcp://127.0.0.1:18330
36+
; Defaults to CONSERVATIVE
37+
; bitcoind.estimatemode=ECONOMICAL
38+
39+
[tor]
40+
tor.active=true
41+
tor.skip-proxy-for-clearnet-targets=true

tools/finalize-nakamochi.sh

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ run_main()
129129
fi
130130

131131
# check for existing lightning wallet
132+
# only check for mainnet wallet as accidentally deleting it might lose funds, other stuff is not so important
132133
if [[ -f "$SSD_MOUNT_POINT/lnd/data/chain/bitcoin/mainnet/wallet.db" ]]; then
133134
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
134135
echo "Existing lightning wallet found on SSD."
@@ -141,6 +142,7 @@ run_main()
141142
echo -n "Removing wallet unlock file and clearing LND config ... "
142143
rm "$USD_MOUNT_POINT"/home/lnd/walletunlock.txt
143144
sed -i "s/^wallet-unlock-password-file=.*/;wallet-unlock-password-file=\/home\/lnd\/walletunlock.txt/" "$USD_MOUNT_POINT"/home/lnd/lnd.mainnet.conf
145+
sed -i "s/^wallet-unlock-password-file=.*/;wallet-unlock-password-file=\/home\/lnd\/walletunlock.txt/" "$USD_MOUNT_POINT"/home/lnd/lnd.testnet3.conf
144146
echo "done."
145147
else
146148
echo "Aborted."
@@ -160,18 +162,22 @@ run_main()
160162
echo "$NAKAMOCHI_ID" > "$USD_MOUNT_POINT"/etc/nakamochi-id
161163
echo "$NAKAMOCHI_ID" > "$SSD_MOUNT_POINT"/nakamochi-id
162164

163-
# generate 2 onion services, one for bitcoind and one for lnd
165+
# generate onion services for bitcoind and lnd
164166
echo -n "Generating onion services ... "
165167
onion_tmp_dir="$(mktemp -d)"
166168
mkp224o -d "$onion_tmp_dir" -n 1 b
169+
mkp224o -d "$onion_tmp_dir" -n 1 tb
167170
mkp224o -d "$onion_tmp_dir" -n 1 l
171+
mkp224o -d "$onion_tmp_dir" -n 1 tl
168172
echo "done."
169173

170174
# copy the generated service directories to the SSD and fix user/group
171175
echo -n "Configuring onion services ... "
172-
mkdir -p "$SSD_MOUNT_POINT"/tor/{bitcoind,lnd}
176+
mkdir -p "$SSD_MOUNT_POINT"/tor/{bitcoind,bitcoind-testnet3,lnd,lnd-testnet3}
173177
cp -r "$onion_tmp_dir"/b*/* "$SSD_MOUNT_POINT"/tor/bitcoind/
178+
cp -r "$onion_tmp_dir"/tb*/* "$SSD_MOUNT_POINT"/tor/bitcoind-testnet3/
174179
cp -r "$onion_tmp_dir"/l*/* "$SSD_MOUNT_POINT"/tor/lnd/
180+
cp -r "$onion_tmp_dir"/tl*/* "$SSD_MOUNT_POINT"/tor/lnd-testnet3/
175181
onion_user_group="$(grep tor "$USD_MOUNT_POINT"/etc/passwd | cut -d: -f 3-4)"
176182
chown -R "$onion_user_group" "$SSD_MOUNT_POINT"/tor
177183
echo "done."
@@ -190,20 +196,32 @@ run_main()
190196
echo "done."
191197

192198
# modify bitcoin configuration
193-
bitcoind_conf="$USD_MOUNT_POINT"/home/bitcoind/mainnet.conf
194-
echo -n "Finalizing bitcoin configuration ($bitcoind_conf) ..."
195-
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind/hostname)"
196-
patch_bitcoind_conf "$bitcoind_conf" "$bitcoind_rpcauth" "$bitcoind_rpcpass" "$bitcoind_onion_hostname"
197-
echo "done."
198-
grep rpc "$bitcoind_conf"
199+
for bitcoind_network in mainnet testnet3; do
200+
bitcoind_conf="$USD_MOUNT_POINT"/home/bitcoind/$bitcoind_network.conf
201+
echo -n "Finalizing bitcoin configuration ($bitcoind_conf) ..."
202+
if [[ "$bitcoind_network" == "mainnet" ]]; then
203+
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind/hostname)"
204+
else
205+
bitcoind_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/bitcoind-$bitcoind_network/hostname)"
206+
fi
207+
patch_bitcoind_conf "$bitcoind_conf" "$bitcoind_rpcauth" "$bitcoind_rpcpass" "$bitcoind_onion_hostname"
208+
echo "done."
209+
grep rpc "$bitcoind_conf"
210+
done
199211

200212
# modify lnd configuration
201-
lnd_conf="$USD_MOUNT_POINT"/home/lnd/lnd.mainnet.conf
202-
echo -n "Finalizing lnd configuration ($lnd_conf) ..."
203-
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd/hostname)"
204-
patch_lnd_conf "$lnd_conf" "$bitcoind_rpcuser" "$bitcoind_rpcpass" "$lnd_onion_hostname"
205-
echo "done."
206-
grep rpc "$lnd_conf"
213+
for bitcoind_network in mainnet testnet3; do
214+
lnd_conf="$USD_MOUNT_POINT"/home/lnd/lnd.$bitcoind_network.conf
215+
echo -n "Finalizing lnd configuration ($lnd_conf) ..."
216+
if [[ "$bitcoind_network" == "mainnet" ]]; then
217+
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd/hostname)"
218+
else
219+
lnd_onion_hostname="$(cat "$SSD_MOUNT_POINT"/tor/lnd-$bitcoind_network/hostname)"
220+
fi
221+
patch_lnd_conf "$lnd_conf" "$bitcoind_rpcuser" "$bitcoind_rpcpass" "$lnd_onion_hostname"
222+
echo "done."
223+
grep rpc "$lnd_conf"
224+
done
207225

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

0 commit comments

Comments
 (0)