bceaa361cab2a3008bba93abd918de4594b27b12 operator: allow reading systemd journal (Erik Arvstedt) 145961c2de1265425dbd3200e1fa4b6e9e75eb8c fix operator authorized keys setup (Erik Arvstedt) 37b2faf63cf2a7ae1ad95fff2b2db6e314c83c4c move systemPackages definitions to services (Erik Arvstedt) 6c22e13b7f431eddab26e50e05f67039ee8f6b7a copy-root-authorized-keys: use inline script definition (Erik Arvstedt) 63c6fe3213c7bed068ac49596b6fcd79cf410c11 fixup! use '' for multi-line string (Erik Arvstedt) ab617946a9d041d28d10a9f5416ba9c3ea7906f4 extract variable 'cfg' (Erik Arvstedt) 36c84d83601b3e9687b0a0727a00ab18f9b843a6 add option clightning.onionport (Erik Arvstedt) 681dbaf328eabb5590e8893048acd3391896c115 move electrs.onionport option (Erik Arvstedt) 74fbfa3a5da2c503d8e14267366500b65fb9e878 use lib.optionals (Erik Arvstedt) ec6d33fbb6e992413b00e0361ea87d25d1e4de06 rearrange code sections (Erik Arvstedt) e16ddc9c771b3757eb11c07be7bfa92d7a2a9e23 extract 'mkHiddenService' (Erik Arvstedt) 89d3d58850cae43279828cf9b717e24d1abaff84 use mkIf (Erik Arvstedt) 85e52a06cb610f0b755472137b6b1ad4da0a2f73 improve grouping of suboptions (Erik Arvstedt) 1a63f0ca6acaebdfc6448424e155aaf5d96d61fe remove option 'services.nix-bitcoin.enable' (Erik Arvstedt) 0f8b2e91fd02676e380d8a6298766c873fbb6618 add nix-bitcoin.nix for backwards compatibility (Erik Arvstedt) 28792f79dc1ff0a581dee8dd30f4d49950b2cef7 rename nix-bitcoin.nix -> presets/secure-node.nix (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: ACK bceaa361cab2a3008bba93abd918de4594b27b12 Tree-SHA512: d9c691d862c73f47399c97a50d9fa70ca934f82e8d9664bedacd5cc013fea040ec0431981aba78ade7f607d30809a5bab68effd627904e2cfa990e9d2612bf11
nix-bitcoin
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 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.
-
./deploy-container.sh
creates a NixOS container.
This is the fastest way to set up a node.
Requires: NixOS -
./deploy-qemu-vm.sh
creates a QEMU VM.
Requires: Nix -
./deploy-nixops.sh
creates a VirtualBox VM via NixOps.
NixOps can be used to deploy to various other backends like cloud providers.
Requires: Nix, VirtualBox
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.
- You no longer need extra software to connect your hardware wallet to Bitcoin Core. Use Bitcoin Core's own Hardware Wallet Interface with one
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.