Setting Up a Bitcoin+Lightning Network Test Environment
This article shows how to get a Bitcoin+LND node up in a jiff — inspired by Michael Goldstein’s post.
Blackbox
Setting up blockchain nodes require that you make a bunch of little decisions to get a node standing. These include decisions about where data is stored, how the daemons are parameterized, how to gauge service health, and how to keep nodes on versions that make sense.
The goal of the Blackbox project is to provide a framework to help developers spin up nodes quickly, in flexible configurations, so that they can focus on that app that is going to win them the Hackathon next week.
I hope that the brevity of the commands in this article convince you, dear searcher, to give Blackbox a try.
Install Blackbox
Prerequisites. Blackbox uses Docker and Docker Compose under the hood. If you are using macOS, these can be installed in Docker Desktop for Mac. Just get the latest version.
Blackbox works on macOS and Linux. To install on macOS with Homebrew, execute the following:
$ brew install crypdex/blackbox/blackboxd
Configure for Bitcoin+LND
Blackbox uses a YAML file to configure the stack — more specifically, it uses a small superset of Docker Compose version 3.7.
By convention, this file is ~/.blackbox/blackbox.yml
. To create a Bitcoin+LND stack, simply specify the following in a file at that location.
version: "3.7"
services:
lnd_bitcoin:
To see what that does you can say
$ blackboxd info
Chances are that running that command told you that you are missing some variables that need to be set. Let’s do that now.
Parameterize Bitcoin+LND
We parameterize the node by placing some variables in our shell’s environment. This can be done in you ~/.bash_profile
or in ~/.env
if you would prefer.
At a bare minimum you need DATA_DIR
to tell Blackbox where all the chain data is going to be stored. This can be anywhere, but I typically recommend you put this data in an external SSD.
DATA_DIR=/mnt/dataBITCOIN_RPCUSER=<alibaba>
BITCOIN_RPCPASS=<opensesame>
By default, this stack is on mainnet
. However, you can spin it up in either testnet
or regtest
by adding this to the .env
.
BITCOIN_NETWORK=regtest
Spin er up!
Now that everything is parameterized, lets boot
blackboxd start
Thats it. Now we can tail the logs to see what’s up
blackboxd logs
So you want CLIs?
Now that you node is up and syncing, you will likely want to communicate with them. To do this, install the binary wrappers. These give you access to the full command line running in the nodes’s container.
$ blackboxd bin install bitcoin-cli lncli-bitcoin
Now you can make calls as you normally would
$ bitcoin-cli getnetworkinfo
$ lncli-bitcoin wallet create
Wrapping Up
There is a whole lot more you can do with Blackbox. In fact, setting up a Litecoin+LND node is just as trival. I’ll show that in detail in the next article.