Jonas Nick 5c99656cce
Merge #226: Improve netns-isolation and tests
e5fb3f6a7fb0f32ec036d2eebfc239528b0345af run-tests: document how to pass extra build args (Erik Arvstedt)
df790f67661cf9e83c39701f7c8e72de0e829d8e run-tests: allow linking test build results for all scenarios (Erik Arvstedt)
91697b1427d4deb6d41dccd5561e3939e076814d test: allow for testing all scenarios (Erik Arvstedt)
28236691aa1d8323a5fb2b0fa62a79f9d88c5328 test: rename scenarios/lib.py -> base.py (Erik Arvstedt)
80da0a41bc21f3297e8223614217a76595bb9d58 test: load complete test environment in debug mode (Erik Arvstedt)
9b4cd7bd1ccb98a3cc9d0ad116dd61094c5166e1 test: simplify scenario handling (Erik Arvstedt)
0f56ea6ad1f04f281dcb2cd2c88215c7b599aa71 test: include scenario in test name (Erik Arvstedt)
9237e5dc3df54036da5ee055c3b40025bf4bb155 test: use pydoc docstring (Erik Arvstedt)
ed73627e0256c69cbaa1e1234b8a248edd7cea36 netns-exec: minor style fixes (Erik Arvstedt)
91ebc2d517bdee91f3909d8abe2c1288105de223 netns-exec: simplify installation (Erik Arvstedt)
809e75485169c4761ee438807df55eacd20731de netns: improve bridge setup (Erik Arvstedt)
b7450877a0445151fd9e9e983d436b1ca514d820 netns: rename bridge peer devices br-nb-veth* -> nb-veth-br* (Erik Arvstedt)
8bfb7bb2f878aa6ad50dd3bae3361c68af82e47f netns: rename bridge br0 -> nb-br (Erik Arvstedt)
32e70a7516a0d9602b6884c0281abc59a85d3228 netns: move webindex config for modules-only usage (Erik Arvstedt)
121301337bd81d1d8a5d7b500b58366347abd467 netns: add option 'allowedUser' for modules-only usage (Erik Arvstedt)
9715134f066fee42101f798ec347d9c3d72057ad netns: don't repeat cli definitions (Erik Arvstedt)
e385c732567a1cdf958f8b6690011e03765cd53b netns: separate implementation and service configs (Erik Arvstedt)
d0b8d77de2018207d8b2e598990ba65db499c08d netns: remove conditionals for service settings (Erik Arvstedt)
0f0f6ddbb97716de7af9a5bbd4519c0ec4e53b95 netns: add comment about undesirable algorithmic complexity (Erik Arvstedt)
a3ae8668e639159d5b63dd3fdc00d166c9c12e11 netns: use map instead of concatMap (Erik Arvstedt)
b7fc819be5cae75a1417c5afcf8376df07f8f03a netns: consistent var naming (Erik Arvstedt)
5a81693ef3e709a630d510c9fbf23c1bca89522d netns: add range check for netns ids (Erik Arvstedt)
74f1610668960dd1579f313707264d8c60b15e56 netns: clarify addressblock description (Erik Arvstedt)
4eb92df08c7ae58d27d74140742826d5fa3a28c7 netns: remove redundant filter (Erik Arvstedt)
50de54aef1e750a40f98ec5ada17e6cfe9d4047e netns: remove empty connections defs (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK e5fb3f6a7fb0f32ec036d2eebfc239528b0345af
  nixbitcoin:
    ACK e5fb3f6a7fb0f32ec036d2eebfc239528b0345af

Tree-SHA512: e2accf7b5ab5d4c4c07a8f9307409021809326648139424ff7ebaa7be3e628f21d5be8dafabe19b9659d09537a5b3976e2513bc287e79027376b5271006bc214
2020-08-25 13:29:33 +00:00
2020-08-21 21:43:46 +00:00
2020-08-04 15:25:37 +00:00
2020-07-08 12:03:57 +00:00
2020-08-25 14:53:12 +02:00
2020-08-25 14:53:12 +02:00
2020-07-28 15:55:54 +00:00
2020-01-09 10:43:29 +01:00
2019-01-02 14:03:52 +00:00
2020-01-09 10:43:29 +01:00
2020-08-04 13:32:06 +00:00
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 continuously 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

Languages
Nix 84.4%
Shell 11.7%
Python 3.5%
C 0.4%