Go to file
Jonas Nick aad0fe6e45
Merge #187: Network Namespaces
681728294b tests: run scenarios as multiple Travis jobs (nixbitcoin)
43ce847e2b tests: allow running integration tests with different configurations (nixbitcoin)
8783f38fba tests: add netns to testing framework (nixbitcoin)
25adce29e5 secure-node: only mkHiddenServices if services are enabled (nixbitcoin)
c542b92e55 nginx: add netns (nixbitcoin)
ef89607704 recurring-donations: add netns (nixbitcoin)
582cb86d74 nanopos: add netns (nixbitcoin)
7369f0a7ec lightning-charge: add netns (nixbitcoin)
c4ab73d51f spark-wallet: add netns (nixbitcoin)
d6296acaba electrs: add netns (nixbitcoin)
c0b02ac93a liquid: add netns cli script (nixbitcoin)
672a416ede liquidd: add netns (nixbitcoin)
4b8ca52647 lnd: add netns cli script (nixbitcoin)
c55296433d lnd: add netns (nixbitcoin)
f3d2aaa5d4 lnd: prepare for netns and bring in line with clightning (nixbitcoin)
3c0c446547 clightning: add netns (nixbitcoin)
ae1230e13b clightning: remove bitcoin-rpcuser option (nixbitcoin)
65b5dab3d4 clightning: add announce-tor (nixbitcoin)
515aae2825 bitcoind: add netns and nonetns cli scripts (nixbitcoin)
75ca6f186c bitcoind: add netns (nixbitcoin)
e5e07b91f7 netns-isolation: netns architecture (nixbitcoin)
4a7199a3da netns-exec: add c program to execute commands in netns (Jonas Nick)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 681728294b

Tree-SHA512: 53083067dd94bfb38d06e9b7f0d2deaeb1b95067dc0c6e50d07073405ff5270de54fa56761e861d23eb0f0a9457f0e1e2c46ed71d732c0cfbaa09b6d425e0691
2020-07-21 12:05:50 +00:00
docs Document low-entropy problem 2020-04-19 15:16:00 +02:00
examples lnd: prepare for netns and bring in line with clightning 2020-07-21 09:38:32 +00:00
helper Update jonasnick's gpg key 2020-07-08 12:03:57 +00:00
modules secure-node: only mkHiddenServices if services are enabled 2020-07-21 09:38:55 +00:00
pkgs lnd: add netns 2020-07-21 09:38:35 +00:00
test tests: allow running integration tests with different configurations 2020-07-21 09:38:59 +00:00
.gitignore Change the nix-bitcoin deployment from forking this repo to importing the module 2020-03-24 21:43:17 +00:00
.travis.yml tests: run scenarios as multiple Travis jobs 2020-07-21 09:39:01 +00:00
default.nix simplify overlay.nix 2020-01-09 10:43:29 +01:00
LICENSE Add license 2019-01-02 14:03:52 +00:00
overlay.nix simplify overlay.nix 2020-01-09 10:43:29 +01:00
README.md Missing folder added to path in example 2020-07-09 14:51:16 +00:00
shell.nix Clean up development shell.nix 2020-03-30 10:49:15 +02:00

nix-bitcoin

Build Status

Nix packages and nixos modules for easily installing Bitcoin nodes and higher layer protocols with an emphasis on security. This is a work in progress - don't expect it to be bug-free, secure or stable.

The default configuration sets up a Bitcoin Core node and c-lightning. The user can enable spark-wallet in configuration.nix to make c-lightning accessible with a smartphone using spark-wallet. A simple webpage shows the lightning nodeid and links to nanopos letting the user receive donations. It also includes elements-daemon. Outbound peer-to-peer traffic is forced through Tor, and listening services are bound to onion addresses.

A demo installation is running at http://6tr4dg3f2oa7slotdjp4syvnzzcry2lqqlcvqkfxdavxo6jsuxwqpxad.onion. The following screen cast shows a fresh deployment of a nix-bitcoin node.

The goal is to make it easy to deploy a reasonably secure Bitcoin node with a usable wallet. It should allow managing bitcoin (the currency) effectively and providing public infrastructure. It should be a reproducible and extensible platform for applications building on Bitcoin.

Example

The easiest way to try out nix-bitcoin is to use one of the provided examples.

git clone https://github.com/fort-nix/nix-bitcoin
cd nix-bitcoin/examples/
nix-shell

The following example scripts set up a nix-bitcoin node according to examples/configuration.nix and then shut down immediately. They leave no traces (outside of /nix/store) on the host system.

Available modules

By default the configuration.nix provides:

  • bitcoind with outbound connections through Tor and inbound connections through a hidden service. By default loaded with banlist of spy nodes.
  • clightning with outbound connections through Tor, not listening
  • includes "nodeinfo" script which prints basic info about the node
  • adds non-root user "operator" which has access to bitcoin-cli and lightning-cli

In configuration.nix the user can enable:

  • a clightning hidden service
  • liquid
  • lightning charge
  • nanopos
  • an index page using nginx to display node information and link to nanopos
  • spark-wallet
  • electrs
  • recurring-donations, a module to repeatedly send lightning payments to recipients specified in the configuration.
  • bitcoin-core-hwi.
    • You no longer need extra software to connect your hardware wallet to Bitcoin Core. Use Bitcoin Core's own Hardware Wallet Interface with one configuration.nix setting.

The data directories of the services can be found in /var/lib on the deployed machines.

Installation

See install.md for a detailed tutorial.

Security

  • Simplicity: Only services you select in configuration.nix and their dependencies are installed, packages and dependencies are pinned, most packages are built from the nixos stable channel, with a few exceptions that are built from the nixpkgs unstable channel, builds happen in a sandboxed environment, code is continiously reviewed and refined.
  • Integrity: Nix package manager, NixOS and packages can be built from source to reduce reliance on binary caches, nix-bitcoin merge commits are signed, all commits are approved by multiple nix-bitcoin developers, upstream packages are cryptographically verified where possible, we use this software ourselves.
  • Principle of Least Privilege: Services operate with least privileges; they each have their own user and are restricted further with systemd options, there's a non-root user operator to interact with the various services.
  • Defense-in-depth: nix-bitcoin is built with a hardened kernel by default, services are confined through discretionary access control, Linux namespaces, and seccomp-bpf with continuous improvements.

Note that nix-bitcoin is still experimental. Also, by design if the machine you're deploying from is insecure, there is nothing nix-bitcoin can do to protect itself.

Hardware requirements

  • Disk space: 300 GB (235GB for Bitcoin blockchain + some room)
    • Bitcoin Core pruning is not supported at the moment because it's not supported by c-lightning. It's possible to use pruning but you need to know what you're doing.
  • RAM: 2GB of memory. ECC memory is better. Additionally, it's recommended to use DDR4 memory with targeted row refresh (TRR) enabled (https://rambleed.com/).

Tested hardware includes pcengine's apu2c4, GB-BACE-3150, GB-BACE-3160. Some hardware (including Intel NUCs) may not be compatible with the hardened kernel turned on by default (see https://github.com/fort-nix/nix-bitcoin/issues/39#issuecomment-517366093 for a workaround).

Usage

For usage instructions, such as how to connect to spark-wallet, electrs and the ssh Tor Hidden Service, see usage.md.

Troubleshooting

If you are having problems with nix-bitcoin check the FAQ or submit an issue. There's also a #nix-bitcoin IRC channel on freenode. We are always happy to help.

Docs