Skip to main content

Set up Bitcoin Core with Docker

At this point, you should have one open terminal window on your Ubuntu desktop, and it should be running Tor. You should be seeing logs like...

tor-socks-proxy  | Mar 27 15:14:07.000 [notice] Bootstrapped 90% (ap_handshake_done): Handshake finished with a relay to build circuits
tor-socks-proxy | Mar 27 15:14:07.000 [notice] Bootstrapped 95% (circuit_create): Establishing a Tor circuit
tor-socks-proxy | Mar 27 15:14:08.000 [notice] Bootstrapped 100% (done): Done

If you haven't set this up yet, go back to set up TOR with docker.

Make the Bitcoind configuration file

So as we've discussed, you'll be running the Bitcoin Core software alongside your Lightning node. We need a configuration file for that. So, let's create it.

From your root directory, run these commands:

cd docker-bitcoind/PRIVATE
touch bitcoin.conf

Next, copy the contents of this file: https://github.com/MegalithicBTC/LND-With-Docker/blob/master/docker-bitcoind/COPY-THIS-bitcoin.conf

...and paste them into PRIVATE/bitcoin.conf.

Please read the comments in this configuration file, it's really helpful if you understand them.

Change the rpcuser and rpcpassword

In the bitcoin.conf, you'll find these two values

rpcuser=change-me-generate-a-unique-username-for-bitcoin-rpc
rpcpassword=change-me-generate-a-unique-password-for-bitcoin-rpc

Change both the username and password. Choose a secure password.

Nice, let's start Bitcoin Core running. Go to the root LND-With-Docker directory, and run:

./start-bitcoin.sh

The container should build, and then you should start to see logs showing that the blockchain is starting to synchronize to your computer.

bitcoind  | 2024-03-27T19:53:19Z Synchronizing blockheaders, height: 103559 (~12.99%)
bitcoind | 2024-03-27T19:53:20Z Synchronizing blockheaders, height: 105559 (~13.24%)
bitcoind | 2024-03-27T19:53:20Z Synchronizing blockheaders, height: 107559 (~13.48%)
bitcoind | 2024-03-27T19:53:20Z Synchronizing blockheaders, height: 109559 (~13.72%)
bitcoind | 2024-03-27T19:53:20Z Synchronizing blockheaders, height: 111559 (~13.96%)
bitcoind | 2024-03-27T19:53:21Z Synchronizing blockheaders, height: 113559 (~14.21%)

What we've achieved.

You should now have two terminals open on your Ubuntu desktop.

One is TOR, and the other is Bitcoin Core.

Bitcoin Core now needs to download the entire Bitcoin blockchain. You will start to see log lines like this:

bitcoind  | 2024-03-27T19:58:07Z UpdateTip: new best=00000000a2ad1ed8d6c1ece08bf265f57968c51777b57d251efc29c71fb2d4d9 height=10425 version=0x00000001 log2_work=45.347920 tx=10518 date='2009-04-10T08:47:50Z' progress=0.000011 cache=2.3MiB(10499txo)

Do you see the progress=0.000011? The progress needs to get to 1.0 for you to be able to run LND. This first synchronization might take 24 to 48 hours, or even longer if you have reduced download speeds.

From now forward, you should never turn this computer off. If you do turn it off, that is OK, but keep in mind: To run LND, your Bitcoin Core node must be synchronized to progress=1.0. Therefore, if your computer is off for a few days, and then you turn it on, expect to wait a few minutes for synchronization.