Setting up Bitcoin Core with RPC over LAN: A step-by-step guide
When setting up your small computer as a Bitcoin node, it’s important to make sure you can access the node state remotely using Remote Procedure Call (RPC) to manage your wallet and troubleshoot problems. In this article, we will look at the correct configuration and command to run Bitcoin Core (BTCS) on your local computer with RPC capabilities over a local network.
Prerequisites
- A small computer (e.g. Raspberry Pi or a PC with sufficient processing power)
*Bitcoin Core version 0.19.1 or later.
- Compatible network adapter for your device.
Step by Step Setup
Install Bitcoin Core on your local computer
- Download and install Bitcoin Core from the official repository:
wget RPM
- Run the installation script:
sudo rpm -ivf bitcoin-0.19.1-1.x86_64-1.0.2-1.i686.noarch.rpm
- Set the default directory of your wallet
wallet_dir
to a safe place (eg/var/lib/btc/
):
echo "/var/lib/btc/" > ~/.bitcoinrc
Configuring RPC via local network
To enable RPC over a local network, it is necessary to configure the server and listen to a certain port. The default RPC port is 8332, but we will change it here.
- Update the
~/.bitcoinrc
file:
rpserver -p 8332 -a "/path/to/your/wallet" --port=8332
Replace /path/to/your/wallet
with the path to your wallet directory.
- To listen to a specific IP address or network, use the “listen_address” parameter:
rpcerver -p 8332 -a "/path/to/your/wallet" --port=8332 --listen_address=0.0.0.0
This will allow you to connect to RPC from anywhere on the local network.
Running Bitcoin Core with RPC
- Start the server:
sudo systemctl start bitcoin core
- To verify that you can connect to your host using RPC, use the
bitcoin-cli
command:
bitcoin-cli --address=0.0.0.0:8332 getnewaddress
This will create a new wallet address. You can then use this address to send transactions remotely.
Troubleshooting
*If you experience problems with RPC connections, check the Bitcoin Core logs for errors.
- Make sure your network adapter is configured to listen on port 8332 or a specific IP address.
*If you are using a VPN connection, make sure that the VPN server allows RPC traffic.
By following these steps and configuring your Bitcoin Core node with RPC capabilities over your local network, you will be able to access your wallet status remotely from your own local network.