Docker bitcoind-base and bitcoind-regtest

Fixed bitcoind-base to use binary from bitcoincore.org instead of ppa which is no longer maintained. Updated regtest to show configuration, address and private key
pull/236/head
Andreas M. Antonopoulos 4 years ago
parent 44b44ba499
commit 69c5d72aef

@ -1,36 +1,52 @@
FROM ubuntu:18.04
# Install development tools prerequisites
RUN apt-get update && apt-get install -y \
build-essential \
libtool \
autotools-dev \
automake \
pkg-config \
python3 \
wget \
git \
curl \
unzip
# Install additional Bitcoin Core (bitcoind) requirements
RUN apt-get install -y \
libssl-dev \
libevent-dev \
bsdmainutils \
libboost-system-dev \
libboost-filesystem-dev \
libboost-chrono-dev \
libboost-test-dev \
libboost-thread-dev \
libminiupnpc-dev \
libzmq3-dev
# Install software-properties-common to add apt repositories
RUN apt-get install -y \
software-properties-common
# Add Bitcoin Core PPA repository
RUN add-apt-repository ppa:bitcoin/bitcoin
RUN apt-get update && apt-get install -y \
bitcoind
ENV BITCOIND_VERSION 0.20.0
# # Install development tools prerequisites
# RUN apt-get update && apt-get install -y \
# build-essential \
# libtool \
# autotools-dev \
# automake \
# pkg-config \
# python3 \
# wget \
# git \
# curl \
# unzip
# # Install additional Bitcoin Core (bitcoind) requirements
# RUN apt-get install -y \
# libssl-dev \
# libevent-dev \
# bsdmainutils \
# libboost-system-dev \
# libboost-filesystem-dev \
# libboost-chrono-dev \
# libboost-test-dev \
# libboost-thread-dev \
# libminiupnpc-dev \
# libzmq3-dev
# # Install software-properties-common to add apt repositories
# RUN apt-get install -y \
# software-properties-common
#
# # Add Bitcoin Core PPA repository
# RUN add-apt-repository ppa:bitcoin/bitcoin
# RUN apt-get update && apt-get install -y \
# bitcoind
# Install binaries for Bitcoin Core
ADD https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VERSION}/bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz /usr/local
RUN cd /usr/local/ \
&& tar -zxf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz \
&& cd bitcoin-${BITCOIND_VERSION} \
&& install bin/* /usr/local/bin \
&& install include/* /usr/local/include \
&& install -v lib/* /usr/local/lib
# Confirm installation
RUN bitcoind -version

@ -1,8 +1,7 @@
FROM bitcoind_base:latest
FROM lnbook/bitcoind_base:latest
ADD bitcoind /bitcoind
WORKDIR /bitcoind
RUN ln -sf /dev/stdout /bitcoind/debug.log
EXPOSE 12001
@ -10,7 +9,16 @@ EXPOSE 12001
CMD bitcoind -datadir=/bitcoind -daemon \
&& sleep 2 \
&& address=$(bitcoin-cli -datadir=/bitcoind getnewaddress) \
&& privkey=$(bitcoin-cli -datadir=/bitcoind dumpprivkey $address)\
&& echo "================================================"\
&& echo "Mining to bitcoin address: " ${address} \
&& echo "Private key: " ${privkey} \
&& echo "Configuration:" \
&& cat /bitcoind/bitcoin.conf \
&& echo "================================================"\
&& echo "Mining 101 blocks to unlock some bitcoin" \
&& bitcoin-cli -datadir=/bitcoind generatetoaddress 101 $address \
&& echo "Mining 1 block every 10 seconds"\
&& while sleep 10 \
; do bitcoin-cli -datadir=/bitcoind generatetoaddress 1 $address \
; done

@ -182,8 +182,7 @@ Docker's volume parameter needs an _absolute_ path, so that will depend on your
In the following example, we will be connecting the book repository files that were extracted in +/home/ubuntu/lnbook+ to the container volume +lnbook+. Your configuration is likely different, so you need to replace +/home/ubuntu/lnbook+ with the absolute path to the folder where you extracted the book repository:
----
$ export LNBOOK_DIR=/home/ubuntu/lnbook
$ docker run --volume $LNBOOK_DIR:/lnbook -it lnbook/devenv
$ docker run --volume /home/ubuntu/lnbook:/lnbook -it lnbook/devenv
root@a7da66010491:/lnbook# ls
code images CONTRIBUTING.md README.md
[...]
@ -192,14 +191,17 @@ code images CONTRIBUTING.md README.m
You should now see all the book repository files inside your container, under the folder +/lnbook+. Now you can access the examples from the code directory with all the tools, applications and utilities that are in the container.
==== Installing a Bitcoin node
==== Bitcoin Core and Regtest
Most of the Lightning node implementations need access to a full Bitcoin node in order to work. This Bitcoin node can be installed on the same computer (will require an additional 250+ GB of disk) or run on a different computer that can authorize connections from the Lightning node over the Internet.
Most of the Lightning node implementations need access to a full Bitcoin node in order to work.
Installing a full Bitcoin node is outside the scope of this book and is a relatively complex endeavor in itself. If you want to try it, refer to _Mastering Bitcoin_ (https://github.com/bitcoinbook/bitcoinbook), "Chapter 3: Bitcoin Core: The Reference Implementation" which discusses the installation and operation of a Bitcoin node.
A Bitcoin node can also be operated in _regtest_ mode, where the nodes creates a local simulated Bitcoin blockchain for testing purposes. In the following examples, we will be using regtest mode to allow us to demonstrate lightning without having to synchronize a Bitcoin node, or risk any funds.
There are two docker containers for Bitcoin Core. The first is a base container (+bitcoind-base+) that downloads and installs the Bitcoin Core software. The second container is +bitcoind-regtest+ that runs Bitcoin Core in regtest mode and mines a new block every 10 seconds.
=== c-lightning
C-lightning is a lightweight, highly customizable, and standard-compliant implementation of the Lightning Network protocol, developed by Blockstream as part of the Elements project. The project is open source and developed collaboratively on Github:

Loading…
Cancel
Save