Install packages needed for Bitcoinlib:
$ sudo apt install build-essential python3-dev libgmp3-dev libssl-dev python3-virtualenv
Create a virtual environment
$ python3 -m venv venv/blocksmurfer
$ source venv/blocksmurfer/bin/activate
Download Blocksmurfer and install requirements.
$ git clone https://github.com/1200wd/blocksmurfer.git
$ cd blocksmurfer
$ python3 -m pip install -r requirements.txt
Copy configuration file and update secret key
$ cp config.example.py config.py
$ nano config.py
Now you can test your install and run flask directly
$ flask run
$ # or if you want to accept connection from other hosts
$ flask run --host 0.0.0.0
or with gunicorn
$ ./boot.sh
Blocksmurfer should run now on http://localhost:5000
You can also create a basic local node with a docker image
$ docker container run --rm --name blocksmurfer -d -p 5000:5000 blocksmurfer/blocksmurfer
For more information about this image: https://hub.docker.com/r/blocksmurfer/blocksmurfer
Or build and run locally from Dockerfile configuration
$ docker build -t blocksmurfer:latest .
$ docker run --rm -p 0.0.0.0:5000:5000 -it blocksmurfer
- Please do not forget to enter a new secret key!
- Select the networks you would like to support and update other settings if you like in the configuration
Please note:
- Remove Blocksmurfer from Bitcoinlib's provider definitions in ./bitcoinlib/providers.json to avoid recursive loops.
- Preferably use your own Bcoin node, or request for an API key at one of the providers to avoid provider errors.
- In the Bitcoinlib config file (./bitcoinlib/config.ini) you can change the loglevel, log location, timeout for requests and other settings
- If you use your own Bcoin node or have an API key, you might want to increase the max_transaction setting in config.ini to 100 or more.
- If you get errors when trying to retrieve blocks or see negative numbers in confirmations, this probably means the blockchain is not fully synced yet. This can take several days for a Bcoin or Bitcoind node.
In production environments you should use another database such as PostgreSQL instead of SQLite for fast and reliable caching.
To install PostgreSQL:
$ apt install postgresql postgresql-contrib libpq-dev
$ pip install psycopg2
Check the Apache config file example in blocksmurfer/examples/apache-example.conf to configure Blocksmurfer with Apache.
- Install Apache and create log directories
$ sudo apt install apache2
$ sudo mkdir /var/log/apache2/blocksmurfer
- Add the proxy modules
$ sudo a2enmod ssl
$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
- Copy the apache config file to /etc/apache2/sites-available, update the settings and create the link in /etc/apache2/sites-available
- Now run blocksmurfer/boot.sh and your blockexplorer should be up and running
Make sure flask gunicorn and nginx are installed.
Copy the blocksmurfer/examples/nginx-example to the /etc/nginx/sites-available directory, update to your local settings and link to /etc/nginx/sites-enabled.
$ sudo nano /etc/nginx/sites-available/blocksmurfer
$ sudo ln -s /etc/nginx/sites-available/blocksmurfer /etc/nginx/sites-enabled
$ sudo nginx - t
$ sudo systemctl restart nginx
$ sudo ufw allow 'Nginx Full'
Run Blocksmurfer as service with Gunicorn, you can find an example of a systemd service file in /blocksmurfer/examples/blocksmurfer.service.
$ sudo nano /etc/systemd/system/blocksmurfer.service
$ sudo systemctl start blocksmurfer.service
$ sudo systemctl enable blocksmurfer.service