2021-01-06 01:53:56 +00:00
<!-- omit in toc -->
# Prepare a bitcoin node to accept a remote RPC connection
2021-01-18 19:34:10 +00:00
2023-07-23 06:35:04 +00:00
If you have arrived here from running JoininBox locally on the RaspiBlitz can skip these steps (CTRL+C to exit the connection settings). The connection to the local bitcoin node is set up automatically.
2021-01-18 19:34:10 +00:00
JoinMarket (running in JoininBox) needs to connect to Bitcoin Core via RPC.
2021-01-06 01:53:56 +00:00
A pruned node with the **bitcoind wallet enabled** will do and txindex is not required.
- [RaspiBlitz ](#raspiblitz )
- [Enable the bitcoind wallet ](#enable-the-bitcoind-wallet )
- [LAN connection ](#lan-connection )
- [Tor connection ](#tor-connection )
2023-07-23 06:35:04 +00:00
- [CONFIG -\> CONNECT in JoininBox ](#config---connect-in-joininbox )
2021-01-06 01:53:56 +00:00
- [RoninDojo ](#ronindojo )
- [Enable the bitcoind wallet ](#enable-the-bitcoind-wallet-1 )
- [LAN connection ](#lan-connection-1 )
- [Tor connection ](#tor-connection-1 )
- [Recompile the Docker containers (takes time) ](#recompile-the-docker-containers-takes-time )
2023-07-23 06:35:04 +00:00
- [CONFIG -\> CONNECT in JoininBox ](#config---connect-in-joininbox-1 )
2021-01-06 01:53:56 +00:00
- [Resources ](#resources )
## RaspiBlitz
### Enable the bitcoind wallet
Since the RaspiBlitz v1.6 run this script:
`$ config.scripts/network.wallet.sh on`
To set up manually:
* Edit the bitcoin.conf:
`$ sudo nano /mnt/hdd/bitcoin/bitcoin.conf`
* Change the disablewallet option to 0:
```
disablewallet=0
```
* Restart bitcoind:
`$ sudo systemctl restart bitcoind`
### LAN connection
2020-01-27 07:16:41 +00:00
2020-12-10 17:02:01 +00:00
In the terminal of the node - allow remote RPC connections to Bitcoin Core
This can be skipped if you [connect through Tor ](#tor-connection )
2020-01-27 07:16:41 +00:00
2020-12-10 17:02:01 +00:00
1) Edit the bitcoin.conf
2020-01-27 07:16:41 +00:00
`$ sudo nano /mnt/hdd/bitcoin/bitcoin.conf`
2020-09-15 09:18:29 +01:00
Add the values:
2021-01-18 19:34:10 +00:00
* `rpcallowip=JOININBOX_IP` or `RANGE`
2021-01-19 22:46:07 +00:00
* either specify the LAN IP of the computer (here JoininBox)
2021-01-18 19:34:10 +00:00
* or use a range like: `192.168.1.0/24` - edit to your local subnet - the first 3 numbes of the LAN IP address, the example used here is: 192.168.1.x
* `rpcbind=LAN_IP_OF_THE_NODE`
* use the local IP of the bitcoin node in the example: `192.168.1.4`
2023-07-23 06:35:04 +00:00
* can keep the other `rpcallowip` and `rpcbind` entries especially for the localhost: `127.0.0.1`
2021-01-18 19:34:10 +00:00
Example:
2021-01-19 22:46:07 +00:00
```bash
2020-01-27 07:16:41 +00:00
rpcallowip=192.168.1.0/24
2021-01-18 19:34:10 +00:00
rpcbind=192.168.1.4
2020-01-27 07:16:41 +00:00
```
2020-12-10 17:02:01 +00:00
2) Restart Bitcoin Core
2020-01-27 07:16:41 +00:00
`$ sudo systemctl restart bitcoind`
2020-12-10 17:02:01 +00:00
3) Open the firewall to allow the RPC connection from LAN
2021-01-18 19:34:10 +00:00
edit to your local subnet - in the example here 192.168.1.X):
`$ sudo ufw allow from 192.168.1.0/24 to any port 8332`
2020-01-27 07:16:41 +00:00
2020-12-10 17:02:01 +00:00
4) Take note of the `LAN_ADDRESS` of the remote node and fill it in to the `rpc_host` in `joinmarket.cfg`
2020-06-21 13:21:28 +01:00
2021-01-06 01:53:56 +00:00
### Tor connection
2020-01-27 07:16:41 +00:00
2020-12-10 17:02:01 +00:00
On the node - activate Tor and create a Hidden Service
2020-01-27 07:16:41 +00:00
2020-12-10 17:02:01 +00:00
Make sure that Tor is installed or active in the SERVICES menu
2020-01-27 07:16:41 +00:00
2021-01-06 01:53:56 +00:00
Create a Hidden Service to forward the bitcoin RPC port:
2020-01-27 07:16:41 +00:00
2022-03-31 07:41:16 +01:00
1) On the RaspiBlitz there is a script to create a hidden service
* Raspiblitz v1.7.2 and above:
```
~/config.scripts/tor.onion-service.sh bitcoinrpc 8332 8332
```
* Raspiblitz v1.4 - v1.7.1:
```
~/config.scripts/internet.hiddenservice.sh bitcoinrpc 8332 8332
```
2020-12-10 17:02:01 +00:00
2) Take note of the `Tor_Hidden_Service.onion` and fill in to the `rpc_host` in the `joinmarket.cfg`
2020-06-20 19:20:11 +01:00
Alternatively proceed manually:
2020-12-10 17:02:01 +00:00
1) Open the Tor configuration file
2020-01-27 07:16:41 +00:00
`$ sudo nano /etc/tor/torrc`
2020-12-10 17:02:01 +00:00
2) Insert the lines
2020-01-27 07:16:41 +00:00
```bash
# Hidden Service v3 for bitcoinrpc
HiddenServiceDir /mnt/hdd/tor/bitcoinrpc
HiddenServiceVersion 3
HiddenServicePort 8332 127.0.0.1:8332
```
2020-12-10 17:02:01 +00:00
3) Restart Tor
2020-01-27 07:16:41 +00:00
`$ sudo systemctl restart tor`
2020-12-10 17:02:01 +00:00
4) Take note of the `Tor_Hidden_Service.onion`
2020-01-27 07:16:41 +00:00
`$ sudo cat /mnt/hdd/tor/bitcoinrpc/hostname`
2021-01-06 01:53:56 +00:00
Fill in the `Tor_Hidden_Service.onion` to the `rpc_host` in the `joinmarket.cfg`
2021-02-14 13:10:38 +00:00
### CONFIG -> CONNECT in JoininBox
2021-02-14 11:55:48 +00:00
* Username: `raspibolt `
* Password: `passwordB` or `sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-`
* Host: `LAN_IP_OF_THE_NODE` or `sudo cat /mnt/hdd/tor/bitcoinrpc/hostname`
* Port: `8332`
2021-02-14 13:10:38 +00:00
2021-01-06 01:53:56 +00:00
---
## RoninDojo
### Enable the bitcoind wallet
2021-02-14 13:10:38 +00:00
* Run in the RoninDojo ssh terminal:
2021-02-14 11:55:48 +00:00
```bash
2021-02-14 13:10:38 +00:00
$ sed -i 's/ -disablewallet=.*$/ -disablewallet=0/' ~/dojo/docker/my-dojo/bitcoin/restart.sh
2021-02-14 11:55:48 +00:00
```
2021-01-06 01:53:56 +00:00
2021-02-14 11:55:48 +00:00
* Alternatively edit manually
2021-01-06 01:53:56 +00:00
`$ nano ~/dojo/docker/my-dojo/bitcoin/restart.sh`
2021-02-14 11:55:48 +00:00
modify:
```bash
-disablewallet=1
```
to:
```bash
-disablewallet=0
```
2021-01-06 01:53:56 +00:00
### LAN connection
2021-02-14 11:55:48 +00:00
* Edit the bitcoind container settings
2021-01-06 01:53:56 +00:00
`$ nano ~/dojo/docker/my-dojo/conf/docker-bitcoind.conf`
2021-02-14 11:55:48 +00:00
* Set the following:
```bash
# should be already on
BITCOIND_RPC_EXTERNAL=on
# the RoninDojo_IP is the LAN IP address of your RoninDojo
BITCOIND_RPC_EXTERNAL_IP=RoninDojo_IP
```
2021-01-06 01:53:56 +00:00
2021-02-14 11:55:48 +00:00
* Open the firewall to allow the RPC connection from LAN
2021-01-06 01:53:56 +00:00
(edit to your local subnet - in the example here 192.168.1.X):
`$ sudo ufw allow from 192.168.1.0/24 to any port 28256`
2021-02-14 13:10:38 +00:00
* Note that Dojo uses the port 28256 instead of the default 8332.
2021-01-06 01:53:56 +00:00
### Tor connection
2021-02-14 11:55:48 +00:00
* Create a Hidden Service to forward the bitcoin RPC port
2021-01-06 01:53:56 +00:00
2021-02-14 11:55:48 +00:00
* Edit the torrc
2021-01-06 01:53:56 +00:00
`$ sudo nano /etc/tor/torrc`
2021-02-14 11:55:48 +00:00
* Add:
```bash
HiddenServiceDir /var/lib/tor/bitcoinrpc/
HiddenServiceVersion 3
HiddenServicePort 8332 127.0.0.1:28256
```
* Restart Tor
2021-01-06 01:53:56 +00:00
`$ sudo systemctl restart tor`
2021-02-14 11:55:48 +00:00
* Show the .onion service address
2021-01-06 01:53:56 +00:00
`$ sudo cat /var/lib/tor/bitcoinrpc/hostname`
2021-02-14 13:10:38 +00:00
### Recompile the Docker containers (takes time)
2021-01-06 01:53:56 +00:00
`$ cd ~/dojo/docker/my-dojo && ./dojo.sh upgrade --nolog`
2020-12-10 17:02:01 +00:00
2021-02-14 13:10:38 +00:00
### CONFIG -> CONNECT in JoininBox
Fill the connection settings from the `5 Credentials` -> `6 Bitcoind` menu of RoninDojo:
2021-02-14 11:55:48 +00:00
* RPC username: `RoninDojo`
* RPC password: `RPC Password`
* Host: `RoninDojo_IP` or `sudo cat /var/lib/tor/bitcoinrpc/hostname`
* Port: `28256` for LAN or `8332` for the .onion service
2020-06-20 19:20:11 +01:00
2021-01-06 01:53:56 +00:00
---
2020-02-03 08:46:27 +00:00
2021-01-06 01:53:56 +00:00
## Resources
2020-01-27 07:16:41 +00:00
* [JoinMarket on the RaspiBlitz guide ](https://github.com/openoms/bitcoin-tutorials/blob/master/joinmarket/README.md )
2020-02-28 07:06:04 +00:00
* [Connect JoinMarket running on a Linux desktop to a remote node ](https://github.com/openoms/bitcoin-tutorials/blob/master/joinmarket/joinmarket_desktop_to_blitz.md )
2021-02-14 13:10:38 +00:00
* Note about the Tor connection (applied automatically in the JoininBox):
2021-10-03 00:37:34 +01:00
Remember to use `torsocks` with the python scripts when connecting remotely through Tor
2021-02-14 13:10:38 +00:00
Example:
2021-10-03 00:37:34 +01:00
`torsocks wallet-tool.py wallet.jmdat`
2022-03-31 07:41:16 +01:00
also need to [allow Tor to connect to localhost ](FAQ.md#allow-tor-to-connect-to-localhost )