Convert raw data with ETL
π§ 1. Enable Pruned Mode (to save disk space)β
Pruned mode keeps only the latest blocks to save storage.
Edit bitcoin.conf
:β
nano ~/.bitcoin/bitcoin.conf
Add or update:
prune=550 # Keep ~550 MB of recent blocks
β You cannot use
txindex=1
with pruning. If you want to save space, removetxindex=1
.
π‘ 2. Enable ZMQ (for real-time block and transaction stream)β
ZMQ allows real-time access to new transactions and blocks.
In bitcoin.conf
, add:β
zmqpubrawblock=tcp://127.0.0.1:28333
zmqpubrawtx=tcp://127.0.0.1:28332
This tells bitcoind
to publish:
- Raw blocks to port
28333
- Raw transactions to port
28332
You can subscribe using a Python library like pyzmq
or bitcoin-rpc
.
π 3. Enable Remote RPC Access (if needed)β
If you want to connect to bitcoind
remotely:
Edit bitcoin.conf
:β
rpcbind=0.0.0.0
rpcallowip=192.168.1.0/24 # Replace with your LAN subnet
rpcport=8332
β οΈ NEVER expose RPC to the internet without authentication and proper firewall rules.
π§ͺ 4. Test Your Setupβ
Run:
bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=strongpassword getblockchaininfo
If remote, add:
bitcoin-cli -rpcconnect=YOUR_NODE_IP -rpcport=8332 ...
π Bonus: Check ZMQ Events with Python (optional)β
Install Python dependencies:
pip install pyzmq
Test listener:
import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://127.0.0.1:28332") # or 28333 for blocks
socket.setsockopt_string(zmq.SUBSCRIBE, '')
while True:
msg = socket.recv()
print(f"Received: {msg.hex()}")