> For the complete documentation index, see [llms.txt](https://docs.money-printer-go-brrr.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.money-printer-go-brrr.com/readme/bitcoin-node/setup-your-bitcoin-node-from-source/setup-btc-rpc-explorer.md).

# Setup BTC RPC Explorer

Install BTC RPC Explorer on your Bitcoin node.

BTC RPC Explorer is essentially a web GUI for the Bitcoin JSON-RPC API. It is highly useful for node monitoring, management, and as a blockchain explorer.

{% hint style="info" %}
Before you start make sure [you've installed Node.js](https://docs.money-printer-go-brrr.com/readme/bitcoin-node/setup-your-bitcoin-node-from-source/pages/gmuDSdqoNxOTfItUIJQr#install-node.js).
{% endhint %}

## Install BTC RPC Explorer

### Get the latest stable release

Clone the repo:

```bash
cd ~
```

```bash
git clone https://github.com/janoside/btc-rpc-explorer.git
```

```bash
cd btc-rpc-explorer/
```

Show the latest version tags:

```
git describe --tags `git rev-list --tags --max-count=20`
```

Switch to the latest stable version:

```
git checkout -f <version-tag>
```

### Install

Update local dependencies within version ranges specified in package.json:

```
npm update
```

Install:

```
npm install
```

{% hint style="danger" %}
If you get an error try updating the following packages to their latest version instead:
{% endhint %}

```
npm install zeromq@latest
```

```
npm install nan@latest
```

Then try installing again:

```
npm install
```

### Configure

Create the config file:

```
touch .env
```

Add the following:

```
BTCEXP_HOST=192.168.1.52
BTCEXP_PORT=3002
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_COOKIE=/home/your_user/.bitcoin/.cookie
BTCEXP_BITCOIND_RPC_TIMEOUT=5000
BTCEXP_PRIVACY_MODE=true
BTCEXP_BASIC_AUTH_PASSWORD=your_secure_password
BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:50001
```

* <kbd>BTCEXP\_HOST</kbd>: Replace with your Pi's local IP to make BTC RPC Explorer accessible on your LAN.
* <kbd>BTCEXP\_BITCOIND\_COOKIE</kbd>: Update the path with your own user.
* <kbd>BTCEXP\_BASIC\_AUTH\_PASSWORD</kbd>: Set a strong password to secure access.

{% hint style="info" %}
With this setup, BTC RPC Explorer is accessible from any machine on our LAN, is password-protected, and also connected to our Electrum server.
{% endhint %}

## Configure systemd service

Create the service file:

```bash
sudo cat /etc/systemd/system/btc-rpc-explorer.service
```

Add the following:

```
[Unit]
Description=BTC-RPC-Explorer
Requires=electrs.service
After=electrs.service
[Service]
WorkingDirectory=/home/your_user/btc-rpc-explorer
ExecStart=npm run start
User=your_user
Group=your_user
Type=simple
Restart=on-failure
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target
```

Line 6,8 and 9 make sure to replace <kbd>your\_user</kbd> by your own user.&#x20;

{% hint style="info" %}
See `.env-sample` to discover more options.
{% endhint %}

Finally, reload systemd:

```bash
sudo systemctl daemon-reload
```

## Startup

Configure <kbd>BTC-RPC Explorer</kbd> to automatically start at boot:

```
sudo systemctl enable btc-rpc-explorer.service
```

Start <kbd>BTC-RPC Explorer</kbd>:

```
sudo systemctl start btc-rpc-explorer.service
```

{% hint style="success" %}
Access BTC RPC Explorer at <kbd><http://NODE-IP:3002></kbd> from any device on your LAN.
{% endhint %}

You'll see a popup asking you to enter a username and password. The username doesn't matter; just use the password you set up in the `.env` file.

## Issue with Node Details page

The page `/node-details` of BTC RPC Explorer throws an error. I suck at coding but I was able to fix it with ChatGPT.&#x20;

Edit the below file:

```
vim views/node-details.pug
```

At line 29, replace this block of code:

```javascript
if (getblockchaininfo.warnings && getblockchaininfo.warnings.trim().length > 0)
	+contentSection("Active Warnings")
		if (getblockchaininfo.warnings && getblockchaininfo.warnings.trim().length > 0)
			span.text-danger #{getblockchaininfo.warnings}
		else
			span.text-success None
```

By this one:

```javascript
if (getblockchaininfo.warnings)
	+contentSection("Active Warnings")
		if (getblockchaininfo.warnings)
			span.text-danger #{getblockchaininfo.warnings}
		else
			span.text-success None
```

(Basically I removed <kbd>getblockchaininfo.warnings.trim().length > 0</kbd> in both if statements).

{% hint style="danger" %}
This is a dirty DIY way of patching it, but it does the job lol.
{% endhint %}

Make sure to restart BTC RPC Explorer and the page should be working:

```
sudo systemctl restart btc-rpc-explorer.service
```

## Tor

I personally wouldn't risk exposing this app to the outside world. It has some bugs, is vulnerable to brute-force attacks, and stores the password in a plain text `.env` file.

If I ever do, I will ensure that the features enabling manual Bitcoin JSON-RPC API calls are disabled.
