Howto: Compile Bitcoin 0.17.0rc3 with tor, ncurses2 on FreeNAS 11.2 iocage jail

Status
Not open for further replies.

Bashern

Dabbler
Joined
Sep 1, 2015
Messages
26
I keep a guide up to date here: https://github.com/seth586/guides/tree/master/FreeNAS

After fumbling around the internet, I've discovered that there are a ton of bitcoin node guides for linux, and virtually nothing for FreeBSD. This guide will get Bitcoin Core 0.17.0rc3 compiled from source (or anther release you choose) and running as a public and tor hidden service. This also includes instructions on installing ncurses2, a terminal user interface for your bitcoin node.

This should be a good starting point for your lnd, electrum, or btcpay servers.

I wrote a guide on medium, you can see it here. I'll make an abridged version here.

First of all, create your jail using the FreeNAS GUI. Give it a static lease and forward port 8333. SSH into your FreeNAS box.

iocage list
iocage console bitcoin_node

pkg install autoconf automake boost-libs git gmake libevent libtool openssl pkgconf wget nano tor


Go to https://github.com/bitcoin/bitcoin/releases, find the tar.gz release we want to install. The latest release is 0.16.3 at https://github.com/bitcoin/bitcoin/archive/v0.16.3.tar.gz

wget https://github.com/bitcoin/bitcoin/archive/v0.16.3.tar.gz
tar xzvf v0.16.3.tar.gz
cd bitcoin-0.16.3
./autogen.sh
./configure --disable-wallet --without-gui --without-miniupnpc --disable-dependency-tracking
gmake
gmake install


This process may take a while. Once its done and installed, we need to add a service script and then call it on boot. FreeBSD ports maintains a service script we can use at https://github.com/freebsd/freebsd-ports/blob/master/net-p2p/bitcoin/files/bitcoind.in (click on the RAW link to get a direct link to the file)

cd /etc/rc.d/
wget https://raw.githubusercontent.com/freebsd/freebsd-ports/master/net-p2p/bitcoin/files/bitcoind.in
mv bitcoind.in bitcoind
chmod +x bitcoind
sysrc 'bitcoind_enable=yes'


Lets edit the startup script for our local environment:

nano bitcoind


The %%PREVIX%% variables need to be changed to local paths, and the users needs to be changed to _tor:

command="/usr/local/bin/bitcoind"
: ${bitcoind_user:="_tor"}
: ${bitcoind_group:="_tor"}
: ${bitcoind_config_file:="/root/.bitcoin/bitcoin.conf"}


Lets make bitcoin's folders and configuration file:

mkdir /var/db/bitcoin
mkdir /root/.bitcoin
nano /root/.bitcoin/bitcoin.conf


Add the collowing lines to bitcoin.conf:

datadir=/var/db/bitcoin
server=1
txindex=1


Configure Tor:

sysrc 'tor_enable=yes'
nano /usr/local/etc/tor/torrc


Add the following lines to tor’s configuration file:

ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1


Restart your jail, and SSH back in. Check running processes. You should see bitcoind and tor running as uid "_tor":

ps auxww


Bitcoin-cli will reveal your tor address:

bitcoin-cli getnetworkinfo


And install ncurses2:

cd /root
pkg install py36-pip python3
git clone https://github.com/esotericnonsense/bitcoind-ncurses2
pip-3.6 install -r bitcoind-ncurses2/requirements.txt
python3 /root/bitcoind-ncurses2/main.py --datadir /var/db/bitcoin


Use CTRL+Z to suspend.

Enjoy! Please leave feedback and questions below! I'm a FreeBSD hobbyist, so I have no formal education, if something should be done better let me know!

Edit: 9/18/2018: version 0.17.0rc3 superseded by 0.16.3
 
Last edited:

Bashern

Dabbler
Joined
Sep 1, 2015
Messages
26
And here is my problem, I can't compile with wallet support (see flag --disable-wallet). The FreeBSD build guide on bitcoin's github explains how to install the berkeley db 4.8 dependancy, but it fails.

https://github.com/bitcoin/bitcoin/blob/master/doc/build-freebsd.md

I tried pkg install db48, but when I run the ./configure I get an error:

configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)

So I tried the following to compile Berkeley Database 4.8:
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/home/theusername/bitcoin/db4/
make install


And I get the following error:

../dist/../dbinc/atomic.h:179:19: error: definition of builtin function '__atomic_compare_exchange'
static inline int __atomic_compare_exchange(
^
1 error generated.
*** Error code 1

Stop.
make: stopped in /db-4.8.30.NC/build_unix

 

8-bit Yoda

Explorer
Joined
Jun 16, 2018
Messages
68
The following compiled for me...

Code:
pkg install autoconf automake boost-libs git gmake libevent libtool openssl pkgconf wget nano tor
git clone https://github.com/bitcoin/bitcoin
cd bitcoin
sh
./autogen.sh
./contrib/install_db4.sh `pwd`
export BDB_PREFIX='/root/bitcoin/db4'
./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --without-gui --without-miniupnpc --disable-dependency-tracking
gmake
gmake install


...but I have no clue how to test it.
 

Bashern

Dabbler
Joined
Sep 1, 2015
Messages
26
Ah, I was trying to do everything in tcsh. sh made it all work, thanks!
 

Bashern

Dabbler
Joined
Sep 1, 2015
Messages
26
If anyone plans on running bitcoind for lightning lab's lnd implementation, bitcoind needs to be compiled using ZeroMQ, run configure as below. Also, I found out why the dependancy tracking wasn't working, its a FreeBSD thing, make=gmake:

./configure MAKE=gmake BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --without-gui --without-miniupnpc --with-zmq --enable-zmq
 
Status
Not open for further replies.
Top