Skip to content

Commit 236e89b

Browse files
committed
feat: update README and configuration files for Bitcoin full node setup, add Testnet3 support, and remove Bitcoin Knots template
1 parent daeec9f commit 236e89b

File tree

4 files changed

+125
-59
lines changed

4 files changed

+125
-59
lines changed

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Bitcoin Full Node on macOS with Lima VM
1+
# Bitcoin Development Toolkit for macOS with Lima VMs (Core Nodes, Layer 2, BTCFi)
22

3-
This repository provides Lima VM templates to run a Bitcoin full node on macOS (Apple Silicon) using either Bitcoin Core (v29.0), Bitcoin Knots (v28.1.knots20250305), or Bitcoin Core Testnet4. Using Lima VM allows running Bitcoin Core mainnet and testnet4 conflict-free simultaneously, ideal for development environments. All templates automate installation, verify binary signatures and checksums for security, generate a random RPC password, and configure the node as a systemd service with a dedicated storage path. Bitcoin Knots, a fork of Bitcoin Core, includes additional features like enhanced mempool policies. The Testnet4 template supports development and testing on the testnet4 network.
3+
This repository provides Lima VM templates to run Bitcoin full nodes on macOS (Apple Silicon) using Bitcoin Core (v29.0) for mainnet, testnet3, and testnet4. Each template runs in its own isolated Lima VM, allowing you to operate multiple networks simultaneously without conflicts. All templates automate installation, verify binary signatures and checksums for security, generate a random RPC password, and configure the node as a systemd service with a dedicated storage path. The macOS host never runs any bitcoind instances directly; all nodes run inside their respective Lima VMs for maximum isolation and safety.
44

55
## Prerequisites
66

77
- Lima (`brew install lima`)
88
- Storage path with ~600GB+ free space (e.g., `/Volumes/MyDrive`)
9+
- `bitcoin-cli` installed on macOS host (`brew install bitcoin`)
910

1011
## Setup
1112

@@ -18,9 +19,9 @@ This repository provides Lima VM templates to run a Bitcoin full node on macOS (
1819

1920
2. Choose a template:
2021

21-
- For Bitcoin Core: Use `bitcoin-core.yaml`.
22-
- For Bitcoin Knots: Use `bitcoin-knots.yaml`.
23-
- For Bitcoin Core Testnet4: Use `bitcoin-testnet4.yaml`.
22+
- For Bitcoin Core mainnet: Use `bitcoin-core.yaml`.
23+
- For Bitcoin Core testnet3: Use `bitcoin-testnet3.yaml`.
24+
- For Bitcoin Core testnet4: Use `bitcoin-testnet4.yaml`.
2425

2526
3. Update the template:
2627

@@ -29,7 +30,7 @@ This repository provides Lima VM templates to run a Bitcoin full node on macOS (
2930
```bash
3031
sed -i '' 's|/Volumes/Storage|/Volumes/MyDrive|g' <template-file>
3132
```
32-
Replace `<template-file>` with `bitcoin-core.yaml`, `bitcoin-knots.yaml`, or `bitcoin-testnet4.yaml`.
33+
Replace `<template-file>` with `bitcoin-core.yaml`, `bitcoin-testnet3.yaml`, or `bitcoin-testnet4.yaml`.
3334
- Ensure your storage path exists and has sufficient space.
3435

3536
4. Create and start VM:
@@ -39,9 +40,7 @@ This repository provides Lima VM templates to run a Bitcoin full node on macOS (
3940
limactl start <vm-name>
4041
```
4142

42-
Replace `<vm-name>` with `bitcoin-core`, `bitcoin-knots`, or `bitcoin-testnet4`, and `<template-file>` with the chosen template.
43-
44-
- Note: Bitcoin Knots downloads may be slow; allow extra time for `limactl start` to complete.
43+
Replace `<vm-name>` with `bitcoin-core`, `bitcoin-testnet3`, or `bitcoin-testnet4`, and `<template-file>` with the chosen template.
4544

4645
5. Verify:
4746

@@ -50,9 +49,41 @@ This repository provides Lima VM templates to run a Bitcoin full node on macOS (
5049
bitcoin-cli getblockchaininfo
5150
```
5251

52+
## Example bitcoin.conf for bitcoin-cli and development
53+
54+
The macOS host never runs bitcoind directly. Instead, you can use `bitcoin-cli` (installed via Homebrew) to interact with your nodes running inside the Lima VMs. For development or scripting, you may want a `~/.bitcoin/bitcoin.conf` file on your macOS host to define multiple networks and RPC credentials. Here is an example:
55+
56+
```ini
57+
[main]
58+
rpcuser=bitcoinuser
59+
rpcpassword=your_mainnet_rpc_password
60+
rpcconnect=127.0.0.1
61+
rpcport=8332
62+
63+
[test]
64+
testnet=1
65+
rpcuser=bitcoinuser
66+
rpcpassword=your_testnet3_rpc_password
67+
rpcconnect=127.0.0.1
68+
rpcport=18332
69+
70+
[testnet4]
71+
testnet=4
72+
rpcuser=bitcoinuser
73+
rpcpassword=your_testnet4_rpc_password
74+
rpcconnect=127.0.0.1
75+
rpcport=28332
76+
```
77+
78+
Adjust the `rpcpassword` and `rpcport` values to match those generated in your VM's `bitcoin.conf` files. This setup allows you to use `bitcoin-cli` on your macOS host to connect to any of your running nodes for mainnet, testnet3, or testnet4.
79+
5380
## Usage
5481
55-
- Run `bitcoin-cli getblockchaininfo` inside the VM to check node status.
82+
- Run one of the following inside the VM to check node status:
83+
- `bitcoin-cli getblockchaininfo` (mainnet)
84+
- `bitcoin-cli -testnet getblockchaininfo` (testnet3)
85+
- `bitcoin-cli -testnet4 getblockchaininfo` (testnet4)
86+
- Or, use `bitcoin-cli` from your macOS host with the appropriate `-conf` or `-rpc*` flags to connect to your VM nodes.
5687
- Ensure storage path is accessible before starting VM.
5788
5889
## Connect
Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# lima.yaml for bitcoin-knots VM
1+
# filepath: /Users/user/dev/bitcoin/bitcoin-lima/bitcoin-testnet3.yaml
2+
# lima.yaml for bitcoin-core Testnet3 VM
23
images:
34
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
45
arch: "aarch64"
@@ -9,7 +10,7 @@ mounts:
910
9p:
1011
securityModel: none
1112
cache: mmap
12-
- location: "/Volumes/Storage/bitcoin"
13+
- location: "/Volumes/Storage/bitcoin-testnet"
1314
writable: true
1415
9p:
1516
securityModel: none
@@ -25,86 +26,91 @@ provision:
2526
set -x
2627
sudo apt update
2728
sudo apt install -y wget tar openssl gnupg coreutils
28-
VERSION="28.1.knots20250305"
29-
# Download Bitcoin Knots files with retries
29+
VERSION="29.0"
30+
31+
# Download Bitcoin Core files
32+
wget https://bitcoincore.org/bin/bitcoin-core-${VERSION}/bitcoin-${VERSION}-aarch64-linux-gnu.tar.gz
33+
wget https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS
34+
wget https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS.asc
35+
36+
# Import keys (fanquake, achow101) with retries
3037
for i in {1..3}; do
31-
wget -O bitcoin-${VERSION}-aarch64-linux-gnu.tar.gz https://bitcoinknots.org/files/28.x/${VERSION}/bitcoin-${VERSION}-aarch64-linux-gnu.tar.gz && break
32-
echo "Download tarball attempt $i failed. Retrying..." >&2
38+
gpg --keyserver keyserver.ubuntu.com --recv-keys 0x0CCBAAFD76A2ECE2CCD3141DE2FFD5B1D88CA97D 0x152812300785C96444D3334D17565732E08E5E41 && break
39+
echo "Keyserver attempt $i failed. Retrying..." >&2
3340
sleep 2
3441
done
35-
for i in {1..3}; do
36-
wget -O SHA256SUMS https://bitcoinknots.org/files/28.x/${VERSION}/SHA256SUMS && break
37-
echo "Download SHA256SUMS attempt $i failed. Retrying..." >&2
38-
sleep 2
39-
done
40-
for i in {1..3}; do
41-
wget -O SHA256SUMS.asc https://bitcoinknots.org/files/28.x/${VERSION}/SHA256SUMS.asc && break
42-
echo "Download SHA256SUMS.asc attempt $i failed. Retrying..." >&2
43-
sleep 2
44-
done
45-
# Import Luke Dashjr's key with retries and fallback keyserver
46-
for i in {1..3}; do
47-
gpg --keyserver keyserver.ubuntu.com --recv-keys 0x0CCBAAFD76A2ECE2CCD3141DE2FFD5B1D88CA97D && break
48-
echo "Keyserver attempt $i failed (keyserver.ubuntu.com). Trying keys.openpgp.org..." >&2
49-
gpg --keyserver keys.openpgp.org --recv-keys 0x0CCBAAFD76A2ECE2CCD3141DE2FFD5B1D88CA97D && break
50-
echo "Keyserver attempt $i failed (keys.openpgp.org). Retrying..." >&2
51-
sleep 2
52-
done
53-
# Verify signature (fallback to checksum if no key)
42+
43+
# Verify signature (fallback to checksum if no keys)
5444
if gpg --verify SHA256SUMS.asc SHA256SUMS 2> gpg-verify.log && grep -q "Good signature" gpg-verify.log; then
5545
echo "Signature verified successfully."
5646
else
57-
echo "Warning: Signature verification failed or no key imported. Proceeding with checksum only." >&2
47+
echo "Warning: Signature verification failed or no keys imported. Proceeding with checksum only." >&2
5848
cat gpg-verify.log >&2
5949
fi
50+
6051
# Verify checksum
6152
if ! sha256sum --ignore-missing --check --strict SHA256SUMS; then
6253
echo "Error: Checksum verification failed." >&2
6354
exit 1
6455
fi
65-
# Install Bitcoin Knots
56+
57+
# Install Bitcoin Core
6658
tar -xzf bitcoin-${VERSION}-aarch64-linux-gnu.tar.gz
6759
sudo mv bitcoin-${VERSION} /usr/local/bitcoin
6860
sudo ln -s /usr/local/bitcoin/bin/bitcoind /usr/local/bin/bitcoind
6961
sudo ln -s /usr/local/bitcoin/bin/bitcoin-cli /usr/local/bin/bitcoin-cli
70-
# Configure Bitcoin Knots
62+
63+
# Configure Bitcoin Core
7164
sudo mkdir -p /home/user.linux/.bitcoin
65+
7266
cat > /home/user.linux/.bitcoin/bitcoin.conf <<EOF
73-
datadir=/Volumes/Storage/bitcoin
74-
txindex=1
67+
[test]
68+
testnet=1
69+
datadir=/Volumes/Storage/bitcoin-testnet/testnet
70+
rpcuser=bitcoinuser
71+
rpcpassword=$(openssl rand -base64 12)
7572
rpcbind=127.0.0.1
76-
rpcport=8332
7773
rpcallowip=127.0.0.1
74+
rpcport=18332
7875
server=1
79-
rpcuser=bitcoinuser
80-
rpcpassword=$(openssl rand -base64 12)
76+
txindex=1
8177
EOF
78+
8279
sudo chown -R user:user /home/user.linux/.bitcoin
8380
sudo chmod -R 755 /home/user.linux/.bitcoin
8481
sudo chmod 600 /home/user.linux/.bitcoin/bitcoin.conf
82+
8583
# Fix home permissions
8684
sudo chown -R user:user /home/user.linux
8785
sudo chmod 755 /home/user.linux
86+
8887
# Set up PATH
8988
echo 'export PATH=$PATH:/usr/local/bin' > /home/user.linux/.bashrc
9089
sudo chown user:user /home/user.linux/.bashrc
9190
sudo chmod 644 /home/user.linux/.bashrc
91+
9292
# Set up storage mount
93-
sudo chown -R user:user /Volumes/Storage/bitcoin || echo "Warning: Failed to chown /Volumes/Storage/bitcoin"
94-
sudo chmod -R 755 /Volumes/Storage/bitcoin || echo "Warning: Failed to chmod /Volumes/Storage/bitcoin"
95-
if ! mount | grep -q /Volumes/Storage/bitcoin; then
96-
echo "Error: /Volumes/Storage/bitcoin not mounted" >&2
93+
sudo chown -R user:user /Volumes/Storage/bitcoin-testnet || echo "Warning: Failed to chown /Volumes/Storage/bitcoin-testnet"
94+
sudo chmod -R 755 /Volumes/Storage/bitcoin-testnet || echo "Warning: Failed to chmod /Volumes/Storage/bitcoin-testnet"
95+
if ! mount | grep -q /Volumes/Storage/bitcoin-testnet; then
96+
echo "Error: /Volumes/Storage/bitcoin-testnet not mounted" >&2
9797
exit 1
9898
fi
99+
100+
# Ensure testnet directory exists and has proper permissions
101+
sudo mkdir -p /Volumes/Storage/bitcoin-testnet/testnet
102+
sudo chown -R user:user /Volumes/Storage/bitcoin-testnet/testnet
103+
sudo chmod -R 755 /Volumes/Storage/bitcoin-testnet/testnet
104+
99105
# Create systemd service
100106
cat > /etc/systemd/system/bitcoind.service <<EOF
101107
[Unit]
102-
Description=Bitcoin Knots daemon
108+
Description=Bitcoin daemon (Testnet3)
103109
After=network.target
104110
[Service]
105111
User=user
106112
Group=user
107-
ExecStart=/usr/local/bin/bitcoind -conf=/home/user.linux/.bitcoin/bitcoin.conf
113+
ExecStart=/usr/local/bin/bitcoind -testnet -conf=/home/user.linux/.bitcoin/bitcoin.conf
108114
Restart=always
109115
TimeoutStopSec=60s
110116
TimeoutStartSec=60s
@@ -119,13 +125,9 @@ provision:
119125
script: |
120126
#!/bin/bash
121127
set -x
122-
sleep 10
128+
sleep 5
123129
if ! pgrep bitcoind >/dev/null; then
124130
echo "Error: bitcoind not running" >&2
125131
exit 1
126132
fi
127-
# Run bitcoin-cli with timeout to avoid hanging
128-
timeout 30 bitcoin-cli getblockchaininfo || {
129-
echo "Warning: bitcoin-cli getblockchaininfo timed out or failed." >&2
130-
exit 1
131-
}
133+
bitcoin-cli -testnet getblockchaininfo

bitcoin-testnet4.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ provision:
6363
sudo mkdir -p /home/user.linux/.bitcoin
6464
cat > /home/user.linux/.bitcoin/bitcoin.conf <<EOF
6565
[testnet4]
66-
datadir=/Volumes/Storage/bitcoin-testnet
66+
testnet4=1
67+
datadir=/Volumes/Storage/bitcoin-testnet/testnet4
6768
rpcuser=bitcoinuser
6869
rpcpassword=$(openssl rand -base64 12)
69-
txindex=1
70-
server=1
71-
rpcport=18443
7270
rpcbind=127.0.0.1
7371
rpcallowip=127.0.0.1
72+
rpcport=18443
73+
server=1
74+
txindex=1
7475
EOF
7576
7677
sudo chown -R user:user /home/user.linux/.bitcoin
@@ -94,6 +95,11 @@ provision:
9495
exit 1
9596
fi
9697
98+
# Ensure testnet4 directory exists and has proper permissions
99+
sudo mkdir -p /Volumes/Storage/bitcoin-testnet/testnet4
100+
sudo chown -R user:user /Volumes/Storage/bitcoin-testnet/testnet4
101+
sudo chmod -R 755 /Volumes/Storage/bitcoin-testnet/testnet4
102+
97103
# Create systemd service
98104
cat > /etc/systemd/system/bitcoind.service <<EOF
99105
[Unit]

example.bitcoin.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[main]
2+
txindex=1
3+
server=1
4+
rpcport=8332
5+
rpcuser=bitcoinuser
6+
rpcconnect=127.0.0.1
7+
rpcpassword=strongpassword
8+
9+
[test]
10+
txindex=1
11+
server=1
12+
rpcport=18332
13+
rpcbind=127.0.0.1
14+
rpcallowip=127.0.0.1
15+
rpcuser=bitcoinuser
16+
rpcpassword=strongpassword
17+
testnet=1
18+
19+
[testnet4]
20+
txindex=1
21+
server=1
22+
rpcbind=127.0.0.1
23+
rpcport=18443
24+
rpcallowip=127.0.0.1
25+
rpcuser=bitcoinuser
26+
rpcpassword=strongpassword
27+
testnet4=1

0 commit comments

Comments
 (0)