Skip to content

Commit

Permalink
minor overhaul, markdown linting
Browse files Browse the repository at this point in the history
A light overhaul of the RaspiBolt guide, mostly for consistency and
valid markdown syntax.
  • Loading branch information
Stadicus committed Dec 15, 2019
1 parent a056a97 commit 34b0207
Show file tree
Hide file tree
Showing 18 changed files with 691 additions and 561 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.sass-cache
_site
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ aux_links:
- "https://github.com/Stadicus/RaspiBolt/issues"
"Contribute! Source on GitHub":
- "https://github.com/Stadicus/RaspiBolt/"

# enable theme for local usage
#theme: "just-the-docs"
74 changes: 46 additions & 28 deletions index.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,96 @@
---
layout: default
title: Intro
nav_order:
nav_order: 1
---
## Beginner’s Guide to ️Lightning️ on a Raspberry Pi
{: .no_toc }

I love to tinker and build stuff.
I am also fascinated with digital currencies, so I recently built my own Bitcoin / Lightning Full Node with a simple low-cost Raspberry Pi.
I now basically run my own bank using free open-source software and some cheap hardware.

![RaspiBolt Logo](images/00_raspibolt_banner_440.png)

---

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

I love to tinker and build stuff. I am also fascinated with digital currencies, so I recently built my own Bitcoin / Lightning Full Node with a simple low-cost Raspberry Pi. I now basically run my own bank using free open-source software and some cheap hardware.
---

This project was as much about the learning process as about the result. And I think I succeeded: I learned a lot and my node runs very well. This guide is my attempt to share my learnings and encourage you to run a node yourself.

![RaspiBolt Logo](images/00_raspibolt_banner_440.png)
This project was as much about the learning process as about the result.
And I think I succeeded: I learned a lot and my node runs very well.
This guide is my attempt to share my learnings and encourage you to run a node yourself.

## Why am I excited about Bitcoin and Lightning?

**Bitcoin as new technology** is an incredibly interesting endeavor, especially because of its interdisciplinary nature. **Bitcoin as sound money** is going to have a major impact on economic principles and society as a whole. In my opinion, a solid, anti-fragile base layer for this future monetary network is the killer app for blockchains and will be more important than the most novel feature of competing altcoin projects.
**Bitcoin as new technology** is an incredibly interesting endeavor, especially because of its interdisciplinary nature.
**Bitcoin as sound money** is going to have a major impact on economic principles and society as a whole.
In my opinion, a solid, anti-fragile base layer for this future monetary network is the killer app for blockchains and will be more important than the most novel feature of competing altcoin projects.

At the moment, Bitcoin is more of a store of value and not really suited for small everyday transactions. Due to limitations of the blockchain and the growth of its usage, fees have risen and business models relying on cheap transactions are being priced out. This is fine. **Truly decentralized blockchains are a scarce resource** and cannot scale to accommodate all global transactions. The current scaling pains are a great motivator to build better technology to scale exponentially, as opposed to just making everything bigger for linear scaling.
At the moment, Bitcoin is more of a store of value and not really suited for small everyday transactions.
Due to limitations of the blockchain and the growth of its usage, fees have risen and business models relying on cheap transactions are being priced out.
This is fine.
**Truly decentralized blockchains are a scarce resource** and cannot scale to accommodate all global transactions.
The current scaling pains are a great motivator to build better technology to scale exponentially, as opposed to just making everything bigger for linear scaling.

This is where the **Lightning Network** comes in. As one of several new blockchain “extensions”, its promise is to accommodate nearly unlimited transactions, with instant payment confirmation, minimal fees and increased privacy. It sounds almost too good to be true, but in contrast to ubiquitous ICO with their own token, this technology is well researched, committed to the cypherpunk open-source ethos and leverages the solid underpinnings of Bitcoin.
This is where the **Lightning Network** comes in.
As one of several new blockchain “extensions”, its promise is to accommodate nearly unlimited transactions, with instant payment confirmation, minimal fees and increased privacy.
It sounds almost too good to be true, but in contrast to ubiquitous ICO with their own token, this technology is well researched, committed to the cypherpunk open-source ethos and leverages the solid underpinnings of Bitcoin.

Bitcoin's security model requires both full nodes and miners to be decentralized. While the full-node-using economy must be decentralized to stop fake bitcoins that do not abide to consensus from being accepted as payments, the miners must be decentralized to stop censorship of transactions and to make transactions irreversible.
Bitcoin's security model requires both full nodes and miners to be decentralized.
While the full-node-using economy must be decentralized to stop fake bitcoins that do not abide to consensus from being accepted as payments, the miners must be decentralized to stop censorship of transactions and to make transactions irreversible.

To preserve the decentralized nature of this monetary system, I think it is important that everybody can run their own trustless Bitcoin full node, preferably on cheap hardware like a Raspberry Pi. If Bitcoin is digital gold, then a full node wallet is your own personal goldsmith who checks for you that received payments are genuine.
To preserve the decentralized nature of this monetary system, I think it is important that everybody can run their own trustless Bitcoin full node, preferably on cheap hardware like a Raspberry Pi.
If Bitcoin is digital gold, then a full node wallet is your own personal goldsmith who checks for you that received payments are genuine.

This is why I set out to build my **RaspiBolt** and think that I have now - through numerous iterations - quite a good configuration that I would like to share as my modest contribution to the community. I am not a systems specialist, so please feel free to point out improvements.
This is why I set out to build my **RaspiBolt** and think that I have now - through numerous iterations - quite a good configuration that I would like to share as my modest contribution to the community.
I am not a systems specialist, so please feel free to point out improvements.

## About this guide

### Structure

1. Introduction (this page)
2. [Preparations](raspibolt_10_preparations.md): get all required parts and start downloading the mainnet Blockchain
3. [Raspberry Pi](raspibolt_20_pi.md): set up and configure the Pi as a secure Linux server
4. [Bitcoin](raspibolt_30_bitcoin.md): install and configure the Bitcoin Core software as a Full Node, on testnet
5. [Lightning](raspibolt_40_lnd.md): install and configure the Lightning Network Daemon (LND), on testnet
6. [Mainnet](raspibolt_50_mainnet.md): after you are comfortable with your setup, switch to Bitcoin mainnet
2. [Preparations](raspibolt_10_preparations.md): get all required parts
3. [Raspberry Pi](raspibolt_20_pi.md): set up and configure the Pi as a Linux server
4. [Bitcoin](raspibolt_30_bitcoin.md): install and configure Bitcoin Core as a fully validating node
5. [Lightning](raspibolt_40_lnd.md): install and configure the Lightning Network Daemon (LND)
7. [FAQ](raspibolt_faq.md): frequently asked questions and further reading
8. [Updates](raspibolt_updates.md): keep track of changes

### Purpose

My aim is to set up a Bitcoin and Lightning node that

* is as fully validating Bitcoin Full Node and does not require any trust in a 3rd party,
* is reliably running 24/7,
* is part of and supports the decentralization of the Lightning network by routing payments and
* can be used to send and receive personal payments using the command line interface.

This server is set up without graphical user interface and is used remotely using the Secure Shell (SSH) command line. In the future, this server should function as my personal backend for desktop and mobile wallets, but I haven’t found a good solution to this yet. So, command line it is for the moment.
This server is set up without graphical user interface and is used remotely using the Secure Shell (SSH) command line.

**The good old days**: this was the original goal of this guide, back in 2017, simply buying a Blockaccino.

[![](images/00_blockaccino_goal.png)](https://vimeo.com/258395303)

**Wishlist for further enhancements**

- [x] Bitcoin / Lightning desktop wallet support: Electrum / Zap Desktop
- [x] Bitcoin mobile wallet support: Zap iOS / Shango
- [x] Hardware wallet support: Electrum + HW wallet
- [ ] Full backup, incl. Lightning channel states
[![Buying a Blockaccino](images/00_blockaccino_goal.png)](https://vimeo.com/258395303)

### Target audience

This guide strives to give simple and foolproof instructions. But the goal is also to do everything ourselves, no shortcuts that involve trust in a 3rd party allowed. This makes this guide quite technical and lengthy, but I try to make it as straightforward as possible and explain everything for you to gain a basic understanding of the how and why.
This guide strives to give simple and foolproof instructions.
But the goal is also to do everything ourselves, no shortcuts that involve trust in a 3rd party allowed.
This makes this guide quite technical and lengthy, but I try to make it as straightforward as possible and explain everything for you to gain a basic understanding of the how and why.

If you like to learn about Linux, Bitcoin and Lightning, this guide is for you.

### A word of caution
All components of the Lightning network are still under development and we are dealing with real money here. So this guide follows a conservative approach: first setup and test everything on Bitcoin testnet, then - once you are comfortable to put real money on the line - switch to Bitcoin mainnet with a few simple changes.
## A word of caution
All components of the Lightning network are still under development and we are dealing with real money here.
Unfortunately, nobody uses the Lightning Testnet, so we will go straight for Mainnet.
But please be aware that you should start with small amounts that you are willing to lose.

---

Get started: [Preparations >>](raspibolt_10_preparations.md)
86 changes: 32 additions & 54 deletions raspibolt_10_preparations.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,64 @@
---
layout: default
title: Preparations
nav_order: 2
nav_order: 10
---
<!-- markdownlint-disable MD014 MD022 MD025 MD040 -->
# Preparations
{: .no_toc }

Let's get all the required parts and assemble the Raspberry Pi.

---

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

This guide builds on the easily available and very flexible Raspberry Pi. This amazing piece of hardware is a tiny computer-on-a-chip, costs about $35 and consumes very little energy.
---

This guide builds on the easily available and very flexible Raspberry Pi 4.
This amazing piece of hardware is a tiny computer-on-a-chip, costs about $35 and consumes very little energy.

## Hardware requirements

It is advisable to get the latest Raspberry Pi for good performance:
* Raspberry Pi 3 Model B or better

* Raspberry Pi 4, 2+ GB RAM
* Micro SD card: 8 GB or more, incl. adapter to your regular computer
* USB power adapter: 5V/1.2A (more ampere is fine) + Micro USB cable
* strong USB power adapter: 5V/3A + USB-C cable
* External hard disk: 500 GB or more
* Optional: Raspberry Pi case

![Raspberry Pi](images/10_raspberrypi_hardware.png)
*Raspberry Pi 3: a tiny computer for less than $40*

I used a Raspberry Pi 3 Model B and set it up with a 8 GB SD card. To run a Lightning node, the full Bitcoin blockchain must be stored locally, which is ~200 GB and growing. I bought a cheap hard disk enclosure and reused an old 500 GB hard disk that was lying around. A modern 2.5" hard disk that is powered by the USB connection to the Pi does work as well, as long as you use a decent power supply (2.5A+).

## Download the Bitcoin blockchain
The Bitcoin blockchain records all transactions and basically defines who owns how many bitcoin. This is the most crucial of all information and we should not rely on someone else to provide this data. To set up our Bitcoin Full Node on mainnet, we need to

* download the whole blockchain (~ 200 GB),
* verify every Bitcoin transaction that ever occurred and every block ever mined,
* create an index database for all transactions, so that we can query it later on,
* calculate all bitcoin address balances (called the UTXO set).

:point_right: See [Running a Full Node](https://bitcoin.org/en/full-node) for additional information.
![Raspberry Pi](images/10_raspberrypi_hardware.png)
*Raspberry Pi 4: a tiny computer for $50*

Although we will set up the RaspiBolt for the Bitcoin testnet first, the validation of the Bitcoin mainnet blockchain can take several days. This is the reason why we already start this task now.
To run a Lightning node, the full Bitcoin blockchain must be stored locally, which is ~250 GB and growing.
You can buy a cheap hard disk enclosure and reuse an old 500 GB hard disk.
I recommend getting a modern 2.5" SSD that can be powered through the USB connection to the Pi directly, which also speeds up initial sync time significantly.

### Using a regular computer
You can imagine that the Raspberry Pi is not quite up to this huge task. The download is not the problem, but to initially process the whole blockchain would take weeks or months due to its low computing power and lack of memory. We need to download and verify the blockchain with Bitcoin Core on a regular computer, and then transfer the data to the Pi. This needs to be done only once. After that the Pi can easily keep up with new blocks.
## Assembly

This guide assumes that you will use a Windows machine for this task, but it works with most operating systems. You need to have about 250 GB free disk space available, internally or on an external hard disk (but not the one reserved for the Pi). As indexing creates heavy read/write traffic, the faster your hard disk the better. An internal drive or an external USB3 hard disk will be significantly faster than one with a USB2 connection.
TODO

We will later format the external hard disk of the Pi with the Ext4 file system, which is suited best for our use case. Using SCP, we then copy the blockchain from the Windows computer over the local network.
## Write down your passwords

### Download and verify Bitcoin Core
Download the Bitcoin Core installer from [bitcoincore.org/en/download](https://bitcoincore.org/en/download) and store it in the directory you want to use to download the blockchain. To check the authenticity of the program, we calculate its checksum and compare it with the checksums provided.
You will need several passwords and I find it easiest to write them all down in the beginning, instead of bumping into them throughout the guide.
They should be unique and very secure, at least 12 characters in length. Do **not use uncommon special characters**, spaces or quotes (‘ or “).

In Windows, I’ll preface all commands you need to enter with `>` , so with the command `> cd bitcoin` , just enter `cd bitcoin` and hit enter.

Open the Windows command prompt (`Win+R`, enter `cmd`, hit `Enter`), navigate to the bitcoin directory (for me, it's on drive `D:`, check in Windows Explorer) and create the new directory `bitcoin_mainnet`. Then calculate the checksum of the already downloaded program.
```
> D:
> cd \bitcoin
> mkdir bitcoin_mainnet
> dir
> certutil -hashfile bitcoin-0.18.1-win64-setup.exe sha256
3bac0674c0786689167be2b9f35d2d6e91d5477dee11de753fe3b6e22b93d47c
```
![Windows Command Prompt: verify checksum](images/10_blockchain_wincheck.png)

Compare this value with the [release signatures](https://bitcoin.org/bin/bitcoin-core-0.18.1/SHA256SUMS.asc). For the Windows v0.18.1 setup binaries, its
```
64 bit: 3bac0674c0786689167be2b9f35d2d6e91d5477dee11de753fe3b6e22b93d47c
```console
[ A ] Master user password
[ B ] Bitcoin RPC password
[ C ] LND wallet password
[ D ] LND seed password (optional)
```
Usually, you would also need to check the signature of this file, but it's a pain on Windows, so we will do it on the Pi later on.

### Installing Bitcoin Core
Execute the Bitcoin Core installation file (you might need to right-click and choose "Run as administrator") and install it using the default settings. Start the program `bitcoin-qt.exe` in the directory "C:\Program Files\Bitcoin". Choose your new “bitcoin_mainnet” folder as the custom data directory.

![Bitcoin Core directory selection](images/10_bitcoinqt_directory.png)

Bitcoin Core opens and starts immediately syncing the blockchain. If your computer has a lot of memory, you can increase the database in-memory cache by adding the following line (with megabytes of memory to use, adjusted to your computer) as well:

```
dbcache=6000
```
Save and close the text file, quit Bitcoin Core using `File` / `Exit` and restart the program. The program will start syncing again.
![xkcd: Password Strength](images/20_xkcd_password_strength.png)

Let the blockchain sync for now, we can already start working on the Pi.
If you need inspiration for creating your passwords: the [xkcd: Password Strength](https://xkcd.com/936/) comic is funny and contains a lot of truth.
Store a copy of your passwords somewhere safe (preferably in a password manager like [KeePass](https://keepass.info/)) and keep your original notes out of sight once your system is up and running.

---
Next: [Raspberry Pi >>](raspibolt_20_pi.md)
Loading

0 comments on commit 34b0207

Please sign in to comment.