Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bitcoinix

Introduction

bitcoinix is a collection of Nix packages and NixOS modules for deploying full-featured Bitcoin and Lightning nodes with an emphasis on security.

Use it for personal or merchant wallets, public infrastructure or Bitcoin application backends, on dedicated hardware, in a virtual machine or in a container. You don’t need previous experience with Nix. bitcoinix is used in production.

bitcoinix is a community fork of nix-bitcoin, which was archived in August 2026. The NixOS options keep the nix-bitcoin.* prefix, so existing configurations keep working. See Migrate from nix-bitcoin to switch a nix-bitcoin node to bitcoinix.

Features

  • Bitcoin Core, with Core Lightning or LND
  • Electrum servers (electrs, Fulcrum), the mempool explorer, BTCPay Server and the RTL web interface
  • Unbeholden Wallet, a watch-only browser wallet for air-gapped signers
  • Mobile wallet connections, e.g. ZEUS via Tor or WireGuard
  • Helpers: nodeinfo, backups, and a non-root operator user for the client tools

The README lists all services and plugins, the module options list their options.

Software versions

This release packages or pins the following software. Each version links to the project’s release notes, tag or source directory:

PackageVersionChannel
bitcoind32.1unstable
btcpayserver2.4.7unstable
cashu-cdk0.18.3unstable
cashu-orchard1.12.1local
charge-lnd0.3.2unstable
clboss0.17.3unstable
clightning26.06.10unstable
clightning-plugins/clnrest0.2.0local
clightning-plugins/currencyrate0.1.0local
clightning-plugins/feeadjuster0.1.0-f0d33fdlocal
clightning-plugins/monitor0.1.0-f0d33fdlocal
clightning-plugins/rebalance0.1.0-f0d33fdlocal
clightning-plugins/zmq0.1.0-f0d33fdlocal
electrs0.12.1unstable
extra-container1.0.1unstable
fulcrum2.1.4unstable
hwi3.2.0local
krops1.31.1local
lnd0.21.8-betaunstable
lndconnect0.2.1unstable
lndinit0.1.38-betaunstable
mempool-backend3.3.2local
mempool-frontend3.3.2local
mempool-rust-gbt3.3.2local
nbxplorer2.6.23unstable
rtl0.15.17unstable
trustedcoin0.8.7unstable
unbeholden-lnurl0.4.0local
unbeholden-wallet0.4.0local

All nixpkgs packages come from the single nixpkgs input, which tracks nixos-unstable. Channel local packages are built by bitcoinix from pinned sources, except hwi, which wraps nixpkgs’ package. krops is the tool of the legacy krops deployment. The flake NixOS module uses the locked unstable package set by default, including for local builds. Non-flake module imports and nix-bitcoin.useVersionLockedPkgs = false use your system’s unstable nixpkgs instead. Overriding bitcoinix’s nixpkgs input also replaces its tested pin. In these setups, service versions depend on your chosen revision; review the package migration guidance before updating it.

Security

  • Only the services you enable and their dependencies are installed.
  • Each service runs as its own user and is confined with systemd sandboxing. Network namespace isolation (nix-bitcoin.netns-isolation) can further restrict which services can reach each other.
  • The secure-node.nix preset sends outgoing connections through Tor, adds onion services for incoming connections, enables the firewall, turns off SSH password login and replaces sudo with doas.
  • Release tags are signed by the maintainers. fetch-release and update-nix-bitcoin in the deployment shell verify the signature before they use a release.

Where to start

  1. Hardware requirements: choose a machine for your node.
  2. Installation: set up a new node from scratch. To add bitcoinix to an existing NixOS configuration, start from the examples.
  3. Configuration and maintenance: customize services and allow external connections.
  4. Using services: connect wallets and manage the services.
  5. Upgrading: read this before you update bitcoinix.
  6. Release notes: review notable changes by release.
  7. FAQ

Some pages still come from nix-bitcoin and are being reviewed. If something is wrong or doesn’t work, please open an issue.

Hardware requirements

Platforms

bitcoinix supports two platforms:

  • x86_64-linux: 64-bit Intel and AMD CPUs
  • aarch64-linux: 64-bit ARM CPUs

Other platforms are not supported.

Memory

  • RAM: 2 GB. ECC memory is better. Additionally, it’s recommended to use DDR4 memory with targeted row refresh (TRR) enabled (https://rambleed.com/).

Disk space

Use a disk of at least 2 TB, preferably an SSD. An Electrum server (electrs or Fulcrum) needs an unpruned Bitcoin Core node and adds its own index on top of it.

Pruning

services.bitcoind.prune limits the block files to a target size in MiB and lowers the disk usage. The smallest target that Bitcoin Core accepts is 550.

Not every service works on a pruned node:

  • electrs and Fulcrum don’t support pruning, and evaluation fails.
  • mempool enables services.bitcoind.txindex, and Bitcoin Core doesn’t start with both pruning and the transaction index.
  • Core Lightning works. Its bcli plugin fetches pruned blocks from peers.

Tutorial: Install and configure NixOS for bitcoinix on a dedicated machine

This tutorial describes how to manage your Bitcoin node comfortably from your personal computer: you keep the node configuration in a Nix flake and deploy it over SSH with nixos-rebuild or Colmena. The deployment tool krops is described as a legacy alternative. However, bitcoinix is agnostic to the deployment method and can be used with different or without such tools (see examples).

0. Preparation

  1. Find a machine to deploy bitcoinix on (see hardware.md).

  2. Optional: Make sure you have the latest firmware for your system (BIOS, microcode updates).

  3. Optional: Disable Simultaneous Multi-Threading (SMT) in the BIOS

    Researchers recommend disabling (SMT), also known as Hyper-Threading Technology in the Intel® world to significantly reduce the impact of speculative execution-based attacks (https://mdsattacks.com/).

1. NixOS installation

  1. Install NixOS on the node as described in the NixOS manual. Use the minimal ISO image for the platform of your node (x86_64-linux or aarch64-linux) from https://nixos.org/download/. To encrypt the disk, see LUKS-Encrypted File Systems.

  2. Before you run nixos-install, enable SSH and add the SSH public key of the computer you deploy from to /mnt/etc/nixos/configuration.nix:

    services.openssh.enable = true;
    users.users.root.openssh.authorizedKeys.keys = [
      "ssh-ed25519 AAAA... you@your-computer" # FIXME
    ];
    

    The deployment logs in as root with this key. With the default services.openssh.settings.PermitRootLogin = "prohibit-password", root can’t log in over SSH with a password.

  3. Finish the installation as described in the manual, and reboot.

2. Nix installation

Run these steps on the computer you deploy from, not on the node.

  1. Install git, and install Nix in multi-user mode as described at https://nixos.org/download/. On NixOS, Nix is already installed.

  2. Enable flakes, which the deployment below uses

    mkdir -p ~/.config/nix
    echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
    

    On NixOS, set nix.settings.experimental-features = [ "nix-command" "flakes" ]; instead.

  3. Optional: Disallow substitutes

    You can put substitute = false to your nix.conf usually found in /etc/nix/ to build the packages from source. This eliminates an attack vector where Nix’s build server or binary cache is compromised.

3. Get and verify bitcoinix

  1. Clone this project

    git clone https://github.com/bitcoinix/bitcoinix
    cd bitcoinix
    
  2. Verify the release signing keys

    A bitcoinix release is a signed git tag. The list of keys that may sign releases lives in the repository you just cloned, so it cannot vouch for itself. Print the fingerprints of the listed keys:

    grep -v '^#' helper/release-keys/ssh-allowed-signers | cut -d' ' -f3- | ssh-keygen -lf -
    

    The release tag key, SHA256:2o/0Op+64zKgF4oMaS0LGOiGPNDsibaqX6g8qMf5Hz0, is also published outside this repository at https://seberm.com/ssh.html. Verify that statement as described on that page and check that the same fingerprint is listed above. Do not continue if it is not.

  3. Verify and check out the latest release

    git config gpg.ssh.allowedSignersFile helper/release-keys/ssh-allowed-signers
    git config gpg.ssh.revocationFile helper/release-keys/ssh-revoked-keys
    git tag -l 'v*' --sort=-v:refname | head -1    # the latest release, e.g. v0.1.0
    git tag -v v<version>
    git checkout v<version>
    cd ..
    

    git tag -v must report Good "git" signature with the release tag key fingerprint from the previous step. Checking out the tag makes sure that the files used below, including fetch-release.sh and its key files, are the ones that were signed.

4. Deploy with a flake

Your node configuration is a Nix flake that has bitcoinix as an input. You deploy it from your computer over SSH with nixos-rebuild or Colmena. CI builds both examples on code-changing pull requests and pushes to master; documentation-only PRs skip these builds.

  1. Copy an example to a new directory next to the bitcoinix clone

    For nixos-rebuild, use examples/flakes. For Colmena, use examples/colmena, a larger node. Both use the secure-node preset.

    cp -r bitcoinix/examples/flakes node-config    # or bitcoinix/examples/colmena
    cd node-config
    git init
    

    Flakes only see files that git tracks, so git add every file you create.

  2. Pin the release that you verified in step 3

    In flake.nix, set the bitcoinix input to the release tag:

    bitcoinix.url = "github:bitcoinix/bitcoinix/v<version>";
    

    Then lock the inputs and check that the locked commit is the one you verified:

    nix flake lock
    nix flake metadata --json | nix run nixpkgs#jq -- -r .locks.nodes.bitcoinix.locked.rev
    git -C ../bitcoinix rev-parse 'v<version>^{commit}'
    

    Both commands must print the same commit. Commit flake.lock, and repeat this step for every update.

  3. Adapt the configuration

    Copy hardware-configuration.nix from your node and import it in place of the example’s placeholders (in the Colmena example, replace configs/fullnode/hardware-configuration.nix):

    scp root@<node>:/etc/nixos/hardware-configuration.nix .
    

    Edit all lines marked FIXME. Above all, add your SSH public key to users.users.root.openssh.authorizedKeys.keys: the deployment logs in as root, and without the key you lose remote access to the node.

  4. Deploy

    With nixos-rebuild:

    nix run nixpkgs#nixos-rebuild -- switch --flake .#fullnode --target-host root@<node>
    

    This builds the system on your computer and copies it to the node. To build on the node instead, for example when you deploy from macOS, add --build-host root@<node>.

    With Colmena, set deployment.targetHost in flake.nix, then:

    nix develop
    colmena apply --on fullnode
    

    switch (the Colmena default) activates the new system on the running node, which can cause problems. For updates, above all of bitcoinix, prefer boot and a reboot: replace switch with boot in the nixos-rebuild command, or run colmena apply --on fullnode boot, then ssh root@<node> reboot.

  5. With the secure-node preset, you can now log in as the unprivileged operator user

    ssh operator@<node>
    

    bitcoinix authorizes the SSH keys of root for operator. Use operator for normal system management, and log in as root as rarely as possible.

5. Alternative: deploy with krops (legacy)

Note

krops is the deployment tool of nix-bitcoin, the predecessor project. Support for it may be removed in a future release. Prefer a flake-based deployment.

Set up the deployment directory

These steps continue from step 3 above.

  1. Create a new directory for your bitcoinix node config and copy initial files from bitcoinix

    mkdir nix-bitcoin-node
    cd nix-bitcoin-node
    cp -r ../bitcoinix/examples/{configuration.nix,shell.nix,krops,.gitignore} .
    
  2. Obtain the hash of the latest bitcoinix release

    ../bitcoinix/helper/fetch-release.sh > nix-bitcoin-release.nix
    

    fetch-release picks the highest signed release tag, verifies it against helper/release-keys/ssh-allowed-signers and helper/release-keys/ssh-revoked-keys, and refuses to emit a hash for an unsigned tag, or for a tag signed by an unknown or revoked key. Pass releaseVersion=<version> to pin a specific release. Set checkDownload=1 to additionally download the release archive into a throwaway Nix store and check that it is exactly the signed tree.

Optional: Specify the system of your node

This enables evaluating your node config on a machine that has a different system platform than your node.
Examples: Deploying from macOS or deploying from an x86 desktop PC to an ARM node.

# Run this when your node has a 64-bit x86 CPU (e.g., an Intel or AMD CPU)
echo "x86_64-linux" > krops/system

# Run this when your node has a 64-bit ARM CPU
echo "aarch64-linux" > krops/system

Deploy with krops

  1. Edit your SSH config

    nano ~/.ssh/config
    

    and add the node with an entry similar to the following (make sure to fix Hostname and IdentityFile):

    Host bitcoin-node
        # FIXME
        Hostname NODE_IP_ADDRESS_OR_HOST_NAME_HERE
        User root
        PubkeyAuthentication yes
        # FIXME
        IdentityFile ~/.ssh/id_...
        AddKeysToAgent yes
    
  2. Make sure you are in the deployment directory and edit krops/deploy.nix

    nano krops/deploy.nix
    

    Locate the FIXME and set the target to the name of the SSH config entry created earlier, i.e. bitcoin-node.

    Note that any file imported by your configuration.nix must be copied to the target machine by krops. For example, if there is an import of networking.nix you must add it to extraSources in krops/deploy.nix like this:

    extraSources = {
        "hardware-configuration.nix".file = toString ../hardware-configuration.nix;
        "networking.nix".file = toString ../networking.nix;
    };
    
  3. Optional: Disallow substitutes

    If you prefer to build the system from source instead of copying binaries from the Nix cache, add the following line to configuration.nix:

    nix.settings.substitute = false;
    

    If the build process fails for some reason when deploying with krops-deploy (see later step), it may be difficult to find the cause due to the missing output. To see the build output, SSH into the target machine and run

    nixos-rebuild -I /var/src switch
    
  4. Copy hardware-configuration.nix from your node to the deployment directory.

    scp root@bitcoin-node:/etc/nixos/hardware-configuration.nix .
    
  5. Adjust configuration by opening the configuration.nix file and enable/disable the modules you want by editing this file.

    nano configuration.nix
    

    Pay attention to lines that are preceded by FIXME comments. In particular:

    1. Make sure to set your SSH pubkey. Otherwise, you lose remote access: root can only log in over SSH with a key.
    2. Uncomment the line ./hardware-configuration.nix by removing #.
  6. Enter the deployment environment

    nix-shell
    
  7. Deploy with krops in nix-shell

    deploy
    

    This will now create a bitcoinix node on the target machine.

  8. You can now access bitcoin-node via SSH

    ssh operator@bitcoin-node
    

    Note that you’re able to log in as the unprivileged operator user because bitcoinix automatically authorizes the SSH key added to root.

For security reasons, all normal system management tasks can and should be performed with the operator user. Logging in as root should be done as rarely as possible.

See also:

Migrate from nix-bitcoin

bitcoinix continues nix-bitcoin, which was archived in August 2026 after its last release, v0.0.139. A nix-bitcoin node switches to bitcoinix in place: the NixOS options keep the nix-bitcoin.* prefix and the services keep their data and secrets. What changes is where you get releases, the NixOS base, and the services that bitcoinix no longer supports.

Before you start

  • Your system moves to NixOS unstable. nix-bitcoin offered a stable NixOS base; bitcoinix uses only nixos-unstable. When your system follows bitcoinix’s nixpkgs, as the deployment examples do, the switch updates the whole OS, not only the Bitcoin services. Read the 0.2.0 upgrade notes first.
  • Some services were removed. The options of joinmarket, liquidd, lightning-loop, lightning-pool, spark-wallet and clightning-rest, among others, now fail evaluation with the reason and what to do instead. The data of removed services stays on the node. The full list is in modules/obsolete-options.nix.
  • Releases are signed differently. bitcoinix releases are git tags signed with SSH keys, which you verify yourself. Don’t follow a branch, as with nix-bitcoin’s release branch: pin a verified tag.
  • Back up your node, above all the secrets dir set by nix-bitcoin.secretsDir and your Lightning backups. The secrets dir defaults to /var/src/secrets with krops and to /etc/nix-bitcoin-secrets otherwise. With krops, also back up the secrets/ directory in your deployment directory, from which krops copies the secrets to the node.

1. Get and verify bitcoinix

In the directory that contains your deployment directory, follow step 3 of the installation: clone bitcoinix, verify the release signing key and check out the latest release tag. The steps below and step 4.2 of the installation expect the clone at ../bitcoinix, next to your deployment directory.

2. Switch your deployment to bitcoinix

Flake

In your node’s flake.nix, replace the nix-bitcoin input and the inputs that follow it:

inputs = {
  bitcoinix.url = "github:bitcoinix/bitcoinix/v<version>";
  nixpkgs.follows = "bitcoinix/nixpkgs";
};

Remove nixpkgs-unstable.follows = "nix-bitcoin/nixpkgs-unstable": bitcoinix has no separate unstable input. In outputs, rename the nix-bitcoin argument and its uses, e.g. bitcoinix.nixosModules.default and (bitcoinix + "/modules/presets/secure-node.nix"). The module and the presets keep these paths, but some package outputs moved: for example, packages.<system>.rtl is now legacyPackages.<system>.pinned.rtl. If your flake refers to packages of the nix-bitcoin flake, look up their new names in the release notes. Compare your flake with examples/flakes/flake.nix.

If your node is a container based on nix-bitcoin’s container example, start from bitcoinix’s examples/container/flake.nix instead and take over your container configuration. The rename above drops the extra-container input, and bitcoinix has no test/lib/extra-container-workaround.nix.

Then lock the inputs and check the locked commit, as in step 4.2 of the installation.

krops

If the deployment shell is open, exit it: it keeps using nix-bitcoin until you start it again. In your deployment directory, replace nix-bitcoin-release.nix with the release that you verified in step 1, e.g. 0.2.0:

releaseVersion=<version> ../bitcoinix/helper/fetch-release.sh > nix-bitcoin-release.nix.new &&
  mv nix-bitcoin-release.nix.new nix-bitcoin-release.nix

This replaces the pin only when the release was fetched and verified. Then start the deployment shell again with nix-shell; its update-nix-bitcoin now updates from bitcoinix releases. Compare your krops/ directory with bitcoinix’s examples/krops and take over its changes. krops is a legacy deployment method in bitcoinix; consider moving to a flake.

3. Migrate your configuration

  1. Keep nix-bitcoin.configVersion at the nix-bitcoin version that your configuration is written for, e.g. "0.0.85", and evaluate your configuration (for example, build it without deploying). Evaluation fails and lists each change since that version that affects your configuration.
  2. Complete these changes, following the upgrade notes of each version from 0.1.0 on, oldest first. Several need action on the node, such as deleting the electrs index before deploying (0.1.3). The error stays after you complete them: the notices check your configuration, e.g. whether a service is enabled, not the node.
  3. Set nix-bitcoin.configVersion to the version named in the error, the bitcoinix release you are deploying.
  4. Evaluate again. Deploy only when evaluation succeeds.

If configVersion is unset, evaluation doesn’t report these changes. Set it to your nix-bitcoin version before you switch, so that you don’t miss a required migration.

4. Deploy

Deploy as described for flakes or krops. Because the OS itself changes, activate the new system at boot and reboot instead of using switch:

  • With a flake, use boot as described in step 4.4 of the installation.
  • With krops, deploy always switches. Add operation = "boot"; to the writeDeploy arguments in krops/deploy.nix, deploy, then reboot the node with ssh bitcoin-node reboot.

Afterwards, check the services, e.g. with nodeinfo and systemctl --failed.

If something doesn’t work, please open an issue.

Managing your deployment

With a flake-based deployment, you deploy with nixos-rebuild or colmena as described in the installation guide.

Bitcoin network

Warning

Use a separate deployment for each Bitcoin network. If you change services.bitcoind.network on an existing node, Bitcoin Core, Core Lightning and electrs switch to the selected network’s data directories. Fulcrum, Mempool, BTCPay Server and NBXplorer still open their existing databases. For example, switching a mainnet BTCPay node to signet leaves its mainnet stores and extended public keys (xpubs) in the database used on signet.

The deployment defaults to mainnet. To run a node on signet, set

services.bitcoind.network = "signet";
NetworkUseBitcoin P2P portBitcoin RPC port
"mainnet"Production83338332
"signet"Public signet3833338332
"testnet4"Public proof-of-work test network4833348332
"regtest"Local regression tests1844418443

Core Lightning, electrs, Fulcrum, Unbeholden Wallet, Mempool and BTCPay Server can use either public test network. Mempool serves the selected network at /. With the packaged software, these combinations fail at evaluation time.

  • LND on signet or testnet4. Its wallet initializer, lndinit, cannot create wallets for these networks. This also applies when another service enables LND, such as charge-lnd or BTCPay Server with the LND backend.
  • CLBOSS or Trustedcoin on testnet4. Both Core Lightning plugins support signet.

BTCPay Server defaults to a testnet3 block explorer on testnet4. Sign in as a server administrator, open Server Settings → Policies → Block Explorers, set BTC-CHAIN to https://mempool.space/testnet4/tx/{0}, and save the policy.

Deployment shell

This section applies to the legacy krops deployment. Run command nix-shell in your deployment directory.
You now have access to deployment commands:

  • deploy
    Run krops-deploy and eval-config in parallel. If evaluation fails, the deployment is stopped.
  • krops-deploy
    Run generate-secrets and deploy your node with krops.
  • eval-config
    Locally evaluate the configuration. This is useful to check for configuration errors.
  • build-config
    Build your node system on your local machine.
  • generate-secrets
    Create the secrets required by your configuration in ./secrets/.
  • update-nix-bitcoin
    Fetch and verify the latest signed bitcoinix release and pin it in nix-bitcoin-release.nix. See Upgrading.
  • fetch-release
    Fetch and verify the latest signed bitcoinix release and print its pin without writing it. update-nix-bitcoin uses it.
  • h, help
    Show help

Updating bitcoinix

See Upgrading for how to update bitcoinix and for the changes that need manual action in each release.

Customizing your configuration

Get started with Nix

See Nix - A One Pager for a short guide to Nix, the language used in configuration.nix.
You can follow along with this guide by running command nix repl which allows you to interactively evaluate Nix expressions.

For a general introduction to the Nix and NixOS ecosystem, see nix.dev.

Set options

All features and services are configurable through options. You can find a list of supported options at the top of each bitcoinix module (Examples: bitcoind.nix, btcpayserver.nix).

Example: Set some bitcoind options by adding these lines to your configuration.nix:

# Use a custom data dir
services.bitcoind.dataDir = "/my/datadir";

# Enable txindex
services.bitcoind.txindex = true;

You can also use regular NixOS options for configuring your system:

networking.hostName = "myhost";
time.timeZone = "UTC";

Snippets that use config or lib, like config.services.bitcoind.port, must be in a module that takes these as arguments. The krops configuration.nix already does. The Colmena example’s configuration.nix takes only config; add lib there if you need it. In the module of the flake.nix example, which is a plain attribute set, use this form instead:

({ config, lib, ... }: {
  networking.firewall.allowedTCPPorts = [ config.services.bitcoind.port ];
})

Raw service configuration (extraConfig)

Prefer dedicated NixOS options when available. Settings you supply through extraConfig are unsupported by bitcoinix. You take full responsibility for checking their correctness, security and compatibility with the generated configuration, including after upgrades. This also covers files loaded through raw settings such as Bitcoin Core’s includeconf.

Raw settings may override managed settings or bypass security checks. For example, putting rest=1 in services.bitcoind.extraConfig does not enable the checks controlled by services.bitcoind.rest.enable. Successful evaluation does not validate the resulting service configuration.

Non-empty extraConfig on an enabled service produces a NixOS evaluation warning. Presets and plugins may populate it too; the responsibility notice applies to settings you add yourself. The warning does not print the configuration contents.

Debug your configuration

To print the values of options of your config, evaluate them on your computer. With the flake.nix example, replace fullnode with the name of your node:

nix eval .#nixosConfigurations.fullnode.config.services.bitcoind.dataDir
nix eval --json .#nixosConfigurations.fullnode.config.networking.firewall.allowedTCPPorts

With Colmena, run from the nix develop shell:

colmena eval -E '{ nodes, ... }: nodes.fullnode.config.services.bitcoind.dataDir'

With krops, add the following to your configuration.nix:

system.extraDependencies = let
  debugVal = config.networking.firewall.allowedTCPPorts;
  # More example options:
  # debugVal = config.environment.systemPackages;
  # debugVal = config.services.bitcoind.dataDir;
in lib.traceSeqN 3 debugVal [];

and run command eval-config from the deployment shell.

Allowing external connections to services

Allow peer connections to bitcoind

services.bitcoind = {
  # Accept incoming peer connections
  listen = true;

  # Listen to connections on all interfaces
  address = "0.0.0.0";

  # Set this to also add IPv6 connectivity. This raw setting causes an evaluation
  # warning, see "Raw service configuration" above.
  extraConfig = ''
    bind=::
  '';

  # With the secure-node preset or `enable-tor.nix`, set this to allow non-Tor connections
  # to bitcoind
  tor.enforce = false;
  # Also set this if bitcoind should not use Tor for outgoing peer connections
  tor.proxy = false;
};

# Open the P2P port in the firewall
networking.firewall.allowedTCPPorts = [ config.services.bitcoind.port ];

Allow bitcoind RPC connections from LAN

Binding 0.0.0.0 with a wide rpc.allowip and an unscoped firewall rule exposes RPC to every network the host is on. The public RPC whitelist limits which methods a caller may use, not who can connect. Scope rpc.allowip and the firewall rule to your LAN.

If the REST interface is enabled (services.bitcoind.rest.enable), it is served on the RPC port without authentication. bitcoinix refuses to evaluate such a config when rpc.allowip contains non-local sources, unless you set services.bitcoind.rest.allowNonLocal = true. The recognized loopback entries are 127.0.0.1, 127.0.0.1/32, 127.0.0.0/8, ::1 and ::1/128. Use these spellings in rpc.allowip for local sources.

With REST enabled, raw rpcallowip and includeconf directives in services.bitcoind.extraConfig are refused too, because their effective allowlist can’t be checked. Use rpc.allowip for checked sources, or review all raw and included settings and set services.bitcoind.rest.allowUncheckedConfig = true. This keeps the rpc.allowip check, unlike allowNonLocal.

services.bitcoind = {
  # Listen to RPC connections on all interfaces
  rpc.address = "0.0.0.0";

  # Allow RPC connections from external addresses
  rpc.allowip = [
    "10.10.0.0/24" # Allow a subnet
    "10.50.0.3" # Allow a specific address
  ];

  # Set this with the secure-node preset or `enable-tor.nix`
  tor.enforce = false;
};

# Open the RPC port in the firewall on the LAN interface only.
# Replace `eth0` with the name of your LAN interface.
networking.firewall.interfaces.eth0.allowedTCPPorts = [ config.services.bitcoind.rpc.port ];

To give a LAN client its own RPC user, add it to services.bitcoind.rpc.users:

services.bitcoind.rpc.users.alice = {
  # The part after `rpcauth=alice:` in the output of
  # Bitcoin Core's `share/rpcauth/rpcauth.py alice`
  passwordHMAC = "<salt>$<hmac>";
  # The RPC methods that alice may call. Without this, alice may call all methods.
  rpcwhitelist = [ "getblockchaininfo" "getblock" ];
};

passwordHMAC is written to the world-readable Nix store, like rpcauth lines in services.bitcoind.extraConfig. Any local user can read it and test password guesses offline. So use a long random password, like the one that rpcauth.py generates when you don’t pass a password. If an RPC user has a weak password, change it. The old HMAC stays readable in the Nix store until it is garbage-collected.

Allow connections to electrs

services.electrs = {
  # Listen to connections on all interfaces
  address = "0.0.0.0";

  # Set this with the secure-node preset or `enable-tor.nix`
  tor.enforce = false;
};

# Open the electrs port in the firewall
networking.firewall.allowedTCPPorts = [ config.services.electrs.port ];

You can use the same approach to allow connections to other services.

Network namespace isolation

nix-bitcoin.netns-isolation is experimental and disabled by default; the secure-node preset doesn’t enable it. It runs each service listed in netns-isolation.nix in its own network namespace. This separates the services from each other and from the outside network. It doesn’t separate them from processes in the host network namespace, and services without tor.enforce can reach your LAN. With it enabled:

  • The snippets above don’t work. The module sets the listen addresses of these services (address, rpc.address and similar) to their namespace address in 169.254.<addressblock>.0/24. Setting them yourself fails evaluation with conflicting definition values.
  • A namespace accepts connections only from its own localhost, from the namespaces of connected services and from the host. Connections from the host come from the bridge address 169.254.<addressblock>.10, which every namespace accepts. This covers every process in the host network namespace, not only the operator user: Tor, sshd, backup jobs and services without a namespace can reach every service listener, so the services still rely on their own authentication.
  • Connections from your LAN are dropped, and opening ports in networking.firewall doesn’t change this. Use onion services for remote access.
  • Outgoing connections leave through the host with NAT. A service without tor.enforce can connect to other hosts in your LAN, not only to the internet.
  • The host forwards only the connections that the namespaces open and their replies. It drops all other forwarded IPv4 traffic, so a host in one of your networks can’t reach another network through the node. If the node routes for other networks, for example for VMs, containers or a VPN, set nix-bitcoin.netns-isolation.restrictForwarding = false. networking.nat, Docker and Tailscale with routing features turn on net.ipv4.conf.all.forwarding, and evaluation fails with it until you do. Tools that route without this setting, like libvirt, Podman or Incus, aren’t detected.
  • When you disable netns-isolation, the host forwards between all its interfaces until you reboot, because NixOS doesn’t turn IP forwarding off again.
  • With tor.enforce, a namespace drops outgoing connections except to the addresses it accepts connections from.
  • IPv6 is disabled on the namespace interfaces.
  • Each namespace copies the host’s net.mptcp.enabled setting when it is created. A later change of the host setting doesn’t reach existing namespaces, and a switch that only changes this setting doesn’t recreate them. Reboot after you change this setting.
  • Other local users can’t take a service’s port. Without netns-isolation, services listen on the host’s loopback address on an unprivileged port. Most of them, such as clnrest, electrs and Fulcrum, bind their port themselves. While such a service is down, for example during a restart or an update, any other local user can listen on its port and receive what clients send, such as the credentials in a ZEUS connection or the addresses of an Electrum wallet. RTL and Orchard aren’t affected once their systemd socket has started, because it holds their port while they’re stopped. A namespace address exists only in the service’s namespace, so a process in the host namespace can’t receive connections to it.
  • On the host, connect to a service at its namespace address, config.nix-bitcoin.netns-isolation.netns.<service>.address, not at 127.0.0.1.
  • It can’t be combined with a bitcoind on another node, the WireGuard preset or firewalld. It needs the iptables firewall backend and a firewall package with bin/iptables. networking.nftables can stay enabled if you set networking.firewall.backend = "iptables" and networking.firewall.package = pkgs.iptables. Then put your own nftables rules in networking.nftables.tables and set networking.nftables.flushRuleset = false. Flushing the ruleset deletes the bridge’s NAT rule, the forwarding rules and the host firewall. It’s on by default when networking.nftables.ruleset or rulesetFile is set or system.stateVersion is older than 23.11. Don’t name a table nat, filter or mangle in the ip family or filter or mangle in the ip6 family, since iptables keeps its rules there. The host firewall keeps its reverse path check in the mangle tables. If you fix either of these on a running node or turn off networking.nftables, reboot once after deploying, since the old deletions still run once. Or run systemctl reload-or-restart firewall.service, systemctl reload-or-restart nb-netns-forward.service and systemctl restart nb-netns-bridge.service in this order. Skip the first command without networking.firewall.enable and the second without nix-bitcoin.netns-isolation.restrictForwarding. The flush and the table names don’t matter when netns-isolation and the firewall run pkgs.iptables-legacy, whose rules live outside the nftables ruleset. Setting it as networking.firewall.package does both, but the default kernel lacks the legacy xtables it needs (see WireGuard firewall compatibility).

Migrate existing services to bitcoinix

Example: bitcoind

# 1. Stop bitcoind on your node
ssh root@<node> 'systemctl stop bitcoind'
# Also stop bitcoind on the node that you'll be copying data from

# 2. Copy the data to the bitcoinix node
# Important: Add a trailing slash to the source path
rsync -a /path/to/existing/bitcoind-datadir/ root@<node>:/var/lib/bitcoind

# 3. Fix data dir permissions on the bitcoinix node
ssh root@<node> 'chown -R bitcoin: /var/lib/bitcoind && chmod 750 /var/lib/bitcoind'

# 4. Start bitcoind
ssh root@<node> 'systemctl start bitcoind'

You can use the same workflow for other services.
The data dir is set by option services.<service>.dataDir. For bitcoind, clightning, lnd, electrs, fulcrum, rtl, btcpayserver and nbxplorer, it defaults to /var/lib/<service>.

Some services require extra steps:

  • LND

    Copy your wallet password to $secretsDir/lnd-wallet-password (See: Secrets dir).

    When lnd on the bitcoinix node starts without a wallet, as after the first deploy, it creates a new wallet and writes its seed to lnd-seed-mnemonic in its data dir (/var/lib/lnd by default). This seed can’t recover your migrated wallet. rsync -a keeps files that the old data dir doesn’t have, so the file would stay. Before you copy the data, copy the file off the node and remove it from the node. Keep that copy if you sent funds to the new wallet, because the migration replaces that wallet:

    scp root@<node>:/var/lib/lnd/lnd-seed-mnemonic ./new-wallet-seed
    ssh root@<node> 'rm /var/lib/lnd/lnd-seed-mnemonic'
    

    The seed of your migrated wallet is the seed of your old node. If the old data dir has an lnd-seed-mnemonic, the copy brings it over.

    If you migrated lnd before, the lnd-seed-mnemonic on the node holds your old node’s seed only if the old data dir had that file. Otherwise it holds the seed of the wallet that bitcoinix created before the copy, and it can’t recover your migrated wallet. Keep your old node’s seed as the backup of your wallet.

  • BTCPay Server

    Copy the PostgreSQL database:

    # Export (on the other node)
    sudo -u postgres pg_dump YOUR_BTCPAYSERVER_DB > export.sql
    # Restore (on the bitcoinix node)
    sudo -u postgres psql btcpaydb < export.sql
    

    This doesn’t copy the private keys of hot wallets. NBXplorer stores them in its own database (nbxplorer on bitcoinix). Without them, hot wallets come back watch-only. Before you migrate, make sure you have the recovery phrase of each hot wallet, so you can import it again in BTCPay Server.

Use bitcoind from another node

Here’s how to use a bitcoind instance running on another node within a bitcoinix config. This doesn’t work with network namespace isolation.

Import the bitcoind-remote.nix preset. With the flake.nix example, add it to the modules list in flake.nix, next to bitcoinix.nixosModules.default:

(bitcoinix + "/modules/presets/bitcoind-remote.nix")

With Colmena, add (inputs.bitcoinix + "/modules/presets/bitcoind-remote.nix") to the imports of your node. With krops, add it to configuration.nix:

imports = [ <nix-bitcoin/modules/presets/bitcoind-remote.nix> ];

Then configure the connection to the other node:

services.bitcoind = {
  enable = true;

  # Address of the other node
  address = "10.10.0.2";
  rpc.address = "10.10.0.2";

  # Only needed for BTCPay Server: NBXplorer needs a whitelisted P2P connection.
  # Set the port of a `whitebind` on the other node, or its regular P2P port
  # if it has `whitelist=<address of this node>`.
  whitelistedPort = 8333;

  rpc.users = {
    # The fully privileged RPC user on the other node
    privileged.name = "myrpcuser";
    # A restricted RPC user on the other node (see the whitelist setup below)
    public.name = "mypublicrpcuser";
    ## Core Lightning, mempool and BTCPay Server each need their own restricted
    ## RPC user. Set the ones for the services you use.
    # clightning.name = "myclightningrpcuser";
    # mempool.name = "mymempoolrpcuser";
    # btcpayserver.name = "mybtcpayrpcuser";
  };
};

# With the secure-node preset or `enable-tor.nix`: don't create an onion service
# on this node that forwards to the other node.
nix-bitcoin.onionServices.bitcoind.enable = false;

With Tor enforcement (services.<service>.tor.enforce, enabled by the secure-node preset and enable-tor.nix), services can’t reach the other node. Allow the connection for each service that connects to bitcoind, for example electrs:

systemd.services.electrs.serviceConfig.IPAddressAllow = [ "10.10.0.2" ];

These services resolve names in-process from /etc/hosts, so a host name that isn’t there won’t resolve. Set address to an IP address, or add the name of the other node to networking.hosts.

electrs reads blocks through bitcoind’s REST interface. If you use electrs, set rest=1 on the other node (Bitcoin Core 31 or later). REST is unauthenticated and available to every source allowed by the other node’s rpcallowip, so keep that list limited to the hosts that need it.

Services that only need the public RPC methods connect as public. Do not use the privileged user for public.name: that gives every such service full RPC access to the other node. Core Lightning, mempool and BTCPay Server connect as their own users, so that the methods only they need don’t reach the other services.

Create the RPC users on the other node with separate passwords, for example using Bitcoin Core’s rpcauth. For each restricted user, set rpcwhitelist=<username>:<comma-separated methods> there using the evaluated whitelist from your bitcoinix configuration:

  • mypublicrpcuser: services.bitcoind.rpc.users.public.rpcwhitelist
  • myclightningrpcuser, if used: services.bitcoind.rpc.users.clightning.rpcwhitelist
  • mymempoolrpcuser, if used: services.bitcoind.rpc.users.mempool.rpcwhitelist
  • mybtcpayrpcuser, if used: services.bitcoind.rpc.users.btcpayserver.rpcwhitelist

Use Debug your configuration to inspect these options. modules/bitcoind-rpc-public-whitelist.nix is the base list of the public user. The other restricted users add the methods that their service needs: getblockfrompeer for Core Lightning’s bcli plugin and for BTCPay Server, and gettxoutsetinfo for mempool. BTCPay Server’s whitelist also includes any permissions you explicitly grant it, such as scantxoutset for wallet UTXO scanning. Update the remote whitelists when these permissions change. The local settings do not configure the remote node.

When you add an rpcwhitelist for the public user on the other node, also set rpcwhitelistdefault=0 there. Otherwise Bitcoin Core gives every user without a whitelist, including the privileged user, an empty whitelist.

Now save the RPC passwords to the following files on your bitcoinix node:

# Password of the privileged user (`myrpcuser`)
$secretsDir/bitcoin-rpcpassword-privileged
# Password of the restricted user (`mypublicrpcuser`)
$secretsDir/bitcoin-rpcpassword-public

## Passwords of the users for Core Lightning, mempool and BTCPay Server,
## only needed for the services you use
# $secretsDir/bitcoin-rpcpassword-clightning
# $secretsDir/bitcoin-rpcpassword-mempool
# $secretsDir/bitcoin-rpcpassword-btcpayserver

Without nix-bitcoin.generateSecrets, nix-bitcoin.setupSecrets also checks a bitcoin-HMAC-<user> file for each of these users. This node doesn’t use them, so create them empty and set nix-bitcoin.secrets.bitcoin-HMAC-<user>.allowEmpty = true, or write the HMAC of each password: the part after rpcauth=<username>: in the line that Bitcoin Core’s share/rpcauth/rpcauth.py prints. See: Secrets dir

Afterwards, restart bitcoind: systemctl restart bitcoind.

Temporarily disable a service

Sometimes you might want to disable a service without removing the service user and integration with other services, as it would happen when setting services.<service>.enable = false.

Use the following approach:

systemd.services.<service>.wantedBy = lib.mkForce [];

This needs lib in scope (see Set options). The systemd service still exists, but is not automatically started.
Note: This only works for services that are not required by other active services.

Write to /run or /dev/shm from a service hook

Most bitcoinix services (those that use nix-bitcoin.lib.defaultHardening, like bitcoind, clightning and lnd) see /run and /dev as read-only. A custom preStart, postStart or ExecStartPost command in these services that writes there fails with Read-only file system. The service’s own RuntimeDirectory (e.g. /run/lnd) and data dir stay writable, and so do device nodes like /dev/null.

To allow writing to another path, add it to ReadWritePaths. The path must exist when the service starts:

systemd.services.lnd.serviceConfig.ReadWritePaths = [ "/run/my-dir" ];

This adds to the service’s own ReadWritePaths; it doesn’t replace them.
Alternatively, prefix a command in ExecStartPre or ExecStartPost with + to run it as root outside the sandbox.

Appendix

Secrets dir

The secrets dir is set by option nix-bitcoin.secretsDir and has the following default values:

  • If you’re using the krops deployment method: /var/src/secrets

  • Otherwise: /etc/nix-bitcoin-secrets

With nix-bitcoin.setupSecrets = true, setup-secrets sets the declared secrets’ owners and permissions and restricts undeclared files to root. A declared secret that is missing or isn’t a regular file fails setup, and so does an empty one, unless its nix-bitcoin.secrets.<name>.allowEmpty is set. setup-secrets makes the directory accessible only to root while it runs; if setup fails, services lose access to all secrets there until a successful run restores directory mode 0751.

nix-bitcoin.generateSecrets = true enables setup and generates secrets in the same sandbox. Custom nix-bitcoin.generateSecretsCmds have no IP network access and can write only to the secrets directory and private temporary directories. Store final secrets inside the secrets directory, including secrets supplied by another tool, rather than linking to external files. See the 0.1.3 upgrade instructions for migration and recovery steps.

Tools like agenix install secrets as symlinks to files outside the secrets directory by default. setup-secrets can’t set the owner and permissions of these files, so setup fails. With agenix, set symlink = false for these secrets, and set their owner, group and mode to the user, group and permissions of nix-bitcoin.secrets.<name>. Or disable nix-bitcoin.generateSecrets and nix-bitcoin.setupSecrets, set nix-bitcoin.secretsSetupMethod = "manual", and set the owners and permissions declared in nix-bitcoin.secrets yourself.

Upgrading

Some releases contain changes that need manual action, such as a removed service, a changed default or a required reindex. bitcoinix reports them when it evaluates your configuration: if a released change is newer than nix-bitcoin.configVersion and affects your configuration, evaluation fails with a short description of the change. Options of removed services and other service assertions can fail evaluation regardless of the config version.

Keep nix-bitcoin.configVersion set to the released version whose migrations you have completed. Values newer than the latest finalized release in version.nix are rejected; use the released version named in the error until release finalization. If the option is unset, migration errors and warnings are disabled. Keep this value explicit: importing the project’s version.nix would automatically acknowledge migrations on each release.

When evaluation fails after an update, follow the version pages below for each version newer than your config version, starting with the oldest. Then set nix-bitcoin.configVersion to the version named in the error message.

On master, review unreleased migration warnings before deploying and keep configVersion at the latest release. These warnings do not block deployment or require acknowledgement: deployment can proceed even before a required migration is completed. They cannot be acknowledged individually and can repeat after migration while their conditions still apply. Once the release is finalized, its notices become errors until you acknowledge them by updating configVersion after migrating.

Updating bitcoinix

Review the release notes for changes to packages and flake attributes.

With a flake-based deployment, verify the new release tag as in step 3 of the installation, set it in flake.nix, run nix flake lock and check the locked commit as in step 4.2. Then deploy.

With krops, run update-nix-bitcoin from the deployment shell.
This fetches the latest release, verifies the signature on its release tag and updates nix-bitcoin-release.nix.
It refuses to switch to a release older than the one currently pinned. To downgrade on purpose, run fetch-release.sh with releaseVersion=<version> and write its output to nix-bitcoin-release.nix.

During development, each change has its own file under docs/upgrading/<version>/. At release time, the draft files are combined into docs/upgrading/<version>.md. See Cutting a release.

Versions

Upgrading to config version 0.2.1

netns-isolation forwards only namespace traffic

netns-isolation turns on IPv4 forwarding for the NAT of the service namespaces. Before, it added no forwarding rules, so the host forwarded traffic between all its interfaces. On a node with two networks, for example a LAN and a VPN, a host on one side could reach the other side through the node.

Now the unit nb-netns-forward adds the iptables chain nb-netns-forward and appends a jump to it to the FORWARD chain. The chain accepts the connections that a namespace opens and their replies, and drops all other forwarded IPv4 traffic.

Evaluation fails when boot.kernel.sysctl."net.ipv4.conf.all.forwarding" is on. networking.nat, Docker and Tailscale with useRoutingFeatures set to server or both turn it on. Other tools can route through the node without this setting, for example libvirt, Podman, Incus or systemd-networkd with IPMasquerade. Their forwarded traffic is now dropped too, unless their own rules accept it before the jump. If this node routes for other networks, set this.

nix-bitcoin.netns-isolation.restrictForwarding = false;

netns-isolation then adds no forwarding rules, and the host forwards between all its interfaces like before, unless you filter forwarded traffic yourself.

To keep the rules and allow some forwarded traffic, insert your ACCEPT rules at the top of FORWARD. A rule that’s appended after the jump has no effect. An accept in an nftables table of its own doesn’t help either, because the packet still passes the FORWARD chain of iptables. For example, this lets hosts on wg0 reach the LAN on eth0. The firewall runs the stop commands before the start commands on each reload, also before the rule exists, so the delete must not fail.

networking.firewall.extraCommands = ''
  iptables -w -I FORWARD -i wg0 -o eth0 -j ACCEPT
  iptables -w -I FORWARD -i eth0 -o wg0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
'';
networking.firewall.extraStopCommands = ''
  iptables -w -D FORWARD -i wg0 -o eth0 -j ACCEPT 2>/dev/null || true
  iptables -w -D FORWARD -i eth0 -o wg0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT 2>/dev/null || true
'';

To list the rules and count the dropped packets, run this as root.

iptables -vnL nb-netns-forward

netns-isolation rejects an nftables ruleset flush

With networking.nftables and iptables-nft, the NAT rule of the namespace bridge, the forwarding rules of nb-netns-forward and the host firewall live in the nftables ruleset. netns-isolation now fails evaluation when networking.nftables.flushRuleset is on. With the flush, each start, reload or stop of nftables.service deletes these rules. NixOS turns the flush on by default when networking.nftables.ruleset or rulesetFile is set or system.stateVersion is older than 23.11.

Evaluation also fails when networking.nftables.tables has a table that iptables-nft uses. nftables.service deletes and creates such a table again on each start or reload, and deletes it on stop, so it replaces the iptables table of the same name. These tables count.

  • ip nat holds the NAT rule of the bridge.
  • ip filter holds the host firewall and the forwarding rules. It counts while networking.firewall.enable or nix-bitcoin.netns-isolation.restrictForwarding is on.
  • ip6 filter holds the host firewall for IPv6. It counts with networking.firewall.enable and networking.enableIPv6.
  • ip mangle and ip6 mangle hold the reverse path check of the host firewall. They count with networking.firewall.enable while networking.firewall.checkReversePath isn’t false. The default is "loose". ip6 mangle counts only with networking.enableIPv6.

A firewall that runs pkgs.iptables-legacy as networking.firewall.package is exempt, since its rules live outside the nftables ruleset.

Put your nftables rules in networking.nftables.tables and turn the flush off. Rename such a table or use the inet family.

networking.nftables.flushRuleset = false;
networking.nftables.tables.my-rules = {
  family = "inet";
  content = ''
    # Your chains and rules
  '';
};

nftables.service keeps the deletions of the config it loaded last and runs them on its next reload or stop. So the first deploy after such a fix still runs the old flush or deletes the old table once. This also happens when you fix the config in the same deploy as this update, so that evaluation doesn’t fail, and when you turn off networking.nftables. Reboot once after that deploy. Or run these commands as root in this order.

systemctl reload-or-restart firewall.service
systemctl reload-or-restart nb-netns-forward.service
systemctl restart nb-netns-bridge.service

Skip the first command without networking.firewall.enable and the second without nix-bitcoin.netns-isolation.restrictForwarding. A reload adds the rules again in place. A restart of firewall.service or nb-netns-forward.service removes the rules that are still there before it adds them again, so the host accepts or forwards all traffic for a moment. The restart of nb-netns-bridge.service also restarts every service in a namespace.

Empty LND RPC host

If you set services.lnd.rpcAddress to "" or "[]", choose the address LND should listen on. Remove the setting to use the default loopback address (127.0.0.1). Set "::" to keep the previous IPv6-only wildcard listener, or "0.0.0.0" for an IPv4-only wildcard listener. If you supply LND’s TLS certificate yourself, include the chosen IP address in its subject alternative names so local gRPC clients can verify it. In OpenSSL notation, the entries for the two wildcards are IP::: and IP:0.0.0.0, respectively.

bitcoind data dir no longer writable by its group

The bitcoind data dir (services.bitcoind.dataDir, /var/lib/bitcoind by default) now has mode 0750 instead of 0770. Before, every member of the bitcoind group (services.bitcoind.group, bitcoin by default) could create, rename and delete entries in it. The group holds the operator user (with nix-bitcoin.operator.enable) and the users that you add to it.

The deployment sets the new mode with tmpfiles, which doesn’t follow a symlink. So if the data dir is a symlink, give its target the owner and mode that tmpfiles would set, with chown bitcoin:bitcoin and chmod 750 on the target. Use your services.bitcoind.user and services.bitcoind.group if you changed them.

Group members can still use bitcoin-cli, read the RPC cookie and read the files they could read before, also the blocks dir with services.bitcoind.dataDirReadableByGroup. A script that writes to the data dir as a group member now fails. Run it as the bitcoind user (services.bitcoind.user, bitcoin by default) or as root.

bitcoind creates its files as the bitcoind user. To list the entries in the data dir that another user created, run this as root. Use your services.bitcoind.dataDir and services.bitcoind.user if you changed them.

find /var/lib/bitcoind/ ! -user bitcoin

Stop bitcoind and move each entry that you didn’t create yourself out of the data dir before you start bitcoind again.

Core Lightning replication dirs no longer writable by its group

With services.clightning.replication, two dirs now have mode 0750 instead of 0770, like the Core Lightning data dir.

  • services.clightning.replication.local.directory, when local.setupDirectory is on. It holds the replica, or with encrypt the encrypted replica.
  • /var/cache/clightning-replication, with sshfs.destination or encrypt. It holds the mount points of SSHFS and gocryptfs.

Before, every member of the clightning group (services.clightning.group, clightning by default) could create, rename and delete entries in them. The group can hold the operator user (with nix-bitcoin.operator.enable), BTCPay Server’s user (with services.btcpayserver.lightningBackend = "clightning") and the users that you add to it.

The deployment sets the new modes, and clightning removes write access of the group and others from the local dir again when it starts. If the local dir belongs to another user, for example on a share that you set up yourself, clightning can’t change it. Then make the clightning user its owner and give it mode 0750, on the share’s server or in its mount options if needed. A server needs the user’s numeric id, which id -u clightning prints on this node. Check that clightning can still write there, for example with runuser -u clightning -- test -w <local.directory> && echo writable.

Group members can still read these dirs. A script that writes there as a group member now fails. Run it as the clightning user (services.clightning.user, clightning by default) or as root.

clightning creates its files there as the clightning user. After you deploy, list the entries that another user created. Stop the replication first, because root can’t look into the mounts, but keep the replica’s disk or share mounted. Then run this as root. Use your local.directory and services.clightning.user, and leave out what your config doesn’t use.

systemctl stop clightning-replication-mounts clightning
find /var/backup/clightning /var/cache/clightning-replication ! -user clightning

On a share where root can’t read the local dir, run its find as the clightning user with runuser -u clightning --, or on the share’s server with ! -uid <id> and the numeric id from above. lost+found and the entries that you created as root are fine. Move every other entry out of these dirs, on the share’s server if needed. Then start clightning again with systemctl start clightning.

dhcpcd control socket

Nodes that use dhcpcd and bitcoinix’s nixpkgs now run dhcpcd 10.5.2. Since 10.5, only root and dhcpcd’s own user can use its control socket, so commands like dhcpcd -U and dhcpcd --dumplease fail for other users. Run them as root.

After migrating your configuration, set nix-bitcoin.configVersion = "0.2.1";.

Upgrading to config version 0.2.0

Unstable NixOS base

bitcoinix now bases its systems and packages on unstable nixpkgs only. The single nixpkgs input tracks nixos-unstable; remove any follows declarations targeting bitcoinix/nixpkgs-unstable. Continue following bitcoinix/nixpkgs for your node. The system itself must be evaluated with unstable nixpkgs, regardless of nix-bitcoin.useVersionLockedPkgs. NixOS 26.05 evaluation fails before migration assertions run, even without I2P or namespace isolation, with an error such as The option `services.i2pd.checkConfig' does not exist. Switch your system’s nixpkgs input to unstable before evaluating this release. If your system follows bitcoinix/nixpkgs, as the deployment examples do, updating bitcoinix moves the whole OS from NixOS 26.05 to unstable, not only service packages.

PostgreSQL 14 removed

nixos-unstable has removed PostgreSQL 14. If you don’t set services.postgresql.package, NixOS selects PostgreSQL by system.stateVersion, and with a stateVersion from 22.05 through 23.05 that was PostgreSQL 14. Then your PostgreSQL databases, such as those of BTCPay Server and NBXplorer, are in PostgreSQL 14, and bitcoinix 0.2.0 fails evaluation. This also happens if you set services.postgresql.package = pkgs.postgresql_14;. Check the running version as root with runuser -u postgres -- psql -tAc 'SHOW server_version'.

Upgrade the databases before you update bitcoinix, while the node still has PostgreSQL 14. The steps follow Upgrading in the NixOS manual, but run the commands as root with runuser, which works without sudo. With the secure-node preset, sudo is only an alias for doas.

  1. Back up the databases, see Backups.

  2. Add this to your configuration and deploy it with your current bitcoinix version:

    environment.systemPackages = [
      (let
        cfg = config.services.postgresql;
        newPostgres = pkgs.postgresql_17.withPackages cfg.extensions;
        newData = "/var/lib/postgresql/${newPostgres.psqlSchema}";
        # Add the other services that use PostgreSQL
        units = lib.optionals config.services.btcpayserver.enable [
          "btcpayserver" "nbxplorer"
        ] ++ [ "postgresql" ];
        # initdb turns data checksums off by default before PostgreSQL 18,
        # which added this flag and turns them on
        noChecksums = lib.optionalString (lib.versionAtLeast newPostgres.psqlSchema "18")
          "--no-data-checksums";
      in pkgs.writeScriptBin "upgrade-pg-cluster" ''
        set -eux
        export NEWDATA="${newData}"
        export NEWBIN="${newPostgres}/bin"
        export OLDDATA="${cfg.dataDir}"
        export OLDBIN="${cfg.finalPackage}/bin"
        if [ -e "$NEWDATA" ]; then
          echo "$NEWDATA exists. Leave it intact and set newData to a new dir." >&2
          exit 1
        fi
        # pg_upgrade requires the new cluster to match the old data checksum setting
        case $(runuser -u postgres -- "$OLDBIN/psql" -p ${toString cfg.settings.port} -tAc 'SHOW data_checksums') in
          on) checksums=--data-checksums ;;
          off) checksums="${noChecksums}" ;;
          *) echo "Can't read data_checksums. Is PostgreSQL running?" >&2; exit 1 ;;
        esac
        systemctl stop ${toString units}
        trap 'systemctl start ${toString units}' ERR
        install -d -m 0700 -o postgres -g postgres "$NEWDATA"
        cd "$NEWDATA"
        runuser -u postgres -- "$NEWBIN/initdb" -D "$NEWDATA" ${lib.escapeShellArgs cfg.initdbArgs} $checksums
        runuser -u postgres -- "$NEWBIN/pg_upgrade" \
          --old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
          --old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
          "$@"
      '')
    ];
    

    If you set services.postgresql.dataDir, set newData to a path that doesn’t exist yet. If you set services.postgresql.extensions to a list, write it as a function, such as ps: [ ps.postgis ], so that the script uses the PostgreSQL 17 extensions. The script initializes the new data dir with the data checksum setting of the running server, as pg_upgrade requires.

  3. Run upgrade-pg-cluster as root. If newData already exists, the script stops before it changes anything. Don’t delete that dir, it can hold another cluster: set newData to a new path. If the script fails later, it starts the services again on the old data, which it leaves unchanged. Fix the cause and delete the newData dir that the script created before you run it again.

  4. Set services.postgresql.package = pkgs.postgresql_17; and, if you set it, services.postgresql.dataDir to newData. Remove the script and deploy. PostgreSQL and its services start on the upgraded data.

  5. Check BTCPay Server, then update bitcoinix.

Don’t change system.stateVersion to select a newer PostgreSQL: the data dir /var/lib/postgresql/<version> changes with it, so PostgreSQL starts with a new, empty database.

Unversioned PostgreSQL package moves to 18

nixos-unstable’s pkgs.postgresql has moved from PostgreSQL 17 to 18. If you set services.postgresql.package = pkgs.postgresql;, PostgreSQL 18 doesn’t use your PostgreSQL 17 data after the update: it starts with a new, empty data dir /var/lib/postgresql/18 or, with a custom services.postgresql.dataDir, fails to start. Evaluation reports each config that sets a PostgreSQL 18 package.

Check the running version as root with runuser -u postgres -- psql -tAc 'SHOW server_version'. If it’s 17, set services.postgresql.package = pkgs.postgresql_17; before you update. To move to PostgreSQL 18 later, follow the steps in PostgreSQL 14 removed with pkgs.postgresql_18 in place of pkgs.postgresql_17.

Custom package imports

Custom calls to lib.mkNbPkgs or pkgs/default.nix must remove pkgsUnstable. Use pinned.pkgs in place of pinned.pkgsUnstable. The deployment shell no longer exports nixpkgsUnstable; use the nixpkgs entry in NIX_PATH instead. The dependency update helper no longer accepts a NixOS release argument.

Service package selection

With the flake’s NixOS module, nix-bitcoin.useVersionLockedPkgs now defaults to true, including for local package builds. Your system’s nixpkgs.overlays and nixpkgs.config no longer apply to the pinned service packages, including bitcoind, lnd and clightning. Review any security patches or other customizations supplied through overlays: set nix-bitcoin.useVersionLockedPkgs = false to use your system’s customized unstable package set, or explicitly override the affected service’s package.

The formerly separate unstable service packages (including lnd and clightning) now also follow your system’s nixpkgs when you set this option to false or import the NixOS modules without flakes. Non-flake module imports do not provide the useVersionLockedPkgs option. If your flake sets bitcoinix.inputs.nixpkgs.follows = "nixpkgs", even the option’s default true uses your chosen input instead of bitcoinix’s tested revision. This is different from having your system’s nixpkgs.follows = "bitcoinix/nixpkgs", which keeps the bitcoinix pin.

In these setups, pin your own nixpkgs and review service versions before each update against the tested versions. An update can upgrade or downgrade a daemon independently of bitcoinix; an older lnd or clightning may refuse a database written by a newer version. Follow the daemon’s migration instructions and do not assume rolling back nixpkgs can roll back its database.

Keep your existing system.stateVersion: it controls state compatibility and does not select the nixpkgs channel.

Firewall and FUSE defaults

The OS update also changes these NixOS defaults:

  • networking.firewall.checkReversePath changes from true (strict) to "loose". Loose checking accepts a source reachable through any interface, rather than requiring the return route to use the incoming interface. Set networking.firewall.checkReversePath = true; to retain strict checking, after checking compatibility with your routing and VPN configuration.
  • programs.fuse.enable defaults to false. If you use non-root FUSE mounts, such as an sshfs backup target, set programs.fuse.enable = true; to keep the privileged mount helper. Encrypted Core Lightning replication enables it automatically; unrelated operator mounts need their own setting.

I2P settings and validation

For custom i2pd configuration, replace services.i2pd.proto.sam with services.i2pd.settings.sam and rename its enable field to enabled. bitcoinix still enables SAM automatically for services.bitcoind.i2p and sets its address for namespace isolation. The web console, HTTP proxy and SOCKS proxy remain disabled by default, and NTCP2/SSU2 address publication remains disabled. Explicit opt-ins through services.i2pd.settings still take precedence.

With namespace isolation, bitcoinix disables services.i2pd.checkConfig by default: the upstream build-time check starts i2pd and cannot bind the namespace bridge address inside the build sandbox. Custom setting errors can therefore surface only when the service starts. After changing I2P settings, check systemctl status i2pd and journalctl -u i2pd, and verify bitcoind can reach the SAM listener. The i2p VM scenario exercises this bridge listener and i2pLocal covers the loopback listener with the upstream check enabled; these tests do not validate your custom configuration.

Core Lightning in systemd-nspawn

On the unstable package/system base, Core Lightning in systemd-nspawn needs memory-locking syscalls allowed to keep its signing keys out of swap. For a custom NixOS/systemd-nspawn container, add this to the host configuration, replacing node with the container name:

containers.node.extraFlags = [ "--system-call-filter=@memlock" ];

Without it, lightning_hsmd aborts during startup. The bitcoinix container examples and test runner already set this flag. The normal memory-lock limit still applies; no additional capability is needed.

Bitcoin network selection

Replace services.bitcoind.regtest = true; with services.bitcoind.network = "regtest";. If you explicitly set services.bitcoind.regtest = false;, remove it or set services.bitcoind.network = "mainnet"; (the default). The new option selects the network for the whole deployment; existing network-specific paths and ports are unchanged.

The old boolean is forwarded to network during migration, so upgrade notices still use the network and paths from your existing configuration. It emits a deprecation warning if used after updating configVersion.

Network name overrides

The read-only services.bitcoind.makeNetworkName helper has been removed. Replace calls such as config.services.bitcoind.makeNetworkName "bitcoin" "regtest" with the new helper, specifying only names that need overriding. In a NixOS module taking config as an argument, define nbLib before using the short name:

let
  nbLib = config.nix-bitcoin.lib;
in
  nbLib.networkName { mainnet = "bitcoin"; }

This returns "bitcoin" on mainnet and "regtest" on regtest. Unmapped network names pass through unchanged.

Mempool follows the selected network

Mempool now identifies as regtest in both its backend and frontend when services.bitcoind.network = "regtest";. Previously it identified as mainnet while connecting to the regtest node. It automatically clears disk caches labelled mainnet and reloads data from its backend after restart.

Review overrides in services.mempool.frontend.settings: regtest defaults to MAINNET_ENABLED = false, REGTEST_ENABLED = true and ROOT_NETWORK = "regtest". Remove conflicting overrides unless needed for a custom deployment. If you set services.mempool.frontend.staticContentRoot, update that custom frontend too. The web interface stays at the same URL; reload it after deploying.

Regtest onion target port

On regtest, bitcoinix now maps the public onion port 18444 to the local bitcoind listener on 18445 by default. The generated Tor mapping updates automatically.

If you manage a separate Tor mapping that forwards to 8334, update its target to 18445 or set services.bitcoind.onionPort = 8334; to keep using the old listener.

bitcoind sysperms option removed

services.bitcoind.sysperms has been removed. Bitcoin Core 25.0 removed its sysperms setting, so bitcoind ignored the option and logged a warning about it. Remove the option from your configuration. To let the bitcoind group read the blocks dir, set services.bitcoind.dataDirReadableByGroup = true;. This now also covers the files that bitcoind creates while it runs. It needs POSIX ACL support on the filesystem of the blocks dir, and it turns off bitcoind’s wallet.

Group read access needs a real bitcoind blocks dir

With services.bitcoind.dataDirReadableByGroup on mainnet, bitcoind no longer changes the permissions of the blocks dir (blocks in the data dir) when it’s a symlink. Members of the bitcoind group can write to the data dir, so they could replace blocks with a symlink to other files of the bitcoind user and make bitcoind give the group access to them. The new bitcoind-group-read service, which sets up the group’s access before each start of bitcoind, now logs a warning and leaves the target alone. On regtest, the blocks dir wasn’t covered before. Now it is, if neither regtest nor regtest/blocks is a symlink. On signet and testnet4, the network subdirectory and its blocks subdirectory must also be real directories or mount points.

If your blocks dir is a symlink, for example to a dir on a second disk, the group can’t read the block files that bitcoind creates from now on. Replace the symlink with a dir, or with a bind mount of the dir on the second disk. That dir and all entries in it must belong to the bitcoind user and group (bitcoin by default). The service leaves an entry of another user or group alone, so the bitcoind group can’t read it, and logs a warning on each start. So don’t mount the root of a filesystem there, which can hold a root-owned lost+found.

A mount point can’t be a symlink. Stop bitcoind and run rm /var/lib/bitcoind/blocks. Then deploy a config with a mount like the one below, and start bitcoind.

fileSystems."/var/lib/bitcoind/blocks" = {
  device = "/mnt/disk2/blocks";
  fsType = "none";
  options = [ "bind" ];
};

Own RPC users for Core Lightning and mempool

Core Lightning and mempool now connect to bitcoind as their own RPC users, clightning and mempool. Before, they connected as the public user and added the methods they need to its whitelist: getblockfrompeer for Core Lightning’s bcli plugin and gettxoutsetinfo for mempool. All services of the public user share its whitelist, so electrs, Fulcrum, lnd and the others could call these methods too. gettxoutsetinfo can keep bitcoind busy for minutes. Now the public user has only the base whitelist, and each new user has the base whitelist plus the method of its service.

Each new user has its own password and HMAC in the secrets dir: bitcoin-rpcpassword-clightning and bitcoin-HMAC-clightning, and bitcoin-rpcpassword-mempool and bitcoin-HMAC-mempool. What you have to do depends on your setup:

  • With nix-bitcoin.generateSecrets = true or the krops deployment shell, and bitcoind on the same node, bitcoinix creates these files, and there’s nothing else to do. No option marks a bitcoind on another node, so evaluation reports this change for every config with Core Lightning or mempool.
  • If you supply secrets yourself, create these files for the services you use before deploying. Write a new password to bitcoin-rpcpassword-<user>, and its HMAC to bitcoin-HMAC-<user>: the <salt>$<hmac> part of the rpcauth= line that Bitcoin Core’s share/rpcauth/rpcauth.py prints. With nix-bitcoin.setupSecrets, a missing file fails setup, and then no service can read its secrets.
  • With the bitcoind-remote.nix preset, create the new users on the other node as described in Use bitcoind from another node, with the whitelists in services.bitcoind.rpc.users.clightning.rpcwhitelist and services.bitcoind.rpc.users.mempool.rpcwhitelist. Set services.bitcoind.rpc.users.<user>.name if a user has another name there. Save their passwords to bitcoin-rpcpassword-<user> on this node. With nix-bitcoin.generateSecrets = true, bitcoinix creates a password when the file is missing, and bitcoin-HMAC-<user> then holds the part after rpcauth=<name>: for the other node. Without it, write the HMAC as above, or create an empty bitcoin-HMAC-<user> and set nix-bitcoin.secrets.bitcoin-HMAC-<user>.allowEmpty = true, since this node doesn’t use it.

With bitcoind on another node, its whitelists still have the methods that bitcoinix added before. Remove getblockfrompeer and gettxoutsetinfo from the whitelist of the public user there, if it has them, whatever your new config enables. If you use BTCPay Server, set the whitelist of its user there again from services.bitcoind.rpc.users.btcpayserver.rpcwhitelist. It builds on the public whitelist, so with mempool it had gettxoutsetinfo too.

Backups leave out the Lightning channel databases

The backups service no longer includes lnd’s graph directory, which holds channel.db, or Core Lightning’s lightningd.sqlite3. It copied these files while the daemons wrote them. A node that runs from an outdated copy can broadcast a revoked channel state, and the peer can then take all funds in that channel.

Backups made before this change still contain these files. Never restore them. To recover Lightning funds, use the files that Lightning channel databases lists. For a copy of the Core Lightning database that’s always current, use database replication.

Backups include copies of bitcoind wallets

Before each backup, the new bitcoind-wallet-backup unit asks a local bitcoind for a consistent copy of each loaded wallet. The duplicity unit now also fails when a copy fails, or when bitcoind is starting or stopping. It still backs up all other files first. If a backup fails, check journalctl -u bitcoind-wallet-backup. See bitcoind wallets.

Core Lightning data dir no longer writable by its group

The Core Lightning data dir (services.clightning.dataDir, /var/lib/clightning by default) now has mode 0750 instead of 0770. Before, every member of the clightning group (services.clightning.group, clightning by default) could create, rename and delete entries in it. A member could swap the config file after clightning.service wrote it and before lightningd read it, and make lightningd start a plugin of its choice. Or it could replace the network dir with one that holds its own hsm_secret. The group can hold the operator user (with nix-bitcoin.operator.enable), BTCPay Server’s user (with services.btcpayserver.lightningBackend = "clightning") and the users that you add to it.

The deployment sets the new mode. Group members can still use the RPC socket, for example with lightning-cli, and read the files they could read before. The RPC socket gives full control over the node, so add only trusted users to this group. A script that writes to the data dir as a group member now fails. Run it as the clightning user (services.clightning.user, clightning by default) or as root.

Every entry in the data dir belongs to the clightning user. To list the entries that don’t, run this as root. Use your services.clightning.dataDir and services.clightning.user if you changed them:

find /var/lib/clightning ! -user clightning

If it lists an entry that you didn’t create as root, a group member created it. Stop clightning and check the entry before you start clightning again. A network dir (bitcoin on mainnet) that a group member created can hold an hsm_secret that the member controls.

clightning requires the mount of its local replica

clightning now requires the mounts for services.clightning.replication.local.directory. With encrypt, clightning-replication-mounts requires them too. This changes something only when a mount that systemd knows, like a fileSystems entry other than /, holds the directory. While that mount is missing, clightning doesn’t start. Before, it started and wrote the replica to the filesystem below the mount point, usually the primary disk. Then a failure of that disk took both copies. Stopping or restarting the mount now also stops or restarts clightning.

Evaluation can’t check which mount holds the directory, so it reports this change for every local replica directory. If the directory is on the root filesystem, or the replica’s disk or share isn’t declared, for example because you mount it by hand, clightning starts as before. Declare the disk or share in fileSystems, as in Local directory target, so that clightning waits for it. systemd doesn’t follow symlinks here, so if local.directory is a symlink, set it to the target instead.

Deploying this change restarts clightning once, because its unit changes.

To check where the replica is, run findmnt --target <local.directory>. It names the filesystem that holds the directory.

Charge-LND credential paths

Charge-LND now reads the configured LND certificate and /run/lnd/charge-lnd.macaroon directly, without a proxy data directory. If you selected custom credentials with --lnddir in services.charge-lnd.extraFlags and omitted either --tlscert or --macaroon, add the missing credential path explicitly. Configurations already specifying both paths, and default configurations, need no changes.

The old /var/lib/charge-lnd/lnddir-proxy tree is left behind on existing hosts. It is no longer used and can be removed after upgrading.

NBXplorer RPC password permissions

NBXplorer’s bitcoind RPC password (bitcoin-rpcpassword-btcpayserver in the secrets dir) is now readable only by NBXplorer’s user (services.nbxplorer.user), with mode 0400. Before, bitcoind’s user and NBXplorer’s group could read it too. BTCPay Server is in that group to read NBXplorer’s API cookie, so it could read the password. BTCPay Server still reads the cookie.

If a program reads the password as another user, give the program its own RPC user in services.bitcoind.rpc.users. If you manage the secret files outside bitcoinix, for example with nix-bitcoin.secretsSetupMethod = "manual", make NBXplorer’s user the owner of the file and set its mode to 0400.

If you think that BTCPay Server was compromised, replace the password. With a local bitcoind and nix-bitcoin.generateSecrets = true, delete the password file and run systemctl restart setup-secrets. Then run systemctl restart bitcoind nbxplorer.

BTCPay Server admin account

BTCPay Server makes the first account that registers the server admin, which can use the internal Lightning node. Before, any local user could register first and take that account until you registered yours. When BTCPay Server has no admin, bitcoinix now creates the admin account admin@localhost before BTCPay Server opens its port. Its password is in the new secret $secretsDir/btcpayserver-admin-password.

  • If your BTCPay Server already has an admin, bitcoinix keeps it and doesn’t create admin@localhost. Check that each admin is yours. Check the admin accounts says how, and what to do if one isn’t. This matters most if BTCPay Server ran for a while before you registered, or if you found registration closed.
  • If it has no admin yet, sign in as admin@localhost instead of registering. See Connect to BTCPay Server.
  • If you supply your secrets yourself instead of with nix-bitcoin.generateSecrets, put a password in btcpayserver-admin-password before you deploy. With krops, the deploy and krops-deploy commands of the deployment shell run generate-secrets, which creates it.

RTL gets its own lnd macaroon and clightning rune

RTL’s start copied lnd’s admin macaroon to macaroons/admin.macaroon and clnrest’s admin rune to clightning-admin-rune in RTL’s data dir, /var/lib/rtl by default. Now RTL gets its own macaroon and rune, which allow only the calls that RTL makes, and its start writes them to these paths. It removes the copy of a backend that RTL doesn’t use. If another app reads one of these files, it gets authorization errors after the deploy for the calls that RTL doesn’t make, or doesn’t find the file. Give the app its own credentials. For lnd, add a custom macaroon with services.lnd.macaroons.<name>, see Custom macaroons. For clightning, create a rune with lightning-cli createrune that allows only the methods that the app needs.

With RTL on lnd, lnd restarts once during the deploy to create RTL’s macaroon.

systemd holds RTL’s port while RTL is stopped

Without netns-isolation, RTL now listens on a unix socket, and systemd holds services.rtl.address and port for it with a socket unit, rtl-proxy-*.socket. rtl-proxy.service forwards each connection to RTL. The SSH tunnel and the onion service work as before. In the tunnel, use the address and port that systemd holds. By default that’s 127.0.0.1:3000, as in Connect to RTL. If you set another address or port, use those, with 127.0.0.1 for 0.0.0.0 and [::1] for ::. With localhost, sshd may connect to [::1]:3000, which systemd doesn’t hold with the default address.

  • services.rtl.address must be a numeric IPv4 or IPv6 address, without brackets and without a zone ID like %lo. A host name like localhost, a zone ID or a socket path now fails the system build with an error that names the address. So if you set a host name or a zone ID, set a numeric IP address like 127.0.0.1.
  • The first switch to this version stops RTL before it starts the socket unit. The port is free in between, and another local user could take it. To avoid this, deploy with nixos-rebuild boot and reboot. After the reboot or a switch, check that systemctl list-units --all 'rtl-proxy-*.socket' shows the socket unit loaded and active. A switch back to an older version has the same gap, and so has a later switch that changes services.rtl.address or port.
  • RTL now ignores PORT and HOST in its environment, also from an EnvironmentFile. Use services.rtl.address and port instead.
  • RTL sees no client addresses through the proxy. So five failed logins from any client lock out all clients for 30 minutes. Before, this applied to all clients on localhost.

Hardware wallet access requires group hardware-wallets

With services.hardware-wallets.ledger or trezor enabled, the Ledger and Trezor devices that its udev rules match are now available only to members of group hardware-wallets (services.hardware-wallets.group). The operator user is in that group. Before, systemd’s 70-uaccess.rules also gave these devices to the user of the active local session, and the Trezor rules added the uaccess tag themselves. The rules now remove that tag. The Ledger rules now match every Ledger device that systemd lists: all of USB vendor 2c97, and the HW.1 and early Nano IDs of vendor 2581. Before, they matched only product 0001, so the group didn’t get other Ledger models and firmware versions. To give another user access, add it to the group:

users.users.<name>.extraGroups = [ "hardware-wallets" ];

A device that’s plugged in while you deploy keeps the session user’s access until you unplug it.

Trezor Bridge runs only on request

The Trezor Bridge (trezord) no longer runs. HWI and trezorctl open the device directly and don’t need it. The bridge couldn’t open the device before, since its user wasn’t in group hardware-wallets. To run it for apps that use it, set:

services.hardware-wallets.trezorBridge = true;

The bridge serves an HTTP API without authentication on 127.0.0.1:21325. Every local user and service can then use the Trezor through it. For example, they can read its public keys while it’s unlocked, which reveals the addresses of its wallets. Signing still needs a confirmation on the device. If you set services.trezord.enable = true yourself instead and don’t give trezord the group, evaluation warns that the bridge can’t open the device.

The secure-node preset turns off SSH password login

The secure-node.nix preset publishes sshd as an onion service. It now also sets services.openssh.settings.PasswordAuthentication and services.openssh.settings.KbdInteractiveAuthentication to false by default, so sshd accepts only keys. Before, the NixOS defaults allowed passwords, and anyone who knew the onion address could try the passwords of your accounts over Tor. This includes the operator, whose groups control your node’s funds. The change also applies to SSH over the node’s IP address, since it’s the same sshd.

Evaluation reports this change for every configuration with the preset and services.openssh.enable. If yours already sets both options to false, like the flakes and Colmena examples, nothing changes.

Otherwise, before deploying, check that each account that logs in over SSH has its key in users.users.<name>.openssh.authorizedKeys.keys. The preset gives the operator the keys of root. Keep a root session or console access until a new login with a key works.

To keep password login, set services.openssh.settings.PasswordAuthentication = true;.

If you log in with keyboard-interactive methods through PAM, for example one-time codes, set KbdInteractiveAuthentication = true and check sshd’s PAM stack. NixOS sets security.pam.services.sshd.unixAuth from PasswordAuthentication, and PAM modules differ in how they depend on it:

  • With googleAuthenticator, NixOS adds the one-time code rule only when unixAuth or services.homed.enable is on. Without systemd-homed, set both options to true.
  • With otpwAuth, unixAuth adds a password rule before the one-time password rule, so a plain password would be enough. Keep PasswordAuthentication = false.

For other modules, check the rules in /etc/pam.d/sshd after you build the system. Either way, test a new login before you close your current session.

If your configuration sets one of these options to true with lib.mkDefault, evaluation fails with “conflicting definition values”, because the preset uses the same priority. Then you don’t see this notice. Set the option without lib.mkDefault instead.

nix-bitcoin-wg-connect needs the node’s address

nix-bitcoin-wg-connect, from the WireGuard preset, now needs the address where your WireGuard client reaches the node. Before, it looked up the node’s public IP when you didn’t pass an address. The lookup queried public IP lookup services over clearnet, which revealed the IP to them, also on a node that otherwise uses only Tor. Without an address, the command now prints a usage message and fails. Pass your node’s public IP or hostname, as described in Set up WireGuard and ZEUS:

nix-bitcoin-wg-connect 93.184.216.34

Scripts that call it without an address need the same change. Existing WireGuard clients keep working.

hardened-extended ignores router advertisements on new interfaces

The hardened-extended.nix preset now sets net.ipv6.conf.default.accept_ra = 0 instead of a sysctl that doesn’t exist. The kernel then ignores IPv6 router advertisements on interfaces that appear after the sysctl settings are applied at boot, which can include your main network interface. dhcpcd and systemd-networkd handle router advertisements themselves, but only on the interfaces they manage. They skip, for example, interfaces with useDHCP = false or a static IPv4 address, all interfaces with networking.dhcpcd.IPv6rs = false, and with systemd-networkd, VLANs, bridges and bonds, because its default networks match only physical interfaces. Evaluation reports this for each config with the preset and IPv6.

If an interface gets its IPv6 address or default route from router advertisements, before deploying, do one of these:

  • Configure the address and route statically, for example with networking.interfaces.<name>.ipv6.addresses and networking.defaultGateway6.
  • Let dhcpcd or systemd-networkd manage the interface: networking.interfaces.<name>.useDHCP = true;.
  • With a static IPv6 address, let dhcpcd solicit router advertisements: networking.dhcpcd.IPv6rs = true;.
  • Keep the previous behavior: boot.kernel.sysctl."net.ipv6.conf.default.accept_ra" = lib.mkForce "1";.

After migrating your configuration, set nix-bitcoin.configVersion = "0.2.0";.

Upgrading to config version 0.1.6

Operator access to Lightning onion addresses

services.lnd.lndconnect.onion and services.clightning.plugins.clnrest.lnconnect.onion now give the operator user access to the lnd-rest and clnrest onion addresses only when nix-bitcoin.operator.enable is set. This matches the access to the other onion addresses. Before, the operator user received this access whenever it existed, for example when nix-bitcoin.operator.name named an existing account and the operator role was disabled. When the operator user didn’t exist at all, the onion-addresses service failed and published no onion address for anyone.

lndconnect isn’t affected. It runs as the lnd user and reads the lnd user’s copy of the address. With the operator role disabled, only lnconnect-clnrest reads the address from the operator user’s directory. nodeinfo reads it too, but it enables the operator role itself. So with clnrest.lnconnect.onion enabled, evaluation fails unless the operator user has clnrest access. If you use it with the operator role disabled, choose one of the following:

  • Enable the operator role. It declares users.users.<operator name> as a normal user and merges into an existing declaration under that attribute, but also adds the operator’s groups and its permission to run commands as service users. Don’t use it if the account is declared under another attribute or comes from outside users.users, since NixOS would then manage it with its defaults:
    nix-bitcoin.operator.enable = true;
    
  • Keep the role disabled and grant only the onion address access:
    nix-bitcoin.onionAddresses.access.<operator name> = [ "clnrest" ];
    
    lnconnect-clnrest also reads the admin rune, which only the clightning group can read. Without the role, run lnconnect-clnrest as root, or add the user to this group:
    users.users.<operator account>.extraGroups = [ "clightning" ];
    
    <operator account> is the users.users attribute that defines the account. It’s usually the operator name. Members of this group can read the admin rune and use the clightning RPC socket, so they have full control over the node.
  • If the operator account is disabled in users.users, enable it and use one of the options above. If it comes from outside users.users, for example from LDAP, and you can’t declare it (see below), set nix-bitcoin.operator.name to an enabled account in users.users and use one of the options above for it, or disable clnrest.lnconnect.onion.

Onion address access requires declared users

nix-bitcoin.onionAddresses.access now accepts only users that are defined and enabled in users.users, and evaluation fails if it names any other user. Before, it also accepted accounts created outside the configuration, for example with useradd or via LDAP, because the onion-addresses service looked the names up at runtime. For each such user, either remove it from nix-bitcoin.onionAddresses.access, or declare the account in users.users. NixOS then manages the account and applies its defaults to anything you leave out, so declare its current settings: isNormalUser or isSystemUser, uid, the primary group and its users.groups entry with the current gid, extraGroups, description, home, homeMode and shell. With users.mutableUsers = false, NixOS also manages the password, so declare it too if the account uses one.

Secret file validation

setup-secrets now fails when a declared secret file is empty or isn’t a regular file, as it does when one is missing. Then services can’t read any secret until setup succeeds. Before deploying, check the secrets dir for empty files, for example with find /etc/nix-bitcoin-secrets -maxdepth 1 -type f -empty:

  • Write the secret to each empty file that a service needs. With nix-bitcoin.generateSecrets = true, setup regenerates empty passwords.
  • Secret generation (nix-bitcoin.generateSecrets = true) doesn’t replace an empty TLS key (lnd-key), WireGuard private key or replication SSH key, or a symlink to a missing file in their place, because a new key breaks the clients that trust the old one. Setup fails and names the file: restore it from a backup, or delete it to generate a new key.
  • For a secret that may be empty, set nix-bitcoin.secrets.<name>.allowEmpty = true. bitcoinix sets it for backup-encryption-env.
  • With the bitcoind-remote.nix preset and nix-bitcoin.generateSecrets = false, the local bitcoin-HMAC-* files are unused, but setup checks them too. Write the HMAC of the matching password to each one: the <salt>$<hmac> part of its rpcauth= line, as printed by Bitcoin Core’s share/rpcauth/rpcauth.py. Or set allowEmpty for them.

lnd seed validation and wallet creation

lnd now stops with an error when wallet.db in lnd’s network dir isn’t a regular file, for example a symlink to a moved or unmounted wallet. Before, lnd tried to create a new wallet there. Restore the wallet, or remove the entry if lnd never ran a wallet from it.

While lnd has no wallet.db, a symlink to a missing file at lnd-seed-mnemonic in lnd’s data dir now stops lnd with an error. An empty lnd-seed-mnemonic, which a failed seed creation of an earlier version could leave, already stopped lnd with an lndinit error. Now the error names the file. In both cases, if lnd never ran a wallet from that seed, delete it, and lnd creates a new seed. Otherwise, restore it from a backup.

lnd now creates its wallet in a temporary directory. Before, a failed wallet creation could leave a partial wallet.db, and lnd then never started: every start skipped wallet creation, and the lnd log shows an lndinit error such as private passphrase may not be empty. If your node is stuck like this and lnd never ran with this wallet, fix the cause, keep lnd-seed-mnemonic in lnd’s data dir, and move the partial wallet aside. lnd then creates the wallet from the same seed. With the default data dir on mainnet:

systemctl stop lnd
mv /var/lib/lnd/chain/bitcoin/mainnet/wallet.db /var/lib/lnd/chain/bitcoin/mainnet/wallet.db.failed
systemctl start lnd

Separate root keys for custom lnd macaroons

Each custom lnd macaroon (services.lnd.macaroons, also used by BTCPay Server and charge-lnd) now has its own root key, with an ID from 7953919891889717248 to 7954201366866427903 (0x6e62000000000000 to 0x6e62ffffffffffff). Each time lnd starts, bitcoinix deletes the root key of every ID in this range that no configured macaroon uses. Before deploying, check that lncli listmacaroonids lists no ID in this range. If it does, bake the macaroons that use such an ID again with an ID outside the range.

bitcoinix now uses lnd’s admin macaroon and gRPC each time lnd starts, also without custom macaroons. Keep lnd’s macaroons enabled: the no-macaroons option isn’t supported.

When lnd restarts during the deployment, bitcoinix creates the custom macaroons with their new root keys. BTCPay Server and charge-lnd read their new macaroons without a restart. Restart other services that read a custom macaroon only at startup; see Custom macaroons. Copies of custom macaroons created before this change use root key 0, like the admin macaroon, and stay valid. To revoke them, see Revoke all macaroons.

Custom lnd macaroon file permissions

Each custom lnd macaroon is now readable only by its user, with mode 0400. Before, the user’s primary group could read it too. For a user like operator, that’s the group users, which normal users get by default. So other normal users could read the macaroon. If other users log in to your node, they could have copied it, and such copies stay valid. To revoke them, see Revoke all macaroons. If a program reads a custom macaroon as another user, through the group, give the program its own macaroon in services.lnd.macaroons.

RTL stops with its backends

RTL is now bound to the units of its enabled backends, lnd for services.rtl.nodes.lnd and clightning for services.rtl.nodes.clightning. It now stops when a backend’s unit stops, crashes or exits, instead of polling the port of a stopped backend, which another local user could take over. A backend’s start starts RTL again once all of RTL’s backends run. Deploying this change restarts each backend that RTL uses once, because its unit changes.

With both backends enabled:

  • Stopping one backend, for example clightning for maintenance, also stops RTL for the other one.
  • Starting RTL starts a stopped backend too. Leave RTL stopped until the maintenance is done. The backend’s own start starts RTL again afterwards.

RTL verifies its backends’ certificates

RTL now checks TLS certificates. A connection to a backend’s address and port must present that backend’s pinned certificate: services.lnd.certPath for lnd, or server.pem in clnrest’s cert dir (clightning’s network dir, or clnrest-certs). Every other HTTPS connection gets the normal certificate and hostname checks against the system CAs. These setups no longer work:

  • LN_SERVER_URL or LND_SERVER_URL in RTL’s environment. RTL doesn’t start.
  • Another URL in Settings.lnServerUrl in services.rtl.nodes.<node>.extraConfig. Evaluation fails.
  • A proxy in RTL’s environment without a no_proxy entry for the backend address. RTL then reaches the backend through the proxy, where it has no pin, and the system CAs don’t trust the backend’s certificate.
  • A server with a self-signed certificate set through extraConfig, for example a swap server. To use it, add its certificate with systemd.services.rtl.environment.NODE_EXTRA_CA_CERTS.

RTL two-factor authentication persists across restarts

RTL now keeps the two-factor authentication (2FA) that you set up in its web interface across restarts. Before, each restart turned 2FA off without a warning. If you lose the authenticator, delete RTL-Config.json in RTL’s data dir (/var/lib/rtl by default) and restart RTL. RTL-Config.json holds the 2FA secret and is now readable only by RTL’s user. Before, members of group rtl could read it too.

Tor enforcement allows only local addresses

Services with Tor enforcement (services.<service>.tor.enforce, set by the secure-node preset and enable-tor.nix), charge-lnd, and custom units that use nix-bitcoin.lib.allowLocalIPAddresses or allowTor have a narrower network restriction:

  • Without network namespace isolation they reach localhost only. With it, they also reach the namespace subnet 169.254.<addressblock>.0/24. To let a service reach a further address, allow it for that service, for example for electrs:
    systemd.services.electrs.serviceConfig.IPAddressAllow = [ "10.10.0.2" ];
    
    With netns-isolation, services with tor.enforce are also limited by the namespace firewall, so IPAddressAllow alone doesn’t widen them there; see that section. charge-lnd and custom units have no tor.enforce and no such namespace firewall, so IPAddressAllow does widen them, with or without netns-isolation.
  • They can’t use the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi). glibc resolves names itself, from /etc/hosts. If a service connects to an allowed address by host name, use the address directly or add the name to networking.hosts.
  • A resolver on 127.0.0.1 or ::1 stays reachable without netns-isolation; see Connecting without Tor or WireGuard for what that means and how to avoid it.
  • netns-isolation no longer accepts addressblock 169 or 170, because those subnets hold cloud metadata addresses. Evaluation fails with a message. Pick another block, and update any addresses you derived from it.

Evaluation reports this change for services with tor.enforce and for charge-lnd, but not for custom units. If one of your units uses allowLocalIPAddresses or allowTor, check it against the points above before you deploy.

After migrating your configuration, set nix-bitcoin.configVersion = "0.1.6";.

Upgrading to config version 0.1.5

Currencyrate, rebalance and mempool’s settings.CORE_RPC.PASSWORD each have a migration notice. Review the changes for each one you use before updating your config version.

Currencyrate plugin replacement

The Python currencyrate plugin has been replaced by Rust cln-currencyrate. Keep services.clightning.plugins.currencyrate.enable = true, but update any custom scripts before deploying:

  • Replace currencyrates <currency> with listcurrencyrates <currency>. The response is now {"currencyrates": [{"source": "…", "amount": 95000.0}, …]}, with amounts in fiat per BTC, replacing the map of source names to msat per fiat unit. Adapt both parsing and units. currencyrate <currency> returns a single median rate in fiat per BTC.
  • currencyconvert still takes amount and currency, for example lightning-cli currencyconvert 10 USD, but its msat result is now a JSON number rather than a string with an msat suffix. The median is now calculated from fiat prices before conversion.
  • Rename add-source and disable-source in services.clightning.extraConfig to currencyrate-add-source and currencyrate-disable-source. Review them against the new plugin’s README. The plugin follows CLN’s configured proxy.

After deploying, check that lightning-cli help currencyconvert and lightning-cli help listcurrencyrates list the new RPCs. A live conversion such as lightning-cli currencyconvert 100 USD also needs reachable price sources.

Rebalance routing changes

The rebalance plugin now uses Core Lightning’s askrene routing. If you enable services.clightning.plugins.rebalance.enable, update custom scripts and configuration before deploying:

  • Remove the getroute_method argument from rebalance RPC calls; it is no longer accepted.
  • Remove rebalance-getroute, rebalance-maxhops and rebalance-msatfactor from services.clightning.extraConfig and any included configuration files. These settings are still accepted with a deprecation warning but are ignored, so they no longer control route selection or hop limits.
  • Update scripts that read rebalancereport: its getroute_method, maxhops_threshold and msatfactor fields have been removed.

mempool RPC password moves to the secrets directory

mempool no longer accepts services.mempool.settings.CORE_RPC.PASSWORD. Its settings are copied to the world-readable Nix store, so evaluation now fails when this option is set. Remove it and save the password to bitcoin-rpcpassword-mempool in the secrets dir. mempool reads it from there at startup, also when it uses bitcoind from another node. Releases before 0.2.0 read bitcoin-rpcpassword-public instead. The old value stays readable in the Nix store until it is garbage-collected, so change the password if untrusted users or services run on the node.

After addressing these changes, set nix-bitcoin.configVersion = "0.1.5";.

Upgrading to config version 0.1.3

Bitcoin Knots support removed

Bitcoin Knots support and the services.bitcoind.package option have been removed. Remove services.bitcoind.package from your configuration, including explicit selections of Bitcoin Core. The daemon, bitcoin-cli and Core Lightning now use nix-bitcoin.pkgs.bitcoind (Bitcoin Core) directly. bitcoind-knots is no longer included in bitcoinix’s pinned packages. If you used Knots, review any Knots-specific settings in services.bitcoind.extraConfig before deploying with Bitcoin Core.

electrs index rebuild

electrs 0.12.0 switched to bindex, which uses a new index format. electrs must rebuild its index from scratch, and it does not convert or delete the old one, so bitcoinix refuses to start electrs while the old index is in place. Reindexing takes from a few hours to about a day, depending on your hardware. The final index is about 7% of the size of bitcoind’s blocks/*.dat files and can temporarily grow to about 14% during the initial sync. electrs accepts connections while it indexes but answers with incomplete history and balances until indexing has finished. The same applies to mempool if it uses electrs as its Electrum server.

To upgrade, delete the old index before deploying (default data dir shown; for regtest, the index is in regtest instead of bitcoin):

systemctl stop electrs && rm -r /var/lib/electrs/bitcoin

Then deploy the new system config to your node and follow the progress with journalctl -u electrs -f.

If you roll back to the previous config after electrs 0.12 has started once, also remove the marker file /var/lib/electrs/bitcoin.bindex. Otherwise the index check is skipped on the next upgrade.

electrs requires Bitcoin Core REST access

electrs 0.12.0 also requires Bitcoin Core 31 or later. It reads blocks through bitcoind’s REST interface, which bitcoinix enables automatically (services.bitcoind.rest.enable). REST is served without authentication on the RPC address and port: every source allowed by services.bitcoind.rpc.allowip can read blocks, transactions, the UTXO set and the mempool, bypassing RPC users and rpcwhitelist. If services.bitcoind.rpc.allowip contains sources other than localhost and bitcoinix’s network namespaces, evaluation fails. Remove them, or set services.bitcoind.rest.allowNonLocal = true to accept unauthenticated REST access for these sources. Evaluation also fails if services.bitcoind.extraConfig contains rpcallowip or includeconf directives: move RPC sources to services.bitcoind.rpc.allowip, or review the raw and included settings and set services.bitcoind.rest.allowUncheckedConfig = true. electrs no longer connects to bitcoind’s whitelisted P2P port.

Service runtime paths become read-only

Services using nix-bitcoin.lib.defaultHardening, including Bitcoin Core, Core Lightning and LND, now see /run and /dev (including /dev/shm) as read-only. Before deploying, review custom service hooks (preStart, postStart, ExecStartPre, ExecStartPost) and plugins that write there: they can now fail with Read-only file system.

The service’s RuntimeDirectory, StateDirectory, configured data directory and existing ReadWritePaths remain writable. Move custom writes into those directories, or add a narrow ReadWritePaths exception for an existing path that must remain writable. See Write to /run or /dev/shm from a service hook for an example. If you have no custom code writing outside the allowed directories, no script changes are needed.

mempool database migration

mempool 3.3 migrates its MariaDB database from schema version 97 to 106 on the first start of the backend. The migration can’t be undone: rolling back the NixOS generation keeps the migrated database, and mempool 3.2 has no downgrade path. The database is not covered by services.backups. To keep a way back, dump it before deploying:

mysqldump --single-transaction mempool > mempool-3.2.sql

Run this as root, and replace mempool if you set services.mempool.database.name.

Secret setup sandbox

setup-secrets now runs in a sandbox whenever nix-bitcoin.setupSecrets is enabled, including when nix-bitcoin.generateSecrets enables it automatically. Before deploying:

  • Replace declared secret symlinks to files outside nix-bitcoin.secretsDir with files inside that directory, preserving their contents. If another tool supplies or rotates these secrets, configure it to install the files there before setup-secrets starts. External targets are read-only or hidden inside the sandbox.
  • Review custom nix-bitcoin.generateSecretsCmds. They have no IP network access and can write only to the secrets directory and private temporary directories. Put final secret files in the secrets directory. Commands requiring writable executable memory (such as JIT compilation) or setuid/setgid file modes are blocked. If generation needs these facilities, arrange to supply all required secrets before setup-secrets, set nix-bitcoin.generateSecrets = false, and keep nix-bitcoin.setupSecrets = true to set the supplied files’ permissions.
  • Remove setuid/setgid bits from any nix-bitcoin.secrets.<name>.permissions values; the sandbox rejects those modes when setting permissions too.

The secrets directory is now root:root 0700 while setup runs even when generateSecrets is false. If any step fails, every service loses access to secrets in that directory until setup succeeds. After fixing the cause reported by journalctl -u setup-secrets, run as root:

systemctl reset-failed setup-secrets
systemctl restart setup-secrets
systemctl start nix-bitcoin-secrets.target

Then restart any dependent services that failed. Successful setup restores the directory to 0751 and applies each declared secret’s configured owner and mode.

After migrating your configuration, set nix-bitcoin.configVersion = "0.1.3";.

Upgrading to config version 0.1.2

bitcoind’s RPC authentication cookie now lives at /run/bitcoind/.cookie for both mainnet and regtest. The runtime directory allows the bitcoind service group to read the cookie while preventing group members from replacing it.

Update external RPC clients and scripts that read /var/lib/bitcoind/.cookie or /var/lib/bitcoind/regtest/.cookie to use /run/bitcoind/.cookie. If you set services.bitcoind.dataDir, the old cookie was under that directory instead. For clients running in containers or filesystem sandboxes, update any bind mounts or allowed paths for cookie access as well.

The bitcoin-cli installed by bitcoinix reads the new path from bitcoin.conf automatically. Services configured by bitcoinix use RPC credentials and need no cookie path changes.

An old cookie can remain in the data directory after an unclean shutdown before the upgrade. Once the upgraded bitcoind is running, that old cookie is stale and can be removed. bitcoind creates a new cookie in /run/bitcoind each time it starts.

mempool backend listen address

The mempool backend now listens on services.mempool.address (default 127.0.0.1) instead of all interfaces. With network namespace isolation enabled, it listens on its namespace address. Access through the nginx frontend is unchanged. If you access the backend API directly from another host, set services.mempool.address to the node’s LAN or VPN address.

MariaDB listens on localhost by default

The MariaDB server enabled by mempool now listens on 127.0.0.1 by default. mempool itself uses MariaDB’s Unix socket and needs no connection changes. If other clients access this database server over the network, explicitly set services.mysql.settings.mysqld.bind-address to the desired listen address. Existing explicit values of this option take precedence over the new default.

LND restarts after a clean exit

LND now restarts automatically after a clean exit, so it can recover after its chain backend health check shuts it down. By default, lncli stop also causes LND to restart after 10 seconds. To keep LND stopped for maintenance, use sudo systemctl stop lnd and update any scripts that relied on lncli stop leaving it down. Start it again with sudo systemctl start lnd when maintenance is complete.

BTCPay Server restricts requests to private networks

BTCPay Server 2.4.5 blocks outbound requests to private network addresses by default to prevent server-side request forgery. This affects webhooks, invoice notification URLs and LNURL requests that point to localhost, LAN or VPN addresses. The Lightning node that bitcoinix configures for BTCPay Server is unaffected. To allow specific private destinations, list them in BTCPay’s ssrfexceptions setting:

systemd.services.btcpayserver.environment.BTCPAY_SSRFEXCEPTIONS = "192.168.1.50:8443;10.8.0.0/24";

Entries are exact hostnames, IP addresses or CIDR ranges, optionally with a port, separated by ; or ,.

Keep each exception as narrow as possible: one address with its port, or the smallest range that covers the destination. Never list the ports of node services such as the LND REST API or the bitcoind RPC. Anyone who can set a webhook, a notification URL or a Lightning address in BTCPay can make it send requests to every listed destination. A hostname entry trusts every address the hostname resolves to, so list only hostnames whose DNS you control.

After updating any affected clients and settings, set nix-bitcoin.configVersion = "0.1.2";.

Upgrading to config version 0.1.1

Liquid support removed

Liquid support has been removed, including the Elements daemon, liquid-swap, and BTCPay Server’s LBTC integration. Liquid peg-outs were suspended after the September 2026 Elements consensus bug (incident assessment).

If you used Liquid, remove services.liquidd, services.btcpayserver.lbtc, and any Liquid-specific onion service or network namespace settings from your configuration.

Upgrading does not delete Liquid data. These files stay on the node:

  • the data directory (default: /var/lib/liquidd), which holds your Liquid wallets
  • the secret liquid-rpcpassword in the secrets directory (default: /etc/nix-bitcoin-secrets)
  • the onion service keys in /var/lib/tor/onion/liquidd, if Liquid had an onion service (the default with the secure-node.nix preset)

The backups service no longer includes the data directory. To keep backing up the wallets without the chain data (as before, unless with-bulk-data was set), add:

services.backups.extraFiles = [
  "- /var/lib/liquidd/*/blocks"
  "- /var/lib/liquidd/*/chainstate"
  "- /var/lib/liquidd/*/indexes"
  "/var/lib/liquidd"
];

To access the wallets later, run upstream Elements Core 23.3.4 or later on a copy of the data directory. Earlier versions, including the elementsd package in nixpkgs 26.05, lack the fix for that bug. Delete the files above once you no longer need them.

netns-exec wrapper removed

The netns-exec wrapper has been removed. Its namespace allowlist had been empty since JoinMarket was removed, so it rejected every namespace. To run a command in a service network namespace, use sudo ip netns exec nb-<service> <command>. If you set nix-bitcoin.netns-isolation.allowedUser, remove it from your configuration.

Lightning Pool and Lightning Loop support removed

Lightning Pool and Lightning Loop support, including RTL’s Loop integration, has also been removed. Remove services.lightning-pool, services.lightning-loop, services.rtl.nodes.lnd.loop, and any Pool- or Loop-specific onion service or network namespace settings from your configuration.

If you still need either service, arrange a separately managed deployment before upgrading. The services stop running after the upgrade, and their packages and CLI wrappers are no longer installed by bitcoinix. Existing data directories (default: /var/lib/lightning-pool and /var/lib/lightning-loop) and Loop secrets (loop-key and loop-cert in the secrets directory) are retained. Keep these files for the separately managed deployment.

Before upgrading, make sure no Loop swap is in progress (loop listswaps). Once a Loop Out has revealed its preimage, its sweep must confirm before the HTLC expires, otherwise the swap amount is lost. Pool account funds stay locked until the account expires; to recover them, run poold with the retained data directory.

BTCPay Server wallet UTXO scanning disabled by default

BTCPay Server’s wallet UTXO scan is now disabled by default. The btcpayserver RPC user no longer has permission to call scantxoutset, because a scan can keep bitcoind busy for minutes. If you use this feature, explicitly restore permission:

services.bitcoind.rpc.users.btcpayserver.rpcwhitelist = [ "scantxoutset" ];

If you do not use wallet UTXO scanning, leave it disabled and acknowledge the change by updating the config version below.

charge-lnd macaroon permissions restricted

The charge-lnd macaroon now grants read access and write access only to UpdateChannelPolicy and UpdateChanStatus. The previous broad offchain:write grant also allowed sending payments and abandoning channels. LND regenerates /run/lnd/charge-lnd.macaroon with the restricted permissions when it restarts during deployment. Regeneration does not revoke old copies: they remain valid with their original permissions. Do not reuse them. If another application used this macaroon, give it a separate macaroon with the permissions it needs via services.lnd.macaroons.

lnconnect-clnrest server certificate corrected

lnconnect-clnrest now includes clnrest’s server certificate (server.pem) in direct connection URLs. Previously it included the mutual-TLS client certificate (client.pem), which did not match the certificate presented by clnrest. Regenerate direct connection URLs and reconnect clients. Tor and WireGuard URLs use --nocert and are unaffected.

c-lightning-REST replaced by clnrest

c-lightning-REST support has been removed because it is no longer maintained. Remove services.clightning-rest (or the legacy services.rtl.cl-rest) and any associated onion service or network namespace settings from your configuration. Use the clnrest plugin for Core Lightning’s REST API:

services.clightning = {
  enable = true;
  plugins.clnrest = {
    enable = true;
    # Optional: connection helper and access via Tor
    lnconnect = {
      enable = true;
      onion = true;
    };
  };
};

clnrest uses runes for authentication instead of c-lightning-REST macaroons and listens on port 3010 by default. Reconnect clients using lnconnect-clnrest instead of lndconnect-clightning, or lnconnect-clnrest-wg instead of lndconnect-clightning-wg with the WireGuard preset. See connecting via Tor and connecting via WireGuard. RTL already uses clnrest and enables it automatically for its Core Lightning node.

Custom API clients must switch to POST /v1/<rpc-method> with JSON parameters and handle native Core Lightning RPC responses. The convenience endpoints getBalance, getFees, and channel/localRemoteBal are gone; calculate their summaries from listfunds, getinfo, and listpeerchannels. The old /v1/ws protocol is also replaced by clnrest’s notification streaming. See the upstream migration guide.

clnrest runs within clightning.service and shares Core Lightning’s network namespace and sandbox. There is no separate REST service or API-specific Tor enforcement setting. services.clightning.tor.enforce applies to both; the WireGuard preset disables enforcement for that service to allow connections over the tunnel.

Swagger documentation is served on the REST API port at /, instead of a separate docPort. If you used extraConfig.DOMAIN for a custom certificate hostname, supply suitable certificates with the clnrest-certs option through services.clightning.extraConfig. When using a custom certificate directory, pass --tlscertpath=/path/to/certs/server.pem to lnconnect-clnrest for direct TLS connection URLs. See the clnrest configuration reference.

The former c-lightning-REST data directory (default: /var/lib/clightning-rest) and onion service keys (/var/lib/tor/onion/clightning-rest, if configured) are retained. The backups service no longer includes the former data directory. To keep backing it up, add its path to services.backups.extraFiles:

services.backups.extraFiles = [ "/var/lib/clightning-rest" ];

By default, clnrest’s certificates and rune are stored in Core Lightning’s network directory and remain covered by the Core Lightning backup.

After migrating your configuration, set nix-bitcoin.configVersion = "0.1.1";.

Upgrading to config version 0.1.0

Lightning REST APIs listen on localhost by default

When using lndconnect or lnconnect without Tor, explicitly set the REST listen address for LAN or VPN access. It now defaults to localhost. See Connecting without Tor or WireGuard.

After migrating your configuration, set nix-bitcoin.configVersion = "0.1.0";.

Release notes

For configuration migrations reported during evaluation, follow the upgrading guide.

During development, each change has its own file under docs/release-notes/<version>/. At release time, the draft files are combined into docs/release-notes/<version>.md. See Cutting a release.

Versions

Release notes 0.2.1

bitcoind data dir no longer writable by its group

The bitcoind data dir now has mode 0750 instead of 0770, like the Core Lightning data dir. Members of the bitcoind group, like the operator user, can still use bitcoin-cli and read the files they could read before, but they can’t write to the data dir. See Upgrading to config version 0.2.1.

Root runs CLI commands as the service user

bitcoin-cli now reads the config that bitcoinix generates from the Nix store, and not the copy in the data dir. When root runs bitcoin-cli, it runs as the bitcoin user. With the bitcoind-remote.nix preset, the credentials for the remote node are now in /run/bitcoind/.cookie and not in bitcoin.conf.

When root runs lightning-cli or lnconnect-clnrest, they run as the clightning user, like lncli runs as the lnd user. With services.clightning.plugins.clnrest.lnconnect.onion, the clightning user gets its own copy of the clnrest onion address for this. The option no longer needs the operator role or explicit onion access for the operator user. The operator user needs this access only to run lnconnect-clnrest as itself. lnconnect-clnrest reads the admin rune and clnrest’s cert only from regular files of the clightning user, also when the operator runs it.

So as root, these commands can’t read a file that only root can read, for example a file that you pass to bitcoin-cli -rpccookiefile.

Core Lightning replication dirs no longer writable by its group

With services.clightning.replication, the local replica dir (with local.setupDirectory) and /var/cache/clightning-replication (with sshfs.destination or encrypt) now have mode 0750 instead of 0770, like the Core Lightning data dir. Members of the clightning group, like the operator user, can still read them, but only clightning writes there. See Upgrading to config version 0.2.1.

Core Lightning wallet setting is world-readable

bitcoinix writes services.clightning.wallet into clightning’s config file in the Nix store, which every local user can read. The option’s description now says so. If your setting holds a PostgreSQL connection string with a password, change that password and use a connection that doesn’t put it in the setting.

lnd’s REST onion service forwards to a Unix socket

With services.lnd.lndconnect.onion, lnd also serves REST on the Unix socket /run/lnd-rest/rest.sock, and the lnd-rest onion service forwards to this socket instead of lnd’s REST port. Only lnd can create the socket, so the onion service reaches only lnd, also while lnd restarts. Only lnd and Tor can open the socket’s directory. The directory is mounted on itself with nosymfollow, so Tor doesn’t follow symlinks in it. Tor starts only after this mount, and the mount fails to start if the directory is missing. lnd stops or restarts with the mount, before it. The onion address and port stay the same, so wallets don’t need to pair again. lnd keeps listening on services.lnd.restAddress for RTL and local clients.

netns-isolation keeps other local users off service ports

Without netns-isolation, clnrest, electrs and Fulcrum listen on the host’s loopback address. While one of them is down, for example during a restart or an update, another local user can listen on its port and receive the clnrest rune from ZEUS or a wallet’s addresses through the onion service. The docs now explain this on the ZEUS and electrs and Fulcrum pages and under network namespace isolation, which prevents it. lnd’s onion service forwards to a Unix socket and isn’t affected. The WireGuard preset and direct REST connections can’t use netns-isolation, so the ZEUS page recommends not to give untrusted users an account on such a node.

lndconnect and lnconnect-clnrest need the onion address

With services.lnd.lndconnect.onion or services.clightning.plugins.clnrest.lnconnect.onion, lndconnect and lnconnect-clnrest now fail when they can’t read the onion address, for example while Tor still starts or when the user has no access to it (nix-bitcoin.onionAddresses.access). Before, they asked public services for the node’s IP over clearnet and printed a URL with that IP and the admin macaroon or rune. A --host argument still replaces the onion address, and an empty --host is now an error. With onion, --localhost and --localip only worked together with an empty --host or while the onion address was missing. For a local URL, pass --host 127.0.0.1 or --host with the node’s LAN IP.

netns-isolation forwards only namespace traffic

With netns-isolation, the host forwarded traffic between all its interfaces. So on a node with a LAN and a VPN, or with two LANs, a host on one side could reach the other side through the node. Now the host forwards only the connections that the service namespaces open and their replies, and drops all other forwarded IPv4 traffic. The new option nix-bitcoin.netns-isolation.restrictForwarding turns this off. Evaluation fails while networking.nat, Docker or another module turns on net.ipv4.conf.all.forwarding, until you set the option to false. See Upgrading to config version 0.2.1.

netns-isolation rejects an nftables ruleset flush

With networking.nftables and iptables-nft, netns-isolation now fails evaluation when networking.nftables.flushRuleset is on, or when networking.nftables.tables has a table that iptables-nft uses, like ip nat, ip filter or ip mangle. The flush deleted the NAT rule of the namespace bridge, the forwarding rules of nb-netns-forward and the host firewall, and such a table replaced the iptables table of the same name. Without the NAT rule, the namespaces couldn’t reach anything beyond the host. Without the forwarding rules, the host forwarded traffic between all its interfaces. Without the mangle tables, the host firewall didn’t check the reverse path. NixOS turns the flush on by default when networking.nftables.ruleset or rulesetFile is set or system.stateVersion is older than 23.11. A firewall that runs pkgs.iptables-legacy as networking.firewall.package is exempt. The first deploy after such a fix still runs the old deletions once. See Upgrading to config version 0.2.1.

nb-netns-bridge now also stops and starts again when its NAT rule is gone. Before, the stop failed and left the bridge behind, so the next start failed too. Now a start deletes such a bridge, which still has its address. When another link has the name nb-br, the start fails and leaves that link alone.

dhcpcd 10.5.2

The nixpkgs update brings dhcpcd 10.5.2, the default DHCP client of NixOS, which fixes CVE-2026-56113, CVE-2026-56114, CVE-2026-56116 and CVE-2026-56117. Nodes whose system uses bitcoinix’s nixpkgs, like the deployment examples, get it with this release; other nodes get it once their own nixpkgs has it. See Upgrading to config version 0.2.1.

.NET 10.0.15 for BTCPay Server and NBXplorer

The nixpkgs update moves BTCPay Server and NBXplorer to the .NET 10.0.15 runtime, a security release that fixes several ASP.NET Core denial of service, elevation of privilege and information disclosure vulnerabilities. NBXplorer is updated from 2.6.17 to 2.6.23, which fixes Postgres startup retries and an indexer that could hang after an error.

Other package updates

The nixpkgs update also brings these updates to nodes whose system uses bitcoinix’s nixpkgs. nginx 1.30.8 fixes CVE-2026-132779, excessive CPU use with the ssl_early_data directive. bitcoinix doesn’t set it; check your own nginx configuration. rsync 3.5.2 fixes CVE-2026-119741, a denial of service against an rsync sender, such as a public rsync daemon. The security fix of OpenSSH 10.6p2 concerns only systems with musl and without PAM, not NixOS.

Cashu mint service

The optional services.cdk-mintd service runs a Cashu mint using nixpkgs’ cashu-cdk package. Select local LND or Core Lightning for Lightning payments; on-chain payments through a separate BDK wallet and Bitcoin Core are opt-in. The module includes secret generation, systemd hardening, namespace isolation and Tor onion access. With services.backups, it also stages consistent mint data and signing secrets while the mint is stopped. Pending starts wait for staging to finish; explicit stops of the mint or its backends during shutdown or staging take precedence over the backup’s pending restart. A persistent initialization guard prevents recreating a lost database with the old signing seed; restoration requires the spent-proof state as well as the seed. See Run a Cashu mint for setup and recovery.

Orchard Cashu mint dashboard

Add cashu-orchard 1.12.1 and the optional services.orchard service for the local CDK mint. It provides mint analytics and management with a separate service account, read-only database access and mutually authenticated TLS for CDK’s management RPC. Localhost access, onion services and network namespace isolation are supported. The Tor preset also proxies external dashboard, AI and Telegram requests. With the proxy enabled, public URL and TCP port checks resolve hostnames through Tor and reject private destinations without falling back to local DNS or direct connections. Public icon fetches stay on the proxy even for local-looking names. Alternative loopback mint addresses and IPv6 Tor SOCKS listeners are supported.

AI is off by default. The server enforces this switch for inference, scheduled agents, Telegram conversations and agent tools. Turning AI off blocks new work; provider requests already in flight may finish. Active schedules resume when AI is enabled again. See the Orchard guide for setup, AI data sharing and recovery.

IPv6 addresses for LND RPC

services.lnd.rpcAddress accepts IPv6 addresses with or without brackets. LND, lncli, macaroon creation, charge-lnd and Unbeholden LNURL use the same gRPC endpoint, including when the certificate names a wildcard address. Empty hosts, addresses containing whitespace, and malformed brackets fail evaluation. Upgrading a node with an empty RPC host

IPv6 addresses in service URLs

When a service listens on an IPv6 address, the URLs and endpoints that bitcoinix gives other services to reach it now put the address in brackets. For example, with services.clightning.plugins.clnrest.address = "::1", RTL’s backend URL is now https://[::1]:3010 instead of https://::1:3010. This applies to RTL, Unbeholden LNURL’s clnrest URL, mempool’s nginx backend, BTCPay Server’s NBXplorer and bitcoind endpoints, bitcoind’s I2P SAM address and the addresses that nodeinfo shows.

Services stop when their public address command fails

bitcoind, lnd and clightning now run getPublicAddressCmd before they write their config, and fail to start when the command fails or prints nothing. The journal then shows the error of the command, or that it printed no address.

With a public onion service, this happens when the onion-addresses service can’t read the onion address of the service. The services also failed then before, but later and with an error that didn’t name the missing address. bitcoind failed with Cannot resolve -externalip address: '' and clightning with Cannot use wildcard address. lnd opened its wallet and then failed with unable to encode IP <nil>.

A custom command that printed an address and then failed worked before. It now stops the service.

Operator commands with sudo-rs

With security.sudo-rs.enable, the operator user can now run commands as the users in nix-bitcoin.operator.allowRunAsUsers, like with sudo and doas. Before, the rule went only to sudo and doas, so lncli and lndconnect, which switch to the lnd user with sudo -u, failed for the operator.

bitcoind-remote preset rejects netns-isolation

The bitcoind-remote.nix preset now fails evaluation together with nix-bitcoin.netns-isolation.enable. The docs already said that the two don’t work together.

Service guides on their own pages

The service guide is split into one page per service, listed under Services. Links to sections of the old page lead to the new pages.

Release notes 0.2.0

Unstable NixOS base

bitcoinix now uses a single nixpkgs input tracking nixos-unstable for its system and packages. nix-bitcoin.useVersionLockedPkgs defaults to true. Review the 0.2.0 migration guide for the system input, package customization, reverse-path filtering, FUSE, I2P validation and systemd-nspawn changes. Non-flake module imports, disabling version-locked packages, or overriding bitcoinix’s nixpkgs input now also move the formerly separately pinned unstable service packages with the caller’s nixpkgs.

PostgreSQL 14 removed

nixos-unstable has removed PostgreSQL 14. Nodes that still use PostgreSQL 14, such as for BTCPay Server, fail evaluation. By default, this applies to a system.stateVersion from 22.05 through 23.05. Upgrade the databases before you update bitcoinix, see the upgrade notes.

Unversioned PostgreSQL package moves to 18

nixos-unstable’s pkgs.postgresql has moved from PostgreSQL 17 to 18. If you set services.postgresql.package = pkgs.postgresql; and run PostgreSQL 17, set pkgs.postgresql_17 before you update, see the upgrade notes.

Package selection cleanup

The generated pkgs/pinned.nix file has been removed. Package selection and local overrides now live together in pkgs/default.nix; the public legacyPackages.<system>.pinned paths remain available. The deployment shell and package imports without an explicit pkgs still read the lock file through pkgs/nixpkgs-pinned.nix; non-flake NixOS module imports use the system’s pkgs.

Package updates

  • CLBOSS 0.17.2 → 0.17.3. It pays a swap invoice only when it matches the swap that it requested. A swap started by one version can’t be claimed by the other: it ends at its timeout and the payment fails back to the node. Finish active swaps before you update or roll back. On mainnet, CLBOSS makes no swaps, because its swap provider suspended them on 2026-08-03.
  • electrs 0.12.0 → 0.12.1
  • charge-lnd 0.3.1 → 0.3.2
  • HWI 3.1.0 → 3.2.0
  • extra-container 0.17 → 1.0.1 in the deployment shell. Containers that you build with its extra-container command no longer reach the host’s Nix daemon, see extra-container 1.0.1.
  • nginx 1.30.6 → 1.30.7, which fixes nine CVEs, see the nginx changelog. A default node isn’t exposed: nginx serves only the mempool frontend, over plain HTTP on a local address, without alias. Check your own nginx configuration against the list.

Electrs uses the unmodified nixpkgs package

Nixpkgs now supplies electrs’ pkg-config and zstd build inputs, so the local override is no longer needed.

TrustedCoin initialization

The pinned TrustedCoin package applies two patches from the upstream startup fix to prevent initialization races and reporting height zero without a block source.

krops 1.31.1

The krops deployment uses krops 1.31.1 instead of 1.26.2 (see the changelog). The commands of the deployment shell don’t change. Behavior changes for existing deployments:

  • Names of extraSources may contain only letters, digits and ._-, must not start with - and must not be ., .. or .populate. Other names, e.g. "nixos/networking.nix", fail evaluation.
  • If the node has /etc/nixos/flake.nix, krops runs nixos-rebuild with --no-flake and deploys the synced configuration in /var/src.
  • If a source’s path on the node, e.g. /var/src/secrets, is a symlink, krops removes the symlink and syncs to that path instead of into the symlink’s target. If you linked /var/src/secrets to an encrypted volume, mount the volume at /var/src/secrets instead before you deploy. Otherwise krops writes your secrets to the file system of /var/src.
  • krops 1.31 pipes nixos-rebuild through nix-output-monitor if it’s installed on the node. The deployment then reports success even if evaluation or activation failed. bitcoinix’s krops therefore defaults useNixOutputMonitor of writeDeploy to false, which keeps the previous output and exit status.
  • krops reuses one SSH connection per deployment. bitcoinix patches krops to keep the connection’s socket in /tmp, because the upstream path is too long for macOS or for an onion host, which made the deployment fail.

Deploying from macOS failed on the symlinks in nixpkgs and bitcoinix (nixpkgs#180046). examples/krops/sources.nix now excludes all of them. If you deploy from macOS, copy the filters of its nixpkgs and nix-bitcoin sources into your krops/sources.nix.

CI now deploys the krops example to a VM.

Migration warnings on master

Unreleased configuration migrations now warn without blocking deployment or requiring acknowledgement. Users following master must review them before deploying; warnings cannot be acknowledged individually and repeat while applicable. A configVersion newer than the latest finalized release is rejected. Finalizing the release makes its notices blocking errors until acknowledged. See the upgrading guide for the version policy.

Signet and testnet4

Set services.bitcoind.network to "signet" or "testnet4" to deploy on a public test network. Evaluation reports incompatible services and plugins before deployment. Switching an existing node in place reuses several service databases. Read the network-switch warning before changing this option.

New LND regtest wallets are initialized with regtest chain parameters.

Unbeholden LNURL service

Unbeholden LNURL v0.4.0 now has a native package and service for LND and Core Lightning. It supports Lightning Addresses, withdrawal vouchers, ntfy notifications and Nostr zaps, with restricted node credentials and persistent keys.

Unbeholden Wallet behind a remote proxy

Unbeholden Wallet only accepted connections from localhost, so address = "0.0.0.0" alone didn’t let a reverse proxy on another host reach it. List the proxy’s address in the new services.unbeholden-wallet.allowedClients option, see Access from another device.

Module options and documentation of each release

The new module options page lists the options of the bitcoinix modules with their types, defaults and examples, and can be filtered. It replaces the search.nixos.org links, which mixed in options of other flakes. docs.bitcoinix.net serves the latest release at its root, as before, and keeps the documentation of each release from 0.1.6 on at /v/<version>/, for example https://docs.bitcoinix.net/v/0.1.6/. A selector in the menu bar switches between releases.

Migrate from nix-bitcoin guide

The new Migrate from nix-bitcoin page describes how to switch a nix-bitcoin node to bitcoinix: the release pin, the move to NixOS unstable, removed services and the configuration migrations from nix-bitcoin’s configVersion on.

Bitcoin network selection

Select the Bitcoin network with services.bitcoind.network instead of services.bitcoind.regtest. The makeNetworkName helper is replaced by nix-bitcoin.lib.networkName, which accepts name overrides and passes other network names through unchanged. See the migration instructions for selecting a network and overriding network names.

Regtest onion target port

The regtest onion service now forwards to port 18445 by default, matching Bitcoin Core. See the upgrade note if you maintain a custom Tor mapping.

Mempool regtest support

Mempool’s backend and frontend now follow services.bitcoind.network, including regtest. See the 0.2.0 upgrade notes for existing regtest deployments and custom frontend settings.

Group read access to new bitcoind block files

With services.bitcoind.dataDirReadableByGroup, the bitcoind group can now read the block files and block index files that bitcoind creates while it runs. Before, the group could read only the files that existed when bitcoind started, and none on regtest. Before each start of bitcoind, the new bitcoind-group-read service sets a default ACL on the blocks dir. This needs POSIX ACL support on the filesystem of the blocks dir. Without it, the service logs a warning, and bitcoind still starts. Where the blocks dir, the files in it or the dirs above it already have an ACL, the service adds the group’s rights to it, and all other users and groups keep their effective rights. Before, such an ACL could keep the group out and give the others more rights. If the blocks dir is a symlink, the group can’t read new block files anymore. The services.bitcoind.sysperms option has been removed, because Bitcoin Core ignores it. See the upgrade notes on a symlinked blocks dir and the removed option.

Custom RPC users’ password HMACs are in the Nix store

The passwordHMAC of each custom RPC user in services.bitcoind.rpc.users is written to the world-readable Nix store. Any local user can read it and test password guesses offline. This isn’t new, but it wasn’t documented. If a custom RPC user has a weak password, replace it with a long random one. See Allow bitcoind RPC connections from LAN.

Own RPC users for Core Lightning and mempool

Core Lightning and mempool added getblockfrompeer and gettxoutsetinfo to the whitelist of the shared public RPC user, so every other service of that user could call them too. They now connect to bitcoind as their own users, clightning and mempool, and the public user keeps the base whitelist. Setups that supply secrets themselves need the secrets of the new users, and setups with bitcoind on another node also need the users there, see the upgrade notes.

Backups leave out the Lightning channel databases

The backups service copied the channel databases of lnd and Core Lightning while the daemons wrote them. Such a copy can be torn, and a node that runs from an outdated copy can lose all funds in its channels. The backup now leaves these databases out. It still has the files that recovery needs: the lnd seed and channel.backup, and Core Lightning’s hsm_secret and emergency.recover. See Backups and the upgrade notes.

Backups include consistent copies of bitcoind wallets

Before each backup, the new bitcoind-wallet-backup unit asks bitcoind for a copy of each loaded wallet in /var/lib/bitcoind/wallet-backups. A copy of the wallet file itself can be torn, because bitcoind writes it while the backup runs. If a copy fails, or bitcoind is starting or stopping, the duplicity unit fails after the backup. See bitcoind wallets and the upgrade notes.

Backup password and migrated lnd seed

With nix-bitcoin.generateSecrets, the backups include the password that decrypts them, backup-encryption-password in the secrets dir. Keep a copy of it off the node. If you migrated lnd from another node, the lnd-seed-mnemonic on the node may not hold the seed of your wallet. See Migrate existing services to bitcoinix.

Core Lightning data dir no longer writable by its group

The Core Lightning data dir now has mode 0750 instead of 0770. Before, members of the clightning group could write to it. So they could replace the config that lightningd loads, or the network dir with hsm_secret. Group members keep the RPC socket, which gives full control over the node. See Upgrading to config version 0.2.0.

clightning requires the mount of its local replica

With services.clightning.replication.local.directory, clightning now doesn’t start while the disk or share under that directory isn’t mounted. Before, it wrote the replica to the filesystem below the mount point, usually the primary disk, without a warning. This works only for mounts that systemd knows, like fileSystems entries. See Upgrading to config version 0.2.0.

lnconnect-clnrest finds clnrest’s certificate in a custom dir

lnconnect-clnrest now asks clightning for clnrest’s cert dir, like RTL does. Before, it always read server.pem from clightning’s network dir. So with clnrest-certs set, it failed or put the wrong certificate into direct connection URLs. Regenerate such URLs. When clightning doesn’t answer, for example because it’s stopped, lnconnect-clnrest prints a warning and uses the network dir, as before.

bitcoinix creates the BTCPay Server admin account

BTCPay Server makes the first account that registers the server admin, so any local user could take the admin account and the internal Lightning node until you registered. When BTCPay Server has no admin, bitcoinix now creates the admin account admin@localhost first, with the password in $secretsDir/btcpayserver-admin-password. Existing admins stay, so check that they’re yours. See the upgrade notes.

BTCPay Server’s access to the Lightning node

With services.btcpayserver.lightningBackend = "clightning", BTCPay Server has full control of the Lightning node, including its funds. With lnd, it gets a restricted macaroon. See Lightning backend.

NBXplorer RPC password permissions

BTCPay Server can no longer read NBXplorer’s bitcoind RPC password. Only NBXplorer’s user can read it now. Before, BTCPay Server could read it through the group that gives it NBXplorer’s API cookie. See Upgrading to config version 0.2.0.

Charge-LND credential paths

Charge-LND reads its certificate and macaroon directly, without staging them under a synthetic mainnet directory. Users selecting custom credentials with --lnddir should follow the 0.2.0 upgrade notes.

RTL gets its own lnd macaroon and clightning rune

RTL used lnd’s admin macaroon and clnrest’s admin rune. Now it gets a macaroon (services.lnd.macaroons.rtl) that allows only the lnd RPCs that it calls, and a rune that allows only the clightning methods that it calls. RTL can still send funds and open and close channels, but it can’t bake macaroons, create runes, stop lnd, delete lnd’s payment history or use lnd’s signer RPCs. The macaroon’s permissions for the RPCs of invoicesrpc and walletrpc use the new option services.lnd.macaroons.<name>.optionalPermissions, so RTL also starts with an lnd package that lacks these build tags. bitcoinix creates the rune once, at rtl-rune in clightning’s network dir. When an update changes the methods that RTL needs, RTL’s start creates a new rune and revokes the old one. RTL’s start replaces its copies of the admin credentials, or removes the copy of a backend that RTL doesn’t use. The admin macaroon and the admin rune themselves stay valid. See RTL’s backend credentials. An app that reads RTL’s copies needs its own credentials now, see the upgrade notes.

systemd holds RTL’s port while RTL is stopped

Without netns-isolation, any local user could take RTL’s port while RTL was stopped, for example during maintenance of lnd or clightning, and collect the RTL password with a fake login page. RTL now listens on a unix socket, and systemd holds services.rtl.address and port from boot on with a socket unit, rtl-proxy-*.socket. rtl-proxy.service forwards each connection to RTL. The address must be a numeric IP address without a zone ID, or the system build fails. All clients now share RTL’s login lockout. The first switch to this version leaves the port free for a moment. With netns-isolation, RTL listens on its namespace’s address as before. See Upgrading to config version 0.2.0.

The secure-node preset turns off SSH password login

The secure-node.nix preset now turns off SSH password and keyboard-interactive login by default, so its sshd onion service accepts only keys. See Upgrading to config version 0.2.0.

hardened-extended ignores router advertisements on new interfaces

The hardened-extended.nix preset set net.ipv6.default.accept_ra, which doesn’t exist, so it had no effect. It now sets net.ipv6.conf.default.accept_ra = 0, so the kernel ignores IPv6 router advertisements on interfaces that appear after the sysctl settings are applied at boot. Interfaces on which dhcpcd or systemd-networkd handle router advertisements are unaffected. Others, for example a VLAN with useDHCP = false or any interface with networking.dhcpcd.IPv6rs = false, no longer get an IPv6 address or default route from router advertisements. A migration notice lists the options, see the upgrade notes.

Hardware wallet access requires group hardware-wallets

The Ledger and Trezor udev rules of services.hardware-wallets no longer let the user of the active local session use the device, so only members of group hardware-wallets can use it. The Ledger rule now matches every Ledger device, not only product 0001. See Upgrading to config version 0.2.0.

Trezor Bridge runs only on request

The Trezor Bridge (trezord) no longer runs by default. services.hardware-wallets.trezorBridge turns it on, and then every local user can use the device through it. See Upgrading to config version 0.2.0.

nix-bitcoin-wg-connect no longer looks up the public IP

nix-bitcoin-wg-connect from the WireGuard preset now needs your node’s address as an argument. Before, it looked up the public IP through public IP lookup services over clearnet when you passed no address. See Upgrading to config version 0.2.0.

Release notes 0.1.6

Tor enforcement allows only local addresses

Services with tor.enforce and charge-lnd could reach every link-local address 169.254.0.0/16, including a cloud provider’s metadata service, and could resolve names through the host’s resolver sockets, outside the Tor-only restriction. They now reach only localhost and, with netns-isolation, the namespace subnet, and can’t use the nscd, systemd-resolved, D-Bus and Avahi sockets. netns-isolation rejects addressblock 169 and 170. Setups that connect such a service to a non-local address or by host name need a change, see the upgrade notes. See advisory GHSA-cgh8-4w2p-8fr8.

Unbeholden Wallet service

New service: Unbeholden Wallet, a watch-only wallet that runs in the browser and hands transactions to an air-gapped signer over QR codes. Enable it with services.unbeholden-wallet.enable = true;. It connects to electrs, or to Fulcrum with services.unbeholden-wallet.electrumServer = "fulcrum".

RTL package moves to nixpkgs

RTL now uses the nixpkgs package. Replace explicit flake references to packages.<system>.rtl or legacyPackages.<system>.rtl with legacyPackages.<system>.pinned.rtl. For example, build it with nix build '.#legacyPackages.aarch64-linux.pinned.rtl' (or x86_64-linux). The service still uses nix-bitcoin.pkgs.rtl automatically.

TrustedCoin package moves to nixpkgs

TrustedCoin now uses the nixpkgs package. Replace explicit flake references to packages.<system>.trustedcoin or legacyPackages.<system>.trustedcoin with legacyPackages.<system>.pinned.trustedcoin. For example, build it with nix build '.#legacyPackages.aarch64-linux.pinned.trustedcoin' (or x86_64-linux). The plugin still uses nix-bitcoin.pkgs.trustedcoin automatically.

Trezor uses the unmodified nixpkgs-unstable package

Trezor now uses the unmodified nixpkgs-unstable package. Replace explicit package references to nix-bitcoin.pkgs.pyPkgs.nbPython3PackagesWithUnlockedEcdsa.trezor with nix-bitcoin.pkgs.nbPython3Packages.trezor. The services.hardware-wallets.trezor option selects it automatically; trezorctl remains available. HWI retains its separate ECDSA exception.

Lightning Python packages move to nixpkgs-unstable

nbPython3Packages now uses nixpkgs-unstable’s Python interpreter and package set, including pyln-bolt7, pyln-client, pyln-proto and pylightning. Their versions are selected by nixpkgs-unstable independently of the Core Lightning daemon. In custom configurations, build Python environments with the matching interpreter, for example:

config.nix-bitcoin.pkgs.nbPython3Packages.python.withPackages (ps: [ ps.pyln-client ])

The built-in Python plugins select this interpreter automatically. The package paths under nbPython3Packages remain available.

Secret validation and lnd wallet creation

setup-secrets now fails when a declared secret file is empty or isn’t a regular file. Set nix-bitcoin.secrets.<name>.allowEmpty = true for a secret that may be empty. Secret generation now fails when a TLS, WireGuard or replication SSH private key is empty, and it doesn’t replace the key. lnd now stops when wallet.db isn’t a regular file, for example a symlink to a missing file. While lnd has no wallet yet, it also stops when its seed file is a symlink to a missing file, and its error for an empty seed file names the file. lnd now creates its seed and wallet through temporary files, so a failed wallet creation no longer leaves a partial wallet.db that blocks later starts.

Separate root keys for custom lnd macaroons

Each custom lnd macaroon (services.lnd.macaroons, used by BTCPay Server and charge-lnd) now has its own root key. You can revoke one of them, and the other macaroons and lnd’s admin macaroon stay valid. The revocation needs an lnd restart. When you change or remove a macaroon, its old copies stop working when lnd restarts during the deployment. Copies made before 0.1.6 use root key 0 and stay valid until you revoke all macaroons. See Custom macaroons.

Custom lnd macaroon file permissions

A custom lnd macaroon is now readable only by its user. Before, the user’s primary group could read it too. For a user like operator, that’s the group users, which normal users get by default. So other normal users could read the macaroon.

RTL stops with its backends

RTL now stops when lnd or clightning stops, crashes or exits. Before, it kept sending their admin credentials to the port of a stopped backend. A backend’s start starts RTL again, and with both backends enabled, both must run.

RTL verifies its backends’ certificates

RTL now checks TLS certificates. Before, it sent the lnd admin macaroon and the clightning admin rune to any server on a backend’s port. RTL has no option for this, so bitcoinix loads a small Node module into RTL. A connection to a backend must present the backend’s pinned certificate: services.lnd.certPath for lnd, or clnrest’s server.pem. Other HTTPS connections get the normal checks against the system CAs. See Upgrading to config version 0.1.6 for what no longer works.

RTL two-factor authentication persists across restarts

Two-factor authentication set up in the RTL web interface now survives restarts. Each start still resets the other web interface settings in RTL-Config.json to the Nix configuration. RTL-Config.json is now readable only by RTL’s user. To turn 2FA off without the authenticator, see Connect to RTL.

Onion address access for the operator and declared users

services.lnd.lndconnect.onion and services.clightning.plugins.clnrest.lnconnect.onion now give the operator user access to the lnd-rest and clnrest onion addresses only when nix-bitcoin.operator.enable is set. Before, a missing operator user made the onion-addresses service fail, and no onion address was published. nix-bitcoin.onionAddresses.access now accepts only users that are defined and enabled in users.users. See the upgrade notes on operator access and declared users.

Backups fail when a database dump fails

With services.backups, a failed PostgreSQL dump now fails the duplicity unit. Before, the backup succeeded without the database. The other files are still backed up in that run. The backup now also includes the BTCPay Server and NBXplorer dumps when services.postgresqlBackup.compression is zstd or none. Before, it silently left them out with these settings, so take a new backup if you use one of them. systemctl start duplicity now blocks until the backup finishes.

netns-isolation: no masquerading within the bridge, MPTCP setting

With br_netfilter loaded, which Docker does, a netns-isolated service without tor.enforce could reach the listeners of namespaces it isn’t connected to. Traffic between namespaces is no longer masqueraded, which closes this. The service namespaces now also copy the host’s net.mptcp.enabled when they are created, so the MPTCP setting of presets/hardened-extended.nix reaches netns-isolated services. Upgrading restarts every netns-isolated service once.

Root scripts ignore config files in a service user’s home

Service scripts that run as root no longer load configuration files from the service user’s home directory. Before, the lnd user could make root’s curl and jq load ~/.curlrc and ~/.jq from lnd’s data directory. See advisory GHSA-cwmc-wjvh-3qp6.

WireGuard preset checks the firewall setup

presets/wireguard.nix now fails evaluation for firewall setups in which its rules can’t run or don’t stay loaded: the nftables firewall package without iptables, networking.nftables.flushRuleset, and an ip or ip6 table named filter in networking.nftables.tables. The messages say what to change.

lnd announces its onion address with the port Tor forwards

With a public lnd onion service and a services.lnd.port other than 9735, lnd announced <onion>:9735, and peers couldn’t reach the node over Tor. It now announces the port that Tor forwards.

clnrest regenerates a broken admin rune

A failed createrune on clightning’s first start could install an empty or null clnrest admin rune that later starts kept. Such a rune is now replaced on start, and a failed createrune fails the start. Generate connection URLs from lnconnect-clnrest again if they were created with a broken rune.

btcpayserver with a custom clightning group

With lightningBackend = "clightning", the btcpayserver user now joins services.clightning.group. Before, it joined a group named after services.clightning.user and couldn’t open the RPC socket when the two differed.

nodeinfo shows the bitcoinix revision and service versions

nodeinfo now prints the bitcoinix commit in a bitcoinix entry and the package version of each service. nodeinfo --version prints only the revision, and nodeinfo NAME ... only the given entries. Because the revision is part of the script, every bitcoinix update now produces a new system generation. Set nix-bitcoin.revision = null; to opt out. See nodeinfo.

extra-container 1.0.1

The flake’s extra-container input moves from 0.17 to 1.0.1. This release has a breaking change: containers can no longer reach the host’s Nix daemon socket by default, so nix build, nix run, nix develop and nix-shell fail inside a container. This affects containers built with this input, for example with examples/container. extra.hostNixDaemon = true; restores the old behavior. Read the security section of the extra-container README first.

Package updates

  • lnd 0.21.6-beta → 0.21.8-beta (release notes). A bug-fix release without database migrations. lnd now rejects a new channel that negotiates a CSV delay of zero.
  • RTL 0.15.16 → 0.15.17 (release notes). Fixes login problems and accepts 2FA codes when the server clock is slightly off.

See also Upgrading to config version 0.1.6.

Release notes 0.1.5

clnrest package attribute renamed

The clnrest package has moved from nix-bitcoin.pkgs.clnrest to nix-bitcoin.pkgs.clightning-plugins.clnrest. Update explicit package references in custom configurations and scripts. For flake builds, use '.#packages.aarch64-linux.clightning-plugins/clnrest' (or x86_64-linux) instead of '.#packages.aarch64-linux.clnrest'. The default package is selected automatically, including when RTL enables clnrest. If you have no custom package references, this rename requires no manual changes.

For this release’s configuration and service migrations, see Upgrading to config version 0.1.5.

Using services

How to reach and run the services on your node. The service guides assume the secure-node.nix preset, which adds Tor onion services, nodeinfo and the operator user, unless they say otherwise.

Node administration

  • Nodeinfo: service addresses, versions and node IDs.
  • SSH: connect and deploy through the node’s onion service.
  • Backups: node data, Bitcoin wallets and Lightning recovery files.

Managing services

NixOS uses the systemd service manager.

Usage:

# Show service status
systemctl status bitcoind

# Show the last 100 log messages
journalctl -u bitcoind -n 100
# Show all log messages since the last system boot
journalctl -b -u bitcoind

# These commands require root permissions
systemctl stop bitcoind
systemctl start bitcoind
systemctl restart bitcoind

# Show the service definition
systemctl cat bitcoind
# Show all service parameters
systemctl show bitcoind

Wallets and apps

  • electrs and Fulcrum: connect Electrum wallets through Tor.
  • RTL: access the web interface and manage backend credentials.
  • BTCPay Server: sign in and choose a Lightning backend.
  • Unbeholden LNURL: receive payments with Lightning Addresses.
  • Unbeholden Wallet: connect the watch-only browser wallet.
  • Cashu mint: issue ecash backed by Lightning or optional on-chain payments.
  • Orchard: manage the Cashu mint in a web dashboard.
  • ZEUS: connect to LND or Core Lightning over Tor or WireGuard.
  • Trezor: initialize and use a hardware wallet with HWI.

Lightning nodes

  • LND: create, manage and revoke custom macaroons.
  • Core Lightning: configure plugins and database replication.

Nodeinfo

The examples assume the secure-node.nix preset; see Using services.

Run nodeinfo as user operator (or root) to see onion addresses and local addresses for enabled services, and the node IDs of LND and Core Lightning. It prints JSON:

nodeinfo
nodeinfo | jq -r .bitcoind.onion_address
nodeinfo | jq -r .bitcoinix.revision

The bitcoinix entry is not a service: its revision is the bitcoinix git commit the system is built from, with a -dirty suffix for a checkout with uncommitted changes. It is null when the modules are imported without the bitcoinix flake; set nix-bitcoin.revision yourself in that case.

The revision is baked into the nodeinfo script, so every bitcoinix update produces a new system generation and boot entry, even when no package changed; no service restarts. Set nix-bitcoin.revision = null; to opt out.

The entries of bitcoind, clightning, lnd, cdk-mintd, electrs, fulcrum, btcpayserver, rtl and mempool include the version of the package the service runs.

Without arguments nodeinfo prints all entries. Arguments change that:

nodeinfo --version           # print only the bitcoinix revision, as a JSON string
nodeinfo bitcoind lnd        # print only these entries

See nodeinfo --help.

nodeinfo and jq are included in the secure-node.nix preset. Without the preset, set nix-bitcoin.nodeinfo.enable = true and install jq for the example above.

Troubleshoot onion addresses

The onion-addresses service only publishes valid Tor v3 onion addresses. If a hostname file is unreadable, contains invalid content, or takes more than 10 seconds to read, its address is omitted. Other valid addresses are still published, but onion-addresses.service reports failure. nodeinfo then prints only error: service 'onion-addresses' is not running. bitcoind, lnd and clightning with a public onion service (nix-bitcoin.onionServices.<service>.public) don’t start without their address, and their journal shows the error of cat /var/lib/onion-addresses/services/<service>.

Run journalctl -u onion-addresses to identify the affected /var/lib/tor/onion/<service>/hostname file. It must be readable by the tor user and contain a single v3 onion address, with at most one trailing newline. Once the Tor-generated hostname file and its permissions are correct, run systemctl restart onion-addresses as root, then retry nodeinfo and start the services that failed.

SSH

The examples assume the secure-node.nix preset; see Using services.

The secure-node.nix preset adds an onion service for SSH. It lets you reach and deploy to your node through Tor, e.g. when it’s behind NAT. It uses the SSH keys that you already deploy with. By default, the preset turns off SSH password login (services.openssh.settings.PasswordAuthentication and KbdInteractiveAuthentication), so sshd accepts only keys, also over the node’s IP address.

  1. Get the SSH onion address (excluding the port suffix)

    ssh operator@bitcoin-node
    nodeinfo | jq -r .sshd.onion_address | sed 's/:.*//'
    
  2. On your local machine, run Tor (listening on its default SOCKS port 9050) and install an OpenBSD-style nc, e.g. netcat from nixpkgs or netcat-openbsd on Debian. Add a host alias to ~/.ssh/config:

    Host bitcoin-node-onion
      HostName <SSH onion address>
      User root
      ProxyCommand nc -X 5 -x 127.0.0.1:9050 %h %p
    
  3. Connect with ssh bitcoin-node-onion.

  4. To deploy through Tor, use bitcoin-node-onion as the node’s address in your deployment tool, e.g. nixos-rebuild --target-host bitcoin-node-onion, Colmena’s deployment.targetHost or krops’ target. All of them connect through ssh, so they use the alias.

Keep the node’s IP address private

The onion service and your node’s IP address reach the same sshd, with the same host keys. Internet scanners index SSH host keys by IP address, so anyone who learns the onion address can look up its host key and find your node’s IP address. To keep them apart, don’t expose SSH to the internet:

  • First switch your deployment to the onion alias (step 4), also --build-host if it points to the node, and check that a deploy works. New SSH connections to the IP address fail once the port is closed.
  • Set services.openssh.openFirewall = false, and remove any other firewall rule that opens the SSH port to the internet. To keep SSH over a VPN, open the port on that interface, e.g. networking.firewall.interfaces.wg0.allowedTCPPorts = [ 22 ];.
  • Before you deploy the firewall change, open a root SSH session over the IP address. Keep it open until a new root login through the onion service works, and keep console access in case Tor fails on the node.

Or let only your own Tor client reach the onion service with client authorization (services.tor.relay.onionServices.sshd.authorizedClients).

Backups

The examples assume the secure-node.nix preset; see Using services.

services.backups backs up node data with duplicity, to /var/lib/localBackups by default. See the Backups section in examples/configuration.nix and the module for the options.

The backup includes the data directories of bitcoind, lnd, Core Lightning, NBXplorer and BTCPay Server, dumps of the BTCPay Server databases, /var/lib/tor, /var/lib/nixos and, with nix-bitcoin.generateSecrets, the secrets directory. It leaves out the mainnet, signet and testnet4 blockchains and their indexes unless with-bulk-data is set. This also covers networks previously used on the node.

Lightning channel databases

The backup never includes lnd’s graph directory, which holds channel.db, or Core Lightning’s lightningd.sqlite3 in any network directory. It also excludes the SQLite files set by services.clightning.wallet and each network’s replica at the configured replication destination. The daemons write these files while the backup runs, so a copy can be torn. A copy is also outdated as soon as a channel changes. A node that runs from an outdated channel database can broadcast a revoked channel state, and the peer can then take all funds in that channel. Never restore a copied channel database. Backups made before bitcoinix 0.2.0 contain them.

To recover Lightning funds, use these files from the backup instead. Both ways ask each peer to force close its channel, so they need the peer to be reachable. They get back settled funds, but not funds in pending payments.

  • lnd: the seed /var/lib/lnd/lnd-seed-mnemonic and the static channel backup /var/lib/lnd/chain/bitcoin/mainnet/channel.backup. Restore the seed on a node where lnd hasn’t created a wallet yet, and bitcoinix creates the wallet from it. Keep the restored channel.backup outside lnd’s data directory, because lnd replaces its own copy with the channels it knows. Then run lncli restorechanbackup --multi_file <path to channel.backup>. See lnd’s recovery guide, also for recovering on-chain funds.
  • Core Lightning: hsm_secret and emergency.recover in /var/lib/clightning/bitcoin/. Restore both to that directory, owned by the clightning user, before Core Lightning first starts on the node. Then run lightning-cli emergencyrecover. See Core Lightning’s recovery guide.

For a copy of the Core Lightning database that’s always current, use database replication. When Core Lightning stores its database in PostgreSQL, don’t add it to services.backups.postgresqlDatabases. Its dump is an outdated copy of the channel state too.

bitcoind wallets

Before each backup, the bitcoind-wallet-backup unit asks bitcoind for a consistent copy of each loaded wallet. It writes them to /var/lib/bitcoind/wallet-backups as wallet-<sha256 of the wallet name>.dat, and wallet-names.json there maps each file to its wallet name. bitcoinix manages this directory and replaces the copies before each backup, so don’t keep other files there. The backup also has the wallet files themselves, but a copy of a loaded wallet’s file can be torn. Restore a loaded wallet from its copy, for example with bitcoin-cli restorewallet <name> <copy>.

When bitcoind doesn’t run during a backup, there are no copies, and the wallet files are consistent. If a copy fails, or bitcoind is starting or stopping, the duplicity unit fails after the backup. With the bitcoind-remote.nix preset, the wallets are on the other node, and the backup makes no copies.

Cashu mint

When cdk-mintd is enabled, the backup briefly stops it to stage its complete data and signing secrets in /var/lib/cdk-mintd-backup/current. A previously running or starting mint is queued to restart before uploading; a stopped mint stays stopped unless a new start is requested during staging. Duplicity includes the snapshot and excludes live mint databases. A stop during staging cancels a pending mint restart. Copy failures still back up the other services, then fail the backup. See mint backup and recovery for the snapshot layout, custom secrets and the risks of restoring outdated spent-proof state.

electrs and Fulcrum

The examples assume the secure-node.nix preset; see Using services.

Electrum wallets can connect to your electrs (or Fulcrum) server through its onion service, which the secure-node.nix and enable-tor.nix presets create.

Warning

The onion service forwards to the server’s port, by default 127.0.0.1:50001. While the server is down, for example during a restart or an update, any other local user can listen on this port, and a wallet that connects then sends it the wallet’s addresses. With network namespace isolation, the server listens on its namespace’s address, which no other local user can take.

Android requirements

Desktop requirements

  • Tor, listening on its default SOCKS port 9050
  • Electrum

Connect your wallet

  1. Enable electrs in your configuration:

    services.electrs.enable = true;
    

    For Fulcrum, set services.fulcrum.enable = true and use .fulcrum instead of .electrs below.

  2. Deploy your configuration.

  3. Get the electrs onion address, in the format <onion-address>:<port>:

    nodeinfo | jq -r .electrs.onion_address
    
  4. Connect to electrs

    Make sure Tor is running on your desktop or as Orbot on Android.

    On your desktop

    electrum --oneserver -s "<electrs onion address>:t" -p socks5:127.0.0.1:9050
    

    On Android, open the network settings and set:

    • Proxy: SOCKS5, host 127.0.0.1, port 9050
    • Auto-connect: off, one-server mode: on
    • Server: <electrs onion address>:t

RTL

The examples assume the secure-node.nix preset; see Using services.

RTL listens on localhost by default. Connect to it through an SSH tunnel, then open http://localhost:3000 in your browser:

ssh -L 3000:127.0.0.1:3000 operator@bitcoin-node

With netns-isolation, RTL listens in its own network namespace. Use the address from nodeinfo | jq -r .rtl.local_address instead, e.g. 169.254.1.29:3000.

RTL’s web interface is plain HTTP. A local user who takes RTL’s port could show you a fake login page and collect the password. So without netns-isolation, RTL listens on a unix socket, and systemd holds services.rtl.address and port with a socket unit, rtl-proxy-*.socket, also while RTL is stopped. The address must then be a numeric IP address without a zone ID. With a host name, a zone ID or a socket path, the system build fails. A switch that changes the address or port frees the port for a moment. In the tunnel, use the address and port that systemd holds. By default that’s 127.0.0.1:3000, as above. If you set another address or port, use those, with 127.0.0.1 for 0.0.0.0 and [::1] for ::. With localhost, sshd may connect to [::1]:3000, which systemd doesn’t hold with the default address. With netns-isolation, RTL’s address exists only in RTL’s namespace, and no process in the host namespace can take it.

With the secure-node.nix or enable-tor.nix preset, RTL also has an onion service. Open http://<onion address> in Tor Browser, using the address from nodeinfo | jq -r .rtl.onion_address.

The password is in $secretsDir/rtl-password. See: Secrets dir

Backend maintenance

RTL is bound to the units of its backends. It stops when the lnd or clightning unit stops, crashes or exits, and the backend’s next start starts it again. With both backends enabled, stopping one of them also stops RTL for the other one, and starting RTL starts a stopped backend too. So during maintenance of one backend, leave RTL stopped.

Backend credentials

RTL gets its own lnd macaroon and clightning rune. With them, RTL can send funds and open and close channels, but it can’t bake macaroons, create runes, stop lnd, delete lnd’s payment history or use lnd’s signer RPCs. RTL copies them to its data dir when it starts.

  • lnd: the custom macaroon services.lnd.macaroons.rtl, see Custom macaroons. It allows only the lnd RPCs that RTL calls. Its permissions for the RPCs of invoicesrpc and walletrpc are optional, so RTL also starts with an lnd package that lacks their build tags. RTL’s features that use these RPCs then fail.

  • clightning: a rune that allows only the methods that RTL calls. bitcoinix creates it once and keeps it at rtl-rune in clightning’s network dir. The rune has the comment bitcoinix-rtl. Each start of RTL revokes all other runes with this comment, for example the old rune after an update that changes RTL’s methods.

    To revoke the rune, for example after a leak, run lightning-cli blacklistrune <id> <id> with the unique_id that lightning-cli showrunes shows for it. Then run systemctl restart clightning. clnrest runs as a plugin of clightning, and it checks the rune of a websocket client only when the client connects. So the restart closes the connections that still use the revoked rune. clightning’s start also starts RTL again, see Backend maintenance, and RTL creates a new rune. A new rune gets the next unique ID, also when that ID is blacklisted. So RTL’s start creates up to 10 runes until one has an ID that isn’t blacklisted. If there’s none, the start fails. systemd starts RTL again after 10 seconds, and it tries the next IDs. Each failed try stores 10 more runes in clightning’s database, so blacklist only the IDs of runes that you have.

    When you disable RTL or its clightning node in your config, the rune stays valid. Revoke it the same way. Then the restart doesn’t start RTL. If nothing else in your config enables clightning, the deploy also removes clightning and lightning-cli. Then you can’t revoke the rune, and it works again when you enable clightning later. So revoke the rune before the deploy. Run systemctl stop rtl, blacklist the rune while clightning still runs, and then deploy. The deploy stops clightning, which closes clnrest’s connections. A start of lnd or clightning before the deploy starts RTL again, and RTL creates a new rune. So right before the deploy, check that systemctl is-active rtl prints inactive and that lightning-cli showrunes shows each rune with the comment bitcoinix-rtl as blacklisted.

    clightning keeps the revoked runes and the count of unique IDs in its database. When clightning starts with a new or older database, for example after a recovery, revoked runes work again, and a new rune can get the unique ID of an older rune, like the admin rune. Revoking one of them then revokes both.

Backend certificates

A connection from RTL to a backend’s address and port must present that backend’s pinned certificate: services.lnd.certPath for lnd, or server.pem in clnrest’s cert dir (clightning’s network dir, or clnrest-certs). So a local process that takes a backend’s port gets neither the lnd macaroon nor the clightning rune. Every other HTTPS connection gets the normal certificate and hostname checks against the system CAs. RTL doesn’t start when LN_SERVER_URL or LND_SERVER_URL is set in its environment. To use another server with a self-signed certificate, for example a swap server set through extraConfig, add its certificate to RTL’s environment with systemd.services.rtl.environment.NODE_EXTRA_CA_CERTS.

Reset two-factor authentication

Two-factor authentication that you set up in RTL stays on across restarts. If you lose the authenticator, delete RTL-Config.json in RTL’s data dir (/var/lib/rtl by default) and restart RTL. bitcoinix then writes a new one without the 2FA secret.

BTCPay Server

The examples assume the secure-node.nix preset; see Using services.

BTCPay Server listens on localhost by default. Connect to it through an SSH tunnel, then open http://localhost:23000 in your browser:

ssh -L 23000:127.0.0.1:23000 operator@bitcoin-node

With netns-isolation, BTCPay Server listens in its own network namespace. Use the address from nodeinfo | jq -r .btcpayserver.local_address instead, e.g. 169.254.1.24:23000.

BTCPay Server makes the first account that registers the server admin, which can use the internal Lightning node. So when BTCPay Server has no admin, the unit btcpayserver-admin creates the admin account admin@localhost before BTCPay Server opens its port. BTCPay Server then closes registration. Sign in with this account. The password is in $secretsDir/btcpayserver-admin-password. See: Secrets dir

An installation that already had an admin before bitcoinix 0.2.0 keeps it and gets no admin@localhost. Sign in with your own account there.

You can change the account’s email address and password in BTCPay Server. The secret file keeps the first password.

Check the admin accounts

Before bitcoinix 0.2.0, any local user could register first and become the admin until you registered yours. So on an installation from before 0.2.0, check that each admin is yours. Sign in, open Server Settings > Users and look at the users with the admin role.

If one isn’t yours, or if you found registration closed before you registered, someone else had admin access. An admin can install plugins that run as the btcpayserver user and can use your Lightning node. So treat the node as compromised:

  1. Stop BTCPay Server with systemctl stop btcpayserver.
  2. Move the funds of the Lightning node and of the wallets on this node to a new wallet that this node doesn’t control.
  3. Set up the node again.

Lightning backend

services.btcpayserver.lightningBackend connects BTCPay Server to the node’s lnd or Core Lightning. The two backends give BTCPay Server different access.

With lnd, BTCPay Server gets its own macaroon, services.lnd.macaroons.btcpayserver (see Custom macaroons). It can read the node’s state and create invoices and addresses. It can’t send funds or open or close channels, so BTCPay Server can’t make Lightning payouts.

With clightning, BTCPay Server has full control of the Lightning node, including its funds. It joins the clightning group and uses lightningd’s RPC socket lightning-rpc, which allows every method. So BTCPay Server can pay invoices (pay, xpay), send on-chain funds (withdraw), open and close channels (fundchannel, close) and start plugins (plugin), which run as the clightning user. With clnrest enabled, the group can also read clnrest’s admin rune. A bug in BTCPay Server, a malicious BTCPay plugin or a stolen admin session can drain the node. The pinned BTCPay Server 2.4.7 uses BTCPayServer.Lightning 1.7.14, whose Core Lightning client connects only over this socket or TCP and can’t use runes. So bitcoinix can’t give it restricted access yet.

The backend limits only what BTCPay Server can do with the Lightning node. A hot wallet that you create in BTCPay Server keeps its keys on the node, so BTCPay Server can spend it with either backend.

Use lnd when you want BTCPay Server limited, for example when its web interface is reachable from the internet. bitcoinix turns on Core Lightning for BTCPay Server only while it’s the backend. So if your Core Lightning has channels, set services.clightning.enable = true before you switch, or close the channels first. Otherwise the switch stops Core Lightning, and nothing watches its channels. Both daemons use port 9735 by default, so also give lnd another port, for example services.lnd.port = 9736;.

Unbeholden LNURL

The examples assume the secure-node.nix preset; see Using services.

Unbeholden LNURL serves Lightning Addresses through your local LND or Core Lightning node.

services.unbeholden-lnurl = {
  enable = true;
  backend = "lnd";
  settings.addresses.satoshi = {
    description = "Lightning payments";
    min_sendable = 1000;
    max_sendable = 1000000000;
  };
};

Use backend = "clightning"; for Core Lightning. The module enables the selected node and creates credentials limited to the RPCs needed by the configured features. Core Lightning revokes the service’s rune when you disable the service or switch it to LND. When Core Lightning starts with a new or older database, for example after a recovery, the service gets a new rune, and the old one stays valid: its ID can now belong to another rune, so bitcoinix doesn’t revoke it.

The HTTP listener defaults to 127.0.0.1:8081. Put an HTTPS reverse proxy in front for a public Lightning Address. Set settings.trusted_proxies to the proxy’s IP addresses or CIDRs if it forwards X-Forwarded-Host or X-Forwarded-For. With namespace isolation, use the service’s namespace address as the proxy target. Onion domains can use HTTP through nix-bitcoin.onionServices.unbeholden-lnurl.enable.

settings.withdraw defines vouchers, settings.notifications.ntfy enables payment notifications, and settings.nostr = {}; enables zap receipts. Amounts are in millisatoshis. settings takes the keys of the example config, except listen, state_dir and the node connection, which the module sets.

The config is world-readable in the Nix store. Store an ntfy token in a runtime file and set settings.notifications.ntfy.token_file to its path. On a public ntfy server, anyone who knows the topic can read the notifications, so choose a topic that is hard to guess or protect it with a token. The module generates persistent verification, voucher and Nostr keys through Bitcoinix secrets. Setting settings.withdraw_secret instead skips the voucher key but puts the secret in the world-readable store.

To print the unclaimed vouchers with their URLs, run sudo unbeholden-lnurl-vouchers.

Keep /var/lib/unbeholden-lnurl and the generated secrets across upgrades. This preserves voucher claims, settlement cursors and zap receipts. Changing a voucher secret changes its URLs; changing the verification key invalidates old verify URLs. Treat voucher URLs as bearer secrets. A restored backup restores the voucher secret but not the claims made since the backup, so those vouchers can be claimed again.

With vouchers, the service can pay any invoice from the node’s Lightning balance (LND SendPaymentV2, Core Lightning pay). Only the service itself enforces the voucher amounts.

Rate limits apply per client address. Behind the onion service every client comes from Tor’s address, so they all share one limit, and one client can use it up.

Set services.unbeholden-lnurl.tor.proxy = true; to send notifications and Nostr publishing through Tor. The local node connection stays direct. Zap receipts go to relays that the payer chooses, so without the proxy anyone who pays a zap learns the node’s IP address, even when the Lightning Address is published only as an onion.

Unbeholden Wallet

The examples assume the secure-node.nix preset; see Using services.

Unbeholden Wallet is a watch-only wallet that runs in the browser and hands transactions to an air-gapped signer over QR codes. The service serves the wallet and passes its connection on to electrs, or to Fulcrum with services.unbeholden-wallet.electrumServer = "fulcrum".

services.unbeholden-wallet.enable = true;

It listens on localhost. Connect through an SSH tunnel, then open http://localhost:60846 and press Connect:

ssh -L 60846:127.0.0.1:60846 operator@bitcoin-node

With netns-isolation, use the address from nodeinfo | jq -r '.["unbeholden-wallet"].local_address' instead.

Access from another device

Browsers only allow the camera, which scans the signed transaction, on localhost or over https. To use the wallet from another device without a tunnel, put an https reverse proxy in front of it that passes WebSocket upgrades and the Host header through, and add its name to services.unbeholden-wallet.allowedHosts.

The service only accepts connections from localhost. For a proxy on another host, listen on all addresses, allow the proxy’s address and open the port:

services.unbeholden-wallet = {
  address = "0.0.0.0";
  allowedClients = [ "192.0.2.10" ];
  allowedHosts = [ "wallet.example.com" ];
};
networking.firewall.allowedTCPPorts = [ 60846 ];

The service has no authentication. Its Host and Origin checks stop websites, not other clients, so anyone who can reach the proxy can use the Electrum connection and write to the service’s journal. Keep the proxy on a trusted network or give it its own authentication.

With netns-isolation, nginx and the wallet run in their own namespaces, which drop connections from your LAN, so neither an nginx proxy nor allowedClients serves other devices. Run the proxy in the host network namespace instead, and point it at the wallet’s local_address.

Run a Cashu mint

CDK Mintd issues Cashu ecash backed by your local LND or Core Lightning node. The service uses cdk-mintd from nixpkgs’ cashu-cdk package.

services.cdk-mintd = {
  enable = true;
  backend = "lnd"; # or "clightning"
  settings.mint_info.name = "My Cashu mint";
};

The selected Lightning service is enabled automatically. It needs funded channels and inbound liquidity to send and receive payments. LND gives the mint a dedicated macaroon limited to invoices, payment routing and payment status. Core Lightning uses its Unix RPC socket: the mint joins the clightning group and has full RPC access, including the ability to spend funds and start plugins.

Before changing backends, settle outstanding payments and keep the old node enabled explicitly if it still has channels. If you run both nodes, give them different Lightning ports; both default to 9735.

Access

The HTTP API listens on 127.0.0.1:8085 by default. Put a reverse proxy with HTTPS in front of it and give wallets the public HTTPS URL. The module opens no firewall ports. With namespace isolation, use the address shown by nodeinfo | jq -r '.["cdk-mintd"].local_address' as the proxy target. The mint namespace can reach LND when selected and Bitcoin Core when on-chain support is enabled; Core Lightning uses a Unix socket.

For Tor access, set nix-bitcoin.onionServices.cdk-mintd.enable = true; and use the resulting http://<address>.onion URL. The onion service exposes port 80. The Tor preset restricts the mint to local connections; it needs no external payment API or chain server.

Check the service with journalctl -u cdk-mintd and query its HTTP /v1/info endpoint. See the options for listen addresses, paths and settings. Logs go to the journal by default, without accumulating daily files in dataDir. CDK 0.18.3 does not advertise the public URL through info.url.

Web management

Enable services.orchard.enable = true; for the Orchard dashboard, including mint analytics and authenticated management RPC.

Optional on-chain payments

Lightning-only operation is the default. To also accept and send on-chain payments:

services.cdk-mintd.onchain.enable = true;

This creates a separate BDK wallet, using the local Bitcoin Core RPC for scanning and broadcasting. It does not use the Lightning node’s on-chain wallet. The Bitcoin Core node must be unpruned. CDK 0.18.3 supports mainnet, signet and regtest here, but not testnet4. Deposits require six confirmations by default; configure services.cdk-mintd.settings.bdk.num_confs to change this.

When adding on-chain support after the mint has already started, first back up its data directory, as upstream recommends: run systemctl start duplicity with automated backups, or copy dataDir while the mint is stopped. Also set services.cdk-mintd.onchain.allowNewWallet = true; for the first deployment. After the wallet starts successfully, set it back to false. New mints create their first BDK wallet without this flag. A missing wallet database on a later start is an error, rather than a reason to silently create a replacement.

Secrets, configuration and recovery

With nix-bitcoin.generateSecrets, the module generates cdk-mintd-seed in nix-bitcoin.secretsDir and, when needed, cdk-mintd-bdk-mnemonic. Otherwise provide these through your secrets setup. You can point seedFile and onchain.mnemonicFile at other absolute paths readable by the service user. Use string paths, not Nix path literals that copy files to the store. The signing seed is raw text, not hex-decoded; preserve every byte, including its trailing newline. The BDK secret is a separate BIP39 mnemonic.

CDK stores configuration in its SQLite database. Before the first start the module runs config init --new-mint; when the generated Nix configuration or onchain.allowNewWallet changes, it runs config apply. It records both in dataDir/nix-config. A root-owned marker at /var/lib/nixos/cdk-mintd/initialized prevents a missing database or changed dataDir from silently creating a replacement mint with the old signing seed. Keep this marker with the node’s state when migrating hosts; automated backups include it under var/lib/nixos. Its directory and /var/lib/nixos must be real, root-owned directories, readable and searchable by the mint user and not writable by other users (mode 0755). Startup refuses missing, inaccessible or unsafe guard paths rather than treating their marker as missing. On a replacement host, install the recovery masks below before the first deployment that enables the service, even if /secrets is already restored. This needs no mint account; the protected deployment creates the user and group needed to restore the data. Only when deliberately replacing a mint, use a new signing seed, an empty data directory and temporary allowNewMint = true. Never use this option to recover a mint with outstanding ecash. With nix-bitcoin.generateSecrets and the default seedFile, move the old cdk-mintd-seed out of secretsDir and run systemctl restart setup-secrets to generate a new one. Otherwise create it the same way, with openssl rand -hex 32.

Configure metadata and fees through settings; direct changes through CDK’s management tools can be replaced by a later Nix deployment. The module manages backend connections and signing settings. Keep secrets out of settings, which is world-readable in the Nix store.

Preserve the entire dataDir (default /var/lib/cdk-mintd) and both secrets. The mint database records spent proofs and outstanding obligations: a seed alone cannot recover it, and an outdated database can accept already-spent ecash. Keep the Lightning backend’s recovery data separately; a mint snapshot does not replace Lightning channel recovery.

Automated backups

Enable services.backups.enable = true; to include the mint. Before each duplicity backup, cdk-mintd-backup stops the mint, archives its complete data directory, and copies its signing seed and, when on-chain support is enabled, BDK mnemonic. This includes custom seedFile and onchain.mnemonicFile paths even when nix-bitcoin.generateSecrets is off. A previously running mint gets a restart queued before shutdown, so cancellation during shutdown cannot lose its start. Systemd keeps that start, and any other start requests, waiting until the backup finishes. A stop requested during copying cancels that pending start; stops of the mint or its backends during shutdown also take precedence. A backup waits for an in-progress stop and retries restart transactions after state changes or job conflicts, without cancelling queued starts or reloads. Restart restrictions still apply: a masked or start-rate-limited mint can be stopped and backed up, but stays down until the restriction is cleared and a new start is requested. Cleanup does not restart the mint afterwards. An intentionally stopped mint stays stopped unless a new start is requested. Payments are unavailable during staging; uploading does not wait for mint startup.

The root-only staging directory /var/lib/cdk-mintd-backup/current contains:

  • data.tar: the complete mint data directory, including SQLite databases and WALs.
  • seed and optional bdk-mnemonic: exact copies of the configured secrets.
  • manifest.json: original data and secret paths; created-at: snapshot time.

Duplicity archives this snapshot and excludes the live mint directory and partial staging, even if listed in services.backups.extraFiles. The old snapshot is removed before starting the backup hook, so even a hook that cannot start leaves no stale snapshot. A failed copy releases any pending mint start and makes duplicity fail after backing up the other services. Check journalctl -u cdk-mintd-backup -u duplicity on failure. Do not store your own files in /var/lib/cdk-mintd-backup.

Restore a snapshot

Keep the mint inaccessible to wallets throughout recovery. A consistent snapshot can still be too old: payments and spent proofs recorded after created-at are missing. Do not reopen a mint from an outdated snapshot without reconciling that missing state and its liabilities.

The recovery masks below only stop systemd units. The onion service and a reverse proxy forward directly to the mint’s address, so wallets can reach the mint as soon as it starts. Block them with a deployment before step 1, or in the first deployment on a new host:

nix-bitcoin.onionServices.cdk-mintd.enable = false;

Also remove the mint from your reverse proxy. Tor keeps running for other services. Keep /var/lib/tor/onion/cdk-mintd: its key defines the onion address, and re-enabling the onion service reuses it. On a new host, restore that directory from the backup’s var/lib/tor before re-enabling the onion service, or the mint gets a new address.

  1. Open a root shell (sudo -s). On a new host, perform this step before the first deployment that enables services.cdk-mintd. On an existing host, pause scheduled backups with systemctl stop duplicity.timer if the timer is enabled. Wait for any running duplicity and cdk-mintd-backup jobs to finish, then prevent new backup jobs and mint starts throughout recovery. NixOS installs units in /etc, which takes precedence over ordinary systemctl mask --runtime masks. Use the higher-priority runtime unit directory:

    install -d -m 0755 /run/systemd/system.control
    for unit in duplicity cdk-mintd-backup cdk-mintd; do
      ln -s /dev/null "/run/systemd/system.control/$unit.service"
    done
    systemctl daemon-reload
    systemctl show -p LoadState duplicity cdk-mintd-backup cdk-mintd
    systemctl stop cdk-mintd.service
    

    Confirm all three show LoadState=masked before continuing. On a new host, now deploy the configuration enabling the mint to create its user, group and data directory. Keep the masks in place, and check LoadState=masked again after deployment. If a backup timer is configured, stop duplicity.timer again immediately after deployment, which may have started it. These masks last until reboot; keep the node running until recovery finishes.

    Also restore var/lib/nixos/cdk-mintd/initialized from the backup when available. It is outside the current snapshot. Keep its parent directory owned by root:root with mode 0755, and the marker owned by root:root with mode 0600. Preserve an existing marker.

  2. Restore the snapshot to a temporary, root-only directory. Use your services.backups.destination (default file:///var/lib/localBackups) and the restored backup-encryption-env secret:

    install -d -m 0700 /root/cdk-restore
    (
      set -a
      . /secrets/backup-encryption-env
      duplicity restore --path-to-restore var/lib/cdk-mintd-backup/current \
        file:///var/lib/localBackups /root/cdk-restore/snapshot
    )
    

    Files such as data.tar are then directly inside /root/cdk-restore/snapshot. Retain the original mint data and secrets until recovery has been verified. Check manifest.json against your Nix configuration. Create an empty data directory owned by the configured mint user and group, mode 0700.

  3. Extract data.tar as the mint user, never as root, so archived symlinks cannot redirect privileged writes. From the root shell, for the default user, group and directory:

    (
      umask 077
      setpriv --reuid=cdk-mintd --regid=cdk-mintd --init-groups -- \
        tar --no-same-owner --no-same-permissions -xf - -C /var/lib/cdk-mintd \
        < /root/cdk-restore/snapshot/data.tar
    )
    
  4. Restore seed to seedFile and, if present, bdk-mnemonic to onchain.mnemonicFile, owned by the configured mint user/group with mode 0440. Preserve their bytes. Restore the entire data archive, including the BDK wallet, from the same snapshot, rather than mixing database versions. When nix-bitcoin.setupSecrets is enabled, restore all declared secrets and run the following successfully before starting the mint:

    systemctl reset-failed setup-secrets.service
    systemctl restart setup-secrets.service
    systemctl start nix-bitcoin-secrets.target
    

    Restarting setup-secrets reapplies owners and modes even if it and the target are already active after a deployment with generated secrets. With generateSecrets = false, it also repairs a failed deployment that left secretsDir locked to mode 0700 because supplied secrets were missing.

  5. Remove /run/systemd/system.control/cdk-mintd.service, run systemctl daemon-reload, and start the mint while external access remains blocked. Check its journal, mint keys, quotes and wallet state. Only after resolving any state lost since the snapshot, remove the duplicity.service and cdk-mintd-backup.service masks from the same directory, run systemctl daemon-reload, run systemctl reset-failed duplicity.timer and systemctl start duplicity.timer if scheduled backups are configured, and re-enable the onion service and the proxy route with another deployment.

Restore the BDK wallet database together with its mnemonic. For last-resort mnemonic-only recovery, follow CDK’s BDK recovery guidance, including settings.bdk.wallet_rescan_from_height and a temporary onchain.allowNewWallet. Fresh BDK wallets otherwise begin scanning at the current chain tip and miss historical deposits.

Importing an existing standalone CDK mint requires its original signing source and database and CDK’s explicit migration procedure. The module’s automatic new-mint initialization refuses a database with existing mint identity or keysets.

Orchard

Orchard provides a web dashboard for the local CDK Cashu mint: balances, quotes, proofs, keysets and mint management.

services.orchard.enable = true;

This also enables services.cdk-mintd and its selected Lightning backend. Configure the mint through services.cdk-mintd; for example, set backend = "clightning"; to use Core Lightning instead of LND. Orchard’s Bitcoin, Lightning, Taproot Assets and Prometheus panels are not configured by this module.

Access and initial setup

The web interface listens on 127.0.0.1:3321 by default. For an SSH tunnel:

ssh -L 3321:127.0.0.1:3321 operator@node

Open http://localhost:3321. With network namespace isolation, use the Orchard address from nodeinfo as the tunnel destination instead of 127.0.0.1. Alternatively, enable its onion service:

nix-bitcoin.onionServices.orchard.enable = true;

Use nodeinfo to find the onion address and open it in Tor Browser. The onion service exposes port 80. For a public domain, put an HTTPS reverse proxy in front of Orchard; the module does not open firewall ports.

Retrieve the setup key on the node (adjust the path if you changed nix-bitcoin.secretsDir or services.orchard.setupKeyFile):

sudo cat /etc/nix-bitcoin-secrets/orchard-setup-key

Use this key to create the first administrator account, choosing your own username and password. The setup key is not the login password. It is generated when nix-bitcoin.generateSecrets is enabled; services.orchard.setupKeyFile can instead point to an existing secret. Subsequent logins use the account you created. Restarting Orchard invalidates login sessions.

Permissions and configuration

Orchard runs as a separate user. It can read the mint SQLite database and its WAL files, but cannot write them or read the mint seed, BDK wallet or Lightning credentials. The mint data filesystem must support POSIX ACLs. The module replaces access ACLs on the mint directory and DB/WAL/SHM files, granting access only to the file owner and the restricted Orchard group. Custom access ACL entries on these paths are overwritten, so old masked entries cannot regain read or write access. Orchard reapplies its read access at each start; an ACL failure stops only Orchard, leaving the mint running. While Orchard is enabled, tmpfiles sets the mint directory’s mode to 0700 only when creating it, preserving access until it reapplies the same managed directory ACL. That ACL also restores the owner’s permissions and removes access for other users. Without Orchard, normal 0700 enforcement applies on every run. Without network namespace isolation, a systemd socket reserves the HTTP port even while Orchard is stopped and proxies connections to its private Unix socket.

Management operations use CDK’s gRPC API with mutual TLS. The RPC listener stays on loopback, or the mint’s private namespace address, independently of the public mint HTTP listener. Its default port is 8086; change services.orchard.mintRpcPort if needed.

Treat Orchard administrator access as mint administration access: it allows metadata and fee changes and keyset rotation. Overriding quote payment state is disabled. Changes made through Orchard can be replaced when a changed Nix mint configuration is applied. Keep intended persistent settings in services.cdk-mintd.settings.

Without automatic secret generation, supply orchard-setup-key (unless using services.orchard.setupKeyFile) through your secrets setup. The mutual TLS certificates for the local management RPC are generated ephemerally at runtime under /run/orchard-rpc-tls, so no manual TLS setup is needed.

Outgoing requests and AI

Orchard’s server fetches mint icons and checks public URLs from the mint’s info. OpenRouter and Telegram also make external requests when enabled in Orchard’s settings. The enable-tor preset enables both services.orchard.tor.proxy and services.orchard.tor.enforce, routing these requests through Tor and blocking direct external connections. Local mint connections stay direct. Without the preset, enable the Tor client and both options to get the same behavior. Enabling only the onion service does not proxy outgoing requests; without tor.proxy, they use clearnet unless blocked by tor.enforce.

With tor.proxy, public URL and TCP port checks also resolve hostnames through Tor, even if the node has a local DNS resolver. A failed Tor lookup or connection does not fall back to clearnet. Checks still reject private destinations, including names that Tor resolves to private addresses. Loopback mint addresses such as 127.0.0.2 stay direct; Tor SOCKS listeners on [::1] are supported too. Public icon fetches also stay on the proxy, including URLs with .local, .lan, .internal or dotless hostnames.

Public URL and TCP port checks also reject site-local (fec0::/10), well-known NAT64 (64:ff9b::/96) and local-use translation (64:ff9b:1::/48) IPv6 addresses, even without Tor. Unlike the well-known prefix, the local-use prefix permits translation to private IPv4 destinations.

AI is off by default and the server enforces the switch. When enabled in Orchard’s settings, the web assistant, active scheduled agents and the Telegram conversation agent can send conversation content and mint data obtained through tool calls to the configured provider, such as OpenRouter. Scheduled agents can do this without a browser open. Tor does not prevent that provider from receiving the data.

Turning AI off blocks new inference requests, scheduled runs, Telegram AI conversations and further agent tool calls. A provider request already in flight may finish; data already sent cannot be recalled. Agent configuration and schedules are retained, so active schedules resume when AI is enabled again. Model lists and provider connection checks remain available for configuration while AI is off.

State and recovery

Orchard stores accounts, settings and crypto.key in services.orchard.dataDir (default /var/lib/orchard). Back up this whole directory while orchard.service is stopped, together with orchard-setup-key if you want to keep the initial setup secret. Restore the directory with the configured Orchard user/group and mode 0700. Orchard state is not automatically included in services.backups.

Use the CDK backup and recovery procedure for mint state. Orchard’s database download does not include the signing secrets or initialization guard, and its database restore cannot write the protected mint database. Orchard stops with the mint during its backups and restarts when the mint starts again.

For startup or connection failures, check journalctl -u orchard -u cdk-mintd. See the options for paths, listeners and package overrides.

ZEUS

Connect ZEUS to your LND or Core Lightning node over Tor or WireGuard.

The examples assume the secure-node.nix preset; see Using services.

Connect via Tor

  1. Install ZEUS

  2. Edit your configuration.nix

    For LND

    Add the following config:

    services.lnd.lndconnect = {
      enable = true;
      onion = true;
    };
    

    For Core Lightning

    Add the following config:

    services.clightning.plugins.clnrest = {
      enable = true;
      lnconnect = {
        enable = true;
        onion = true;
      };
    };
    
  3. Deploy your configuration

  4. Run the following command on your node (as user operator) to create a QR code with address and authentication information:

    For LND

    lndconnect
    

    For Core Lightning

    lnconnect-clnrest
    

    lnconnect-clnrest reads the onion address from the directory of the user that runs it. Root can always run it, because then it runs as the clightning user, which has its own copy. The operator user needs access to the onion address only to run lnconnect-clnrest as itself. It gets this access when the operator role is enabled (nix-bitcoin.operator.enable = true;, which the secure-node preset sets). With the role disabled, grant the access explicitly:

    nix-bitcoin.onionAddresses.access.<operator name> = [ "clnrest" ];
    

    lnconnect-clnrest also reads the admin rune, which only the clightning group can read. The operator role adds the operator user to this group. With the role disabled, run lnconnect-clnrest as root, or add the user to the group:

    users.users.<operator account>.extraGroups = [ "clightning" ];
    

    <operator account> is the users.users attribute that defines the account. It’s usually the operator name. Members of this group can read the admin rune and use the clightning RPC socket, so they have full control over the node.

  5. In ZEUS, add a new node and scan the QR code.

Additional lndconnect features

To print the connection URL as text instead of a QR code, run lndconnect --url or lnconnect-clnrest --url. The URL contains the credentials for your node, so keep it secret.

With onion, the commands fail when they can’t read the onion address, for example while Tor still starts. They never look up your public IP then. --host replaces the onion address.

For LND, the onion service forwards to a Unix socket where lnd also serves REST. lnd keeps listening on services.lnd.restAddress for RTL and local clients.

Warning

For Core Lightning, the onion service forwards to clnrest’s port, by default 127.0.0.1:3010. While clnrest is down, for example while clightning restarts or updates, any other local user can listen on this port, and ZEUS then sends it the admin rune. With network namespace isolation, clnrest listens on its namespace’s address, which no other local user can take. Without it, don’t give untrusted users an account on the node.

Connecting without Tor or WireGuard

Enabling lndconnect or lnconnect does not change the address that the REST server listens on. By default, the LND and clnrest REST servers only listen on localhost.

The REST API grants full control over your Lightning node, so only expose it to networks you trust. To reach it directly (e.g. via your local network or your own VPN), opt in explicitly. In the examples below, 192.168.1.10 is the address of your node and eth0 is the interface of the trusted network. The snippets use config, so the module that contains them must take it as an argument ({ config, ... }: { ... }).
These examples don’t apply when using netns-isolation.

Warning

While the REST server is down, for example while lnd or clightning restarts or updates, any other local user can listen on its port, and ZEUS then sends it the macaroon or rune. Don’t give untrusted users an account on the node.

tor.enforce = false lifts the Tor-only network restriction for the whole service, not just the REST server. With tor.proxy, outgoing connections still use Tor.

With tor.enforce, a service reaches only localhost and, with network namespace isolation, its namespace subnet. It can’t use the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself, from /etc/hosts.

The restriction covers IP connections and these sockets, not every local service:

  • Without netns-isolation, a resolver that listens on 127.0.0.1 or ::1, such as a local dnsmasq or unbound, or networking.nameservers = [ "127.0.0.1" ], stays reachable, because localhost is allowed and the restriction can’t tell ports apart. The service can still send it DNS queries, which it may forward over clearnet. With netns-isolation each service has its own loopback, so a host resolver there is out of reach, unless the host firewall opens the resolver’s port on all interfaces: the service can reach the bridge address on any port the firewall allows. Bind the resolver to an address outside the allow list if you don’t want these services to use it.
  • Another daemon you run that the service can reach over a Unix socket, and that makes network requests for its clients, isn’t covered. Keep such daemons off nodes that rely on tor.enforce, or restrict access to their sockets.

For LND

services.lnd = {
  restAddress = "0.0.0.0";
  # Add the node address to the TLS certificate
  certificate.extraIPs = [ "192.168.1.10" ];
  # Only needed when using `secure-node.nix` or `enable-tor.nix`
  tor.enforce = false;
};
networking.firewall.interfaces.eth0.allowedTCPPorts = [ config.services.lnd.restPort ];

For Core Lightning

services.clightning = {
  plugins.clnrest.address = "0.0.0.0";
  # Only needed when using `secure-node.nix` or `enable-tor.nix`
  tor.enforce = false;
};
networking.firewall.interfaces.eth0.allowedTCPPorts = [ config.services.clightning.plugins.clnrest.port ];

Then create the QR code with your node address as the host:

lndconnect --host 192.168.1.10
lnconnect-clnrest --host 192.168.1.10

Always pass --host here. Without it (and without onion), the commands detect your external IP by querying public IP lookup services over clearnet. lnconnect-clnrest puts clnrest’s server certificate into this URL. It asks clightning for clnrest’s cert dir (clnrest-certs). When clightning doesn’t answer, it prints a warning and uses clightning’s network dir. So with clnrest-certs set, run it while clightning runs, or pass --tlscertpath.

Connect via WireGuard

Connecting ZEUS through a WireGuard tunnel is much faster than using Tor. The wireguard.nix preset sets up a WireGuard server on your node with a single peer, your mobile device. To use your own VPN instead, see Connecting without Tor or WireGuard.

WireGuard requirements

The preset requires:

  • the NixOS firewall (networking.firewall.enable, set by the secure-node.nix preset) with the iptables backend. networking.nftables and services.firewalld must be disabled, because the preset protects the REST servers with iptables rules.
  • no netns-isolation.

The preset binds the LND and clnrest REST servers to 0.0.0.0 and only allows REST connections from the WireGuard peer through the firewall. It also sets tor.enforce = false for the service whose connection helper you enable (see Connecting without Tor or WireGuard).

Warning

The firewall doesn’t stop local users. While lnd or clightning restarts or updates, any other local user can listen on the REST port, and ZEUS then sends it the macaroon or rune through the tunnel. The preset can’t be combined with netns-isolation, so don’t give untrusted users an account on the node.

Set up WireGuard and ZEUS

  1. Install ZEUS and WireGuard on your mobile device.

  2. Import the preset. With the flake.nix example, add it to the modules list in flake.nix, next to bitcoinix.nixosModules.default:

    (bitcoinix + "/modules/presets/wireguard.nix")
    

    With Colmena, add (inputs.bitcoinix + "/modules/presets/wireguard.nix") to the imports of your node. With krops, add it to configuration.nix:

    imports = [ <nix-bitcoin/modules/presets/wireguard.nix> ];
    

    Then enable the connection helper:

    # For LND
    services.lnd.lndconnect.enable = true;
    
    # For Core Lightning
    services.clightning = {
      plugins.clnrest = {
        enable = true;
        lnconnect.enable = true;
      };
    };
    

    For custom firewall configurations, review WireGuard firewall compatibility before deploying.

  3. Deploy your configuration.

  4. If your node is behind an external firewall or NAT (e.g. a router), add the following port forwarding rule to the external device:

    • Port: 51820 (the default value of option networking.wireguard.interfaces.wg-nb.listenPort)
    • Protocol: UDP
    • Destination: IP of your node
  5. Set up WireGuard on your mobile device.

    Run the following command on your node (as user operator) to create a QR code for WireGuard, with the public IP or hostname of your node:

    nix-bitcoin-wg-connect 93.184.216.34
    nix-bitcoin-wg-connect mynode.example.com
    
    # For debugging: Show the WireGuard config as text
    nix-bitcoin-wg-connect --text mynode.example.com
    

    The address is required. nix-bitcoin-wg-connect doesn’t look up your node’s public IP, since that would reveal it to public IP lookup services over clearnet. Behind NAT, your router shows the public IP. For a device that connects only from your local network, you can pass the node’s LAN IP instead.

    In the WireGuard app, add a tunnel by scanning the QR code.

  6. Set up ZEUS

    Run the following command on your node (as user operator) to create a QR code for ZEUS:

    For LND

    lndconnect-wg
    

    For Core Lightning

    lnconnect-clnrest-wg
    

    In ZEUS, add a new node and scan the QR code. The QR code contains no TLS certificate, so ZEUS may warn about it; the WireGuard tunnel encrypts the connection.

To print the connection URL as text instead, run lndconnect-wg --url or lnconnect-clnrest-wg --url.

WireGuard firewall compatibility

The preset guards the REST API with networking.firewall.extraCommands rules. They need the iptables firewall backend and iptables on the firewall service’s PATH, and firewalld isn’t supported. networking.nftables can stay enabled if you set networking.firewall.backend = "iptables" and networking.firewall.package = pkgs.iptables (or add pkgs.iptables to networking.firewall.extraPackages). Then put your own nftables rules in networking.nftables.tables and keep networking.nftables.flushRuleset = false. Flushing the ruleset deletes the preset’s rules. It’s on by default when networking.nftables.ruleset or rulesetFile is set or system.stateVersion is older than 23.11. Don’t name a table filter in the ip or ip6 family, since iptables keeps its rules there.

Neither applies when the firewall runs pkgs.iptables-legacy, whose rules live outside the nftables ruleset: set it as networking.firewall.package, or keep the default nftables package and put it first in networking.firewall.extraPackages. iptables-legacy needs a kernel with legacy xtables (CONFIG_NETFILTER_XTABLES_LEGACY, or CONFIG_IP_NF_IPTABLES_LEGACY on older kernels). The default kernel doesn’t enable them, and firewall.service then fails to start. pkgs.linuxPackages_6_12 has them, so set boot.kernelPackages to it and reboot.

If you fix either of these on a running node, run systemctl restart firewall once after deploying, since the first reload still runs the old deletions.

Trezor

Initialize a Trezor for the Bitcoin Hardware Wallet Interface (HWI) and use it with your node.

The examples assume the secure-node.nix preset; see Using services.

  1. Enable Trezor support in your configuration:

    services.hardware-wallets.trezor = true;
    

    This installs hwi, trezorctl and lsusb, and adds udev rules that give group hardware-wallets access to the device. Only members of that group can use it, unless you run the Trezor Bridge (see below). The operator user is in that group. Hardware wallets require the bitcoind wallet, so services.bitcoind.disablewallet must stay unset or false.

  2. Deploy your configuration.

  3. Plug in your Trezor and check that your node recognizes it:

    ssh operator@bitcoin-node
    lsusb
    
  4. If your Trezor’s firmware is outdated, update it:

    trezorctl firmware update
    

    Keep your recovery seed at hand: a firmware update can wipe the device. See Trezor’s firmware guide for the bootloader mode of your model.

  5. If your Trezor is not yet initialized, set it up with a PIN:

    trezorctl device setup -p
    
  6. Find your Trezor:

    hwi enumerate
    

    A Trezor One asks for its PIN through HWI:

    hwi -t trezor -d <path from previous command> promptpin
    hwi -t trezor -d <path> sendpin <number positions for the PIN as displayed on your device's screen>
    hwi enumerate
    
  7. Follow HWI’s guide on using Bitcoin Core with hardware wallets to use your Trezor with bitcoin-cli on your node.

The Trezor Bridge (trezord) doesn’t run by default, since HWI and trezorctl don’t need it. To run it for apps that use it, set services.hardware-wallets.trezorBridge = true;. The bridge serves an HTTP API without authentication on 127.0.0.1:21325, so every local user and service can then use the Trezor through it.

LND

The examples assume the secure-node.nix preset; see Using services.

Custom macaroons

services.lnd.macaroons.<name> gives a service its own macaroon with only the permissions it needs. Each time lnd starts, bitcoinix creates the macaroon at /run/lnd/<name>.macaroon, readable only by user. BTCPay Server, charge-lnd, RTL and Unbeholden LNURL on lnd get their macaroons this way.

services.lnd.macaroons.myapp = {
  user = "myapp";
  permissions = ''{"entity":"info","action":"read"},{"entity":"invoices","action":"write"}'';
};

A uri permission, like {"entity":"uri","action":"/lnrpc.Lightning/GetInfo"}, allows one RPC. When lnd doesn’t have the RPC of a uri permission in permissions, for example because its name has a typo, lnd’s start fails. Some RPCs, like those of walletrpc, exist only when lnd’s package has their build tag. Put the uri permissions for these RPCs in optionalPermissions, in the same format. When lnd doesn’t have one of these RPCs, the macaroon doesn’t get its permission, and lnd’s start logs a warning.

Root keys and configuration changes

Each custom macaroon has its own lnd root key. Its ID, services.lnd.macaroons.<name>.rootKeyId, is derived from the name, user, permissions and optional permissions, so copies of the macaroon stay valid when lnd restarts. A change of one of them gives the macaroon a new ID. Each time lnd starts, bitcoinix deletes the root key of every ID from 7953919891889717248 to 7954201366866427903 (0x6e62000000000000 to 0x6e62ffffffffffff) that no configured macaroon uses. If it deleted a root key, it restarts lnd once more, which closes the connections that use these macaroons. If this restart fails while the old lnd process still runs, it stops lnd. So when you change or remove a macaroon, its copies stop working when lnd restarts during the deployment. Until then, a leaked copy keeps working. Copies created before bitcoinix 0.1.6 are an exception: they use root key 0 and stay valid until you revoke all macaroons. Don’t use IDs in this range for macaroons that you bake yourself.

bitcoinix creates the macaroons and deletes the stale root keys with lncli, lnd’s admin macaroon and gRPC. It does this each time lnd starts, also without custom macaroons, so lnd must keep its macaroons enabled: the no-macaroons option isn’t supported.

Restart services after macaroon changes

A service that reads its macaroon only at startup must restart to read the new macaroon. Restart it on deployments that change the macaroon:

systemd.services.myapp.restartTriggers = [ config.services.lnd.macaroons.myapp.rootKeyId ];

A change of lnd’s package can add or remove optional permissions without a new ID. So if the macaroon has optional permissions, also add config.services.lnd.package to the triggers.

BTCPay Server reads its macaroon for each request to lnd, and charge-lnd for each run. RTL copies its macaroon when it starts, and it restarts with lnd.

Revoke a macaroon

To revoke all copies of a macaroon without changing its configuration:

  1. Find the root key ID of the macaroon in lnd’s log:
    journalctl -b -u lnd --grep 'Create custom macaroon myapp'
    
    lncli listmacaroonids lists all root key IDs.
  2. Delete the root key: lncli deletemacaroonid <ID>
  3. Restart lnd: systemctl restart lnd. This closes the connections that use the macaroon. lnd creates a new root key with the same ID, and bitcoinix creates a new /run/lnd/myapp.macaroon.
  4. Restart the service that uses the macaroon.

Revoke all macaroons

lnd’s default macaroons, like admin.macaroon, share root key 0, and so do custom macaroons created before bitcoinix 0.1.6. lnd can’t delete root key 0. To revoke these macaroons, replace all root keys. lncli changepassword --new_mac_root_key doesn’t work on bitcoinix, because lnd unlocks the wallet when it starts. Instead, delete the macaroon database and the macaroon files in the lnd network dir (services.lnd.networkDir) while lnd is stopped. This works with lnd’s default database backend (bbolt). With another db.backend in services.lnd.extraConfig, the root keys are in that database instead. Run as root:

  1. Keep a copy of the current admin macaroon, to check at the end that old macaroons stop working:
    runuser -u lnd -- cp /var/lib/lnd/chain/bitcoin/mainnet/admin.macaroon /var/lib/lnd/old-admin.macaroon
    
    Then stop lnd and the units that can start it, so that none starts lnd during the next step: charge-lnd.timer and the services that require or want lnd. systemctl list-dependencies --reverse lnd.service lists them. For example, with charge-lnd, BTCPay Server and RTL (leave out the ones your node doesn’t have):
    systemctl stop charge-lnd.timer charge-lnd btcpayserver rtl lnd
    
  2. Delete the files as the lnd user, here for the default mainnet dir:
    runuser -u lnd -- sh -c 'cd /var/lib/lnd/chain/bitcoin/mainnet && rm -f macaroons.db *.macaroon'
    
  3. Restart lnd, so that a fresh process opens the new database. Check that the new admin macaroon works and the old copy doesn’t:
    systemctl restart lnd
    lncli --profile= getinfo
    lncli --profile= --macaroonpath /var/lib/lnd/old-admin.macaroon getinfo
    
    --profile= makes lncli ignore a saved default profile. The first getinfo must work and the second must fail with an authentication error. If not, a unit (bitcoind too) started lnd during step 2. Run the stop command from step 1 again, then steps 2 and 3, and keep the old copy. Then delete the copy: runuser -u lnd -- rm /var/lib/lnd/old-admin.macaroon.
  4. Start the units that you stopped, for example systemctl start charge-lnd.timer btcpayserver rtl. RTL copies its macaroon when it starts.

lnd creates new root keys and new default macaroons, and bitcoinix creates new custom macaroons. All earlier macaroons stop working. Then:

  • Create new connection URLs with lndconnect or lndconnect-wg and connect your wallets again.
  • Bake new macaroons for the macaroons that you baked yourself.

Core Lightning

The examples assume the secure-node.nix preset; see Using services.

Core Lightning (CLN), formerly c-lightning, uses the services.clightning options, clightning systemd service, and lightning-cli command in bitcoinix.

Plugins

There are a number of plugins available for Core Lightning. See README: Features → Core Lightning or the services.clightning.plugins module options for a complete list.

You can activate and configure these plugins like so:

services.clightning = {
  enable = true;
  plugins = {
    clboss.enable = true;
    clboss.min-onchain = 40000;
  };
};

Please have a look at the module for a plugin (e.g. clboss.nix) to learn its configuration options.

Currency rates

Enable the Rust cln-currencyrate plugin:

services.clightning.plugins.currencyrate.enable = true;

Use lightning-cli currencyconvert 100 USD to convert a fiat amount into millisatoshis, lightning-cli listcurrencyrates USD to list source prices in USD per BTC, or lightning-cli currencyrate USD to get the median rate.

For custom price sources, set currencyrate-add-source and currencyrate-disable-source in services.clightning.extraConfig; see the upstream plugin documentation. The plugin follows CLN’s configured proxy and shares its service sandbox and network namespace.

If you used the former Python plugin, follow the currencyrate migration instructions.

Trustedcoin

When services.clightning.tor.proxy is enabled, trustedcoin also uses Tor for all external connections by default. In this case, connections to block explorers can sometimes get blocked.

An example of Core Lightning log error output when connections are getting blocked:

lightningd[5138]: plugin-trustedcoin estimatefees error: https://blockstream.info/api error: 403 Forbidden
lightningd[4933]: plugin-trustedcoin getblock error: got something that isn't a block hash: <html><head>...

To work around this and connect via clearnet instead, set this option:

services.clightning.plugins.trustedcoin.tor.proxy = false;

This also disables services.clightning.tor.enforce, so the whole clightning service is no longer restricted to Tor.

Core Lightning database replication

Core Lightning can write a live copy of its database to a local path or to a remote SSH target (mounted via SSHFS). Optionally, the copy can be encrypted with gocryptfs. See the module for all options.

The replica filename is lightningd-signet.sqlite3 on signet and lightningd-testnet4.sqlite3 on testnet4. Mainnet and regtest both use lightningd.sqlite3. Give those two networks separate replication destinations to keep one from overwriting the other’s replica.

clightning requires the replication target: it doesn’t start while the target is unavailable, e.g. when the SSHFS mount fails. For a local directory, this works only when systemd knows the mount that holds the directory. See Local directory target.

Also back up:

  • the static file hsm_secret (/var/lib/clightning/bitcoin/hsm_secret by default). The services.backups module includes it.
  • with encrypt, the password $secretsDir/clightning-replication-password. Without it, the copy can’t be decrypted. services.backups includes the secrets dir only with nix-bitcoin.generateSecrets.

Remote target via SSHFS

  1. Add this to your configuration:

    services.clightning.replication = {
      enable = true;
      sshfs.destination = "user@hostname:directory";
      # This is optional
      encrypt = true;
    };
    programs.ssh.knownHosts."hostname".publicKey = "<contents of /etc/ssh/ssh_host_ed25519_key.pub on the target>";
    

    Leave out the encrypt line if you want to store data on your destination in plaintext.
    Adjust user, hostname and directory as necessary. directory is relative to the home of user. If the target’s SSH server doesn’t listen on port 22, set sshfs.port and use "[hostname]:<port>" as the knownHosts name.

    The knownHosts entry is required: the mount runs without a terminal, so SSH can’t ask you to accept an unknown host key and the mount fails. Read the host key on the target itself, not with ssh-keyscan from the node, which trusts whatever host answers. Don’t add StrictHostKeyChecking=no to sshfs.sshOptions. It allows any host on the network path to impersonate the target and receive the database, in plaintext without encrypt.

  2. Deploy. With nix-bitcoin.generateSecrets, this creates the SSH key $secretsDir/clightning-replication-ssh-key. clightning starts only once the target accepts this key (step 3).

  3. To allow SSH access from the bitcoinix node to the target node, either use the remote node config below, or copy the contents of $secretsDir/clightning-replication-ssh-key.pub to the authorized_keys file of user (or use ssh-copy-id). Then run systemctl restart clightning as root.

  4. You can restrict the bitcoinix node’s capabilities on the SSHFS target to SFTP access in a chroot. To implement this on NixOS, add the following to the NixOS configuration of the SSHFS target node:

    systemd.tmpfiles.rules = [
      # Because this directory is chrooted by sshd, it must only be writable by user/group root
      "d /var/backup/nb-replication 0755 root root - -"
      "d /var/backup/nb-replication/writable 0700 nb-replication - - -"
    ];
    
    services.openssh = {
      extraConfig = ''
        Match user nb-replication
          ChrootDirectory /var/backup/nb-replication
          AllowTcpForwarding no
          AllowAgentForwarding no
          ForceCommand internal-sftp
          PasswordAuthentication no
          X11Forwarding no
      '';
    };
    
    users.users.nb-replication = {
      isSystemUser = true;
      group = "nb-replication";
      shell = "${pkgs.coreutils}/bin/false";
      openssh.authorizedKeys.keys = [ "<contents of $secretsDir/clightning-replication-ssh-key.pub>" ];
    };
    users.groups.nb-replication = {};
    

    With this setup, the corresponding sshfs.destination on the bitcoinix node is "nb-replication@hostname:writable".

Local directory target

  1. Add this to your configuration:

    services.clightning.replication = {
      enable = true;
      local.directory = "/var/backup/clightning";
      encrypt = true;
    };
    

    Leave out the encrypt line if you want to store data in local.directory in plaintext.

  2. Deploy

Core Lightning will now replicate database files to local.directory. This can be used to replicate to an external HDD by mounting it at path local.directory.

clightning requires the mounts for local.directory. With encrypt, clightning-replication-mounts requires them too. While the disk isn’t mounted, clightning doesn’t start, so the replica can’t land on the primary disk. systemd can only wait for the mounts it knows, so declare the disk in fileSystems:

fileSystems."/var/backup/clightning" = {
  device = "/dev/disk/by-uuid/<uuid of the disk's filesystem>";
  fsType = "ext4";
  # Boot without the disk. clightning stays stopped then.
  options = [ "nofail" ];
};

systemd finds the mounts from the path as written and doesn’t follow symlinks. So set local.directory to the mount point or a directory below it, not to a symlink. A directory on the root filesystem has no mount to wait for.

Custom remote destination

Follow the steps in section “Local directory target” above and mount a custom remote destination (e.g., an NFS or SMB share) to local.directory. Declare the share in fileSystems, so that clightning doesn’t start without it.
You might want to disable local.setupDirectory in order to create the mount directory yourself with custom permissions.

Module options

These are the options of the bitcoinix modules in this release, with their types, defaults and examples. Filter the list by name or description in the field below, or use the search in the menu bar to search the whole documentation. The NixOS options are in the NixOS options search.

nix-bitcoin.configVersion

The released nix-bitcoin version whose configuration migrations you have completed.

When upgrading to a backwards-incompatible release, nix-bitcoin will throw an error during evaluation and provide instructions for migrating your config to the new release.

On master, unreleased migrations warn without blocking deployment or requiring acknowledgement. Review them before deploying; warnings cannot be acknowledged individually and repeat while applicable. Values newer than the latest finalized release are rejected. If unset, migration notices are disabled.

Type: null or string

Default:

null

Example:

"0.0.92"

Declared by:

nix-bitcoin.deployment.secretsDir

Directory of local secrets that are transferred to the bitcoinix node on deployment

Type: absolute path

Declared by:

nix-bitcoin.generateSecrets

Automatically generate all required secrets before services are started. Note: Make sure to create a backup of the generated secrets.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.generateSecretsCmds

Bash expressions for generating secrets, run in nix-bitcoin.secretsDir by the sandboxed setup-secrets service. Commands have no IP network access and can write only to the secrets directory and private temporary directories. Temporary files are not shared with other services. Commands requiring writable executable memory (such as JIT compilation) or setuid/setgid file modes are blocked.

To generate all secrets separately, supply them before setup-secrets starts and disable nix-bitcoin.generateSecrets.

Type: attribute set of strings concatenated with “\n”

Default:

{ }

Declared by:

nix-bitcoin.lib

Helpers shared by the bitcoinix modules, defined in pkgs/lib.nix. defaultHardening holds the systemd sandboxing settings that most bitcoinix services run with. They deny all IP traffic, so merge them with allowLocalIPAddresses or allowAllIPAddresses for a service that needs the network:

systemd.services.<name>.serviceConfig = with config.nix-bitcoin.lib;
  defaultHardening // allowLocalIPAddresses;

allowLocalIPAddresses allows localhost and, with netns-isolation, the namespace addresses 169.254.<addressblock>.0/24. It also hides the nscd, systemd-resolved and D-Bus sockets (and Avahi’s, when enabled) from the service, so it resolves names only from /etc/hosts or through a resolver on an allowed address.

Type: unspecified value (read only)

Default:

"nix-bitcoin/pkgs/lib.nix"

Declared by:

nix-bitcoin.mkLndconnect

A function to create a lndconnect binary. See the source for further details.

Type: unspecified value (read only)

Default:

<function, args: {authSecretPath, certPath?, enableOnion, getCertPathCmd?, isClnrest?, name, onionService?, port, secretsOwner?, shebang?, userOnionService?}>

Declared by:

nix-bitcoin.netns-isolation.enable

Whether to enable netns isolation.

Type: boolean

Default:

false

Example:

true

Declared by:

nix-bitcoin.netns-isolation.addressblock

The address block N in 169.254.N.0/24, used as the prefix for netns addresses. 169 and 170 aren’t allowed, because those blocks hold cloud metadata addresses.

Type: 8 bit unsigned integer; between 0 and 255 (both inclusive)

Default:

1

Declared by:

nix-bitcoin.netns-isolation.bridgeIp

IP of the netns bridge interface.

Type: unspecified value (read only)

Default:

"169.254.1.10"

Declared by:

nix-bitcoin.netns-isolation.netns

Exposes netns parameters.

Type: unspecified value (read only)

Default:

{ }

Declared by:

nix-bitcoin.netns-isolation.restrictForwarding

Whether the host forwards only the traffic of the namespaces, that is the connections that a namespace opens and their replies. The host then drops all other forwarded IPv4 traffic, so a host on one of the node’s networks can’t reach another network through the node.

Set this to false when the node routes for other networks on purpose, e.g. with networking.nat, Docker or a Tailscale subnet router. netns-isolation then adds no forwarding rules, and the host forwards between all its interfaces unless you filter this yourself.

Type: boolean

Default:

true

Declared by:

nix-bitcoin.netns-isolation.services

Services that run in their own network namespace nb-<name>, keyed by the name of the service under services, e.g. bitcoind. An entry takes effect only while that service is enabled. The bitcoinix modules define the entries for the supported services.

A namespace accepts incoming connections only from itself, from the host and from the namespaces linked by connections. Connections from the host come from the bridge address 169.254.<addressblock>.10, so every process in the host network namespace can reach the service, not only the services listed in connections. Services with tor.enforce can also connect only to these addresses.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nix-bitcoin.netns-isolation.services.<name>.connections

Services whose namespaces may exchange connections with this service’s namespace. A connection works in both directions: clightning.connections = [ "bitcoind" ] also lets bitcoind connect to clightning. Entries for disabled services are ignored.

Type: list of string

Default:

[ ]

Declared by:

nix-bitcoin.netns-isolation.services.<name>.id

id for the netns, used for the IP address host part and for naming the interfaces. Must be unique. Must be greater than 10.

Type: integer between 11 and 255 (both inclusive)

Declared by:

nix-bitcoin.nodeinfo.enable

Whether to enable nodeinfo.

Type: boolean

Default:

false

Example:

true

Declared by:

nix-bitcoin.onionAddresses.access

This option controls who is allowed to access onion addresses. For example, the following allows user ‘myuser’ to access bitcoind and clightning onion addresses:

{
  "myuser" = [ "bitcoind" "clightning" ];
};

The onion hostnames can then be read from /var/lib/onion-addresses/myuser.

Type: attribute set of list of string

Default:

{ }

Declared by:

nix-bitcoin.onionAddresses.services

Services that can access their onion address via file /var/lib/onion-addresses/<service> The file is readable only by the service user.

Type: list of string

Default:

[ ]

Declared by:

nix-bitcoin.onionServices

Tor onion services for incoming connections to bitcoinix services, keyed by the name of the service under services, e.g. bitcoind. An entry takes effect only while that service is enabled. The presets enable-tor.nix and secure-node.nix enable onion services for the supported services.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nix-bitcoin.onionServices.<name>.enable

Create an onion service for the given service. The service must define options address and onionPort (or port).

Type: boolean

Default:

false

Declared by:

nix-bitcoin.onionServices.<name>.externalPort

Override the external port of the onion service.

Type: null or 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

null

Declared by:

nix-bitcoin.onionServices.<name>.public

Make the onion address accessible to the service. If enabled, the onion service is automatically enabled. Only available for services that define option getPublicAddressCmd.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.operator.enable

Whether to define a user named operator for convenient interactive access to bitcoinix features (like bitcoin-cli).

When using nix-bitcoin as part of a larger system config, it makes sense to set your main system user as the operator, by setting option nix-bitcoin.operator.name = "MAIN_USER_NAME";.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.operator.allowRunAsUsers

Users as which the operator is allowed to run commands.

Type: list of string

Default:

[ ]

Declared by:

nix-bitcoin.operator.groups

Extra groups of the operatur user.

Type: list of string

Default:

[ ]

Declared by:

nix-bitcoin.operator.name

Name of the operator user.

Type: string

Default:

"operator"

Declared by:

nix-bitcoin.pkgs

The packages that the bitcoinix services run: the packages defined in pkgs/ and the service packages selected from nixpkgs. Refer to a package as config.nix-bitcoin.pkgs.<name>, e.g. config.nix-bitcoin.pkgs.bitcoind.

Type: attribute set

Default:

"nix-bitcoin/pkgs.modulesPkgs"

Declared by:

nix-bitcoin.revision

The bitcoinix git commit that this system is built from. nixosModules.default of the bitcoinix flake sets this to the flake’s revision (<rev>-dirty for a checkout with uncommitted changes). It is null when the flake source has no revision or when the modules are imported without the flake. Shown by nodeinfo.

Type: null or string

Default:

null

Example:

"6d209ffe17e13abe15f5d368e18f14436019d317"

Declared by:

nix-bitcoin.secrets

Secret files in nix-bitcoin.secretsDir that the enabled services use, keyed by file name, with the owner and permissions each file needs. The services declare their own secrets here.

With nix-bitcoin.setupSecrets, setup-secrets applies these owners and permissions before the services start. With nix-bitcoin.secretsSetupMethod = "manual", set them yourself.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

nix-bitcoin.secrets.<name>.allowEmpty

Whether setup-secrets accepts an empty file for this secret. Otherwise, an empty file fails setup like a missing one.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.secrets.<name>.group

Group of the secret file.

Type: string

Default:

user

Declared by:

nix-bitcoin.secrets.<name>.permissions

Mode of the secret file, in the octal notation of chmod.

Type: string

Default:

"440"

Declared by:

nix-bitcoin.secrets.<name>.user

User that owns the secret file.

Type: string

Default:

"root"

Declared by:

nix-bitcoin.secretsDir

Directory to store secrets

Type: absolute path

Default:

"/etc/nix-bitcoin-secrets"

Declared by:

nix-bitcoin.secretsSetupMethod

How the secrets in nix-bitcoin.secretsDir are provided. Evaluation fails while this is null. Values:

  • "setup-secrets": set automatically when nix-bitcoin.setupSecrets or nix-bitcoin.generateSecrets is enabled.
  • "nixops": set by the NixOps deployment module.
  • "manual": you provide the secrets and set the owners and permissions declared in nix-bitcoin.secrets yourself, before the services start.

For any value other than "manual", nix-bitcoin-secrets.target is started on every activation, and services start after it. A custom deployment method can set its own value and order its secrets setup before this target.

Type: null or string

Default:

null

Declared by:

nix-bitcoin.security.dbusHideProcessInformation

Only allow users with group proc to retrieve systemd unit information like cgroup paths (i.e. (sub)process command lines) via D-Bus.

This mitigates a systemd security issue where (sub)process command lines can be retrieved by services even when their access to /proc is restricted (via ProtectProc).

This option works by restricting the D-Bus method GetUnitProcesses, which is also used internally by systemctl status.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.setupSecrets

Set permissions for existing secrets in nix-bitcoin.secretsDir before services are started.

The directory is accessible only to root while permissions are set. A failed run leaves it that way until setup succeeds, so services cannot read any of its secrets. Declared secrets must be writable inside the setup-secrets sandbox; symlinks to files outside the secrets directory can cause setup to fail.

Type: boolean

Default:

false

Declared by:

nix-bitcoin.useVersionLockedPkgs

Use the nixpkgs version locked by this flake for nix-bitcoin.pkgs. Only relevant if you are using a nixpkgs version for evaluating your system that differs from the one that is locked by this flake (via input nixpkgs). If this is the case, enabling this option uses the tested package set for bitcoinix services, unless you override this flake’s nixpkgs input (for example with bitcoinix.inputs.nixpkgs.follows). The downsides are increased evaluation times and increased system closure size. The system’s nixpkgs.overlays and nixpkgs.config do not apply to these pinned packages. System evaluation requires unstable nixpkgs regardless of this option.

If false, the default system pkgs are used. Use an unstable nixpkgs for your system; release branches are not supported. All nixpkgs service packages then follow your system’s pin, including lnd and clightning. Review their versions before updating: downgrades may be incompatible with existing databases.

Type: boolean

Default:

true

Declared by:

services.backups.enable

Enable backups of node data. This uses the NixOS duplicity service. To further configure the backup, you can set NixOS options services.duplicity.*. The services.duplicity.cleanup.* options are particularly useful.

If a database dump or a wallet/mint snapshot fails, the duplicity unit still backs up all other files and then fails.

When cdk-mintd is enabled, briefly stop it to snapshot its complete data directory and signing secrets, then restart it if it was running. Only the staged copy is archived, never the live mint databases.

The backup leaves out the Lightning channel databases, because restoring a copy of them can lose all funds in their channels. See docs/service/backups.md.

With nix-bitcoin.generateSecrets, the backups are encrypted with the generated password backup-encryption-password in nix-bitcoin.secretsDir. The backups include it, but you need it to decrypt them. Keep a copy off the node.

Type: boolean

Default:

false

Declared by:

services.backups.destination

Where to back up to.

Type: string

Default:

"file:///var/lib/localBackups"

Declared by:

services.backups.extraFiles

Additional files to be appended to filelist.

Type: list of string

Default:

[ ]

Example:

[
  "/var/lib/nginx"
]

Declared by:

services.backups.frequency

Run backup with the given frequency. If null, do not run automatically.

Type: null or string

Default:

null

Declared by:

services.backups.postgresqlDatabases

List of database names to backup. Don’t list the database of Core Lightning when it uses PostgreSQL. A dump is an outdated copy of its channel state, and restoring it can lose all funds in its channels.

Type: list of string

Default:

[ ]

Declared by:

services.backups.with-bulk-data

Whether to also backup Bitcoin blockchain and other bulk data.

Type: boolean

Default:

false

Declared by:

services.bitcoind.enable

Whether to enable Bitcoin daemon.

Type: boolean

Default:

false

Example:

true

Declared by:

services.bitcoind.addnodes

Add nodes to connect to and attempt to keep the connections open

Type: list of string

Default:

[ ]

Example:

[
  "ecoc5q34tmbq54wl.onion"
]

Declared by:

services.bitcoind.address

Address to listen for peer connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.bitcoind.addresstype

The type of addresses to use

Type: null or string

Default:

null

Example:

"bech32"

Declared by:

services.bitcoind.assumevalid

If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification.

Type: null or string

Default:

null

Example:

"00000000000000000000e5abc3a74fe27dc0ead9c70ea1deb456f11c15fd7bc6"

Declared by:

services.bitcoind.cli

Binary to connect with the bitcoind instance.

Type: package (read only)

Default:

"(See source)"

Declared by:

services.bitcoind.dataDir

The data directory for bitcoind.

Type: absolute path

Default:

"/var/lib/bitcoind"

Declared by:

services.bitcoind.dataDirReadableByGroup

If enabled, the bitcoind service group can read the blocks dir with the block files and the block index, including the files that bitcoind creates while it runs. To reach it, the group can search the data dir and the selected network’s subdirectory. Where these have an ACL, the group’s rights are added to it, and all other users and groups keep their effective rights. The blocks dir and the dirs between it and the data dir must not be symlinks, and symlinks in the blocks dir aren’t followed. A custom blocksdir in extraConfig isn’t covered. The bitcoind-group-read service sets this up before each start of bitcoind. It sets a default ACL, which needs POSIX ACL support on the filesystem of the blocks dir (on ZFS, acltype=posixacl). Without it, the service logs a warning, and the group can read only the files that exist when bitcoind starts. Disabling this option doesn’t revoke the access that it granted, and the group can still read the files that bitcoind creates later. To revoke it, run setfacl -P -R -n -m g::-,d:g::- on the blocks dir. On regtest, signet and testnet4, also run setfacl -P -n -m g::- on the network subdirectory. Run these commands as the bitcoind user, for example with runuser -u bitcoin --. Older versions let group members put a symlink in the data dir. -P keeps setfacl from following one at the end of the path, and as the bitcoind user, one before it can only lead to that user’s own files. Warning: This disables bitcoind’s wallet support.

Type: boolean

Default:

false

Declared by:

services.bitcoind.dbCache

Override the default database cache size in MiB.

Type: null or integer >= 4

Default:

null

Example:

4000

Declared by:

services.bitcoind.disablewallet

Do not load the wallet and disable wallet RPC calls

Type: null or boolean

Default:

null

Declared by:

services.bitcoind.discover

Discover own IP addresses

Type: null or boolean

Default:

null

Declared by:

services.bitcoind.extraConfig

Extra lines appended to bitcoin.conf.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

Type: strings concatenated with “\n”

Default:

""

Example:

''
  par=16
  logips=1
''

Declared by:

services.bitcoind.getPublicAddressCmd

Bash expression which outputs the public service address to announce to peers. If left empty, no address is announced. The service fails to start when the command fails or prints nothing.

Type: string

Default:

""

Declared by:

services.bitcoind.group

The group as which to run bitcoind.

Type: string

Default:

"bitcoin"

Declared by:

services.bitcoind.i2p

Enable peer connections via i2p. With only-outgoing, incoming i2p connections are disabled.

Type: one of false, true, “only-outgoing”

Default:

false

Declared by:

services.bitcoind.listen

Listen for peer connections at address:port and address:onionPort (if onionPort is set).

Type: boolean

Default:

false

Declared by:

services.bitcoind.listenWhitelisted

Listen for peer connections at address:whitelistedPort. Peers connected through this socket are automatically whitelisted.

Type: boolean

Default:

false

Declared by:

services.bitcoind.network

Bitcoin network used by the deployment’s services. Use signet or testnet4 for a public test network. Use regtest for a local regression testing network. Evaluation fails if an enabled service is incompatible with the network.

Type: one of “mainnet”, “regtest”, “signet”, “testnet4”

Default:

"mainnet"

Declared by:

services.bitcoind.networkDir

The directory where Bitcoin Core stores data for the selected network.

Type: absolute path (read only)

Default: dataDir on mainnet, dataDir/network on other networks.

Declared by:

services.bitcoind.onionPort

Port to listen for Tor peer connections. If set, inbound connections to this port are tagged as onion peers.

Type: null or 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default: null when the bitcoind onion service is disabled, otherwise 8334 on mainnet, 18445 on regtest, 38334 on signet, 48334 on testnet4.

Declared by:

services.bitcoind.port

Port to listen for peer connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default: 8333 on mainnet, 18444 on regtest, 38333 on signet, 48333 on testnet4

Declared by:

services.bitcoind.proxy

Connect through SOCKS5 proxy

Type: null or string

Default:

null

Declared by:

services.bitcoind.prune

Automatically prune block files to stay under the specified target size in MiB. Value 0 disables pruning.

Type: unsigned integer, meaning >=0

Default:

0

Example:

10000

Declared by:

services.bitcoind.rest.enable

Enable the REST interface. It is served on the RPC address and port without authentication. Every source allowed by rpc.allowip can query blocks, transactions, the UTXO set and the mempool, bypassing RPC users and rpcwhitelist.

Type: boolean

Default:

false

Declared by:

services.bitcoind.rest.allowNonLocal

Allow enabling the REST interface when rpc.allowip contains sources other than localhost and nix-bitcoin’s network namespaces. These sources get unauthenticated REST access. For loopback, use 127.0.0.1, 127.0.0.1/32, 127.0.0.0/8, ::1 or ::1/128 in rpc.allowip. Also accepts rpcallowip and includeconf directives in extraConfig (see rest.allowUncheckedConfig).

Type: boolean

Default:

false

Declared by:

services.bitcoind.rest.allowUncheckedConfig

Allow enabling the REST interface when extraConfig contains rpcallowip or includeconf directives. Their effective allowlist is not checked, so review all raw and included settings first. Unlike rest.allowNonLocal, this keeps the check of rpc.allowip.

Type: boolean

Default:

false

Declared by:

services.bitcoind.rpc.address

Address to listen for JSON-RPC connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.bitcoind.rpc.allowip

Allow JSON-RPC connections from specified sources.

Type: list of string

Default:

[
  "127.0.0.1"
]

Declared by:

services.bitcoind.rpc.port

Port to listen for JSON-RPC connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default: 8332 on mainnet, 18443 on regtest, 38332 on signet, 48332 on testnet4

Declared by:

services.bitcoind.rpc.threads

The number of threads to service RPC calls.

Type: null or 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

null

Declared by:

services.bitcoind.rpc.users

Allowed users for JSON-RPC connections.

Type: attribute set of (submodule)

Default:

{ }

Example:

{
  alice = {
    passwordHMAC = "f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae";
    rpcwhitelist = [
      "sendtoaddress"
      "getnewaddress"
    ];
  };
}

Declared by:

services.bitcoind.rpc.users.<name>.name

Username for JSON-RPC connections.

Type: string

Default:

"‹name›"

Example:

"alice"

Declared by:

services.bitcoind.rpc.users.<name>.passwordHMAC

Password HMAC-SHA-256 for JSON-RPC connections. Must be a string of the format <SALT-HEX>$<HMAC-HEX>.

This value is written to the world-readable Nix store. Any local user can read it and test password guesses offline. So use a long random password, like the one that Bitcoin Core’s share/rpcauth/rpcauth.py generates when you don’t pass a password.

Type: string

Example:

"f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae"

Declared by:

services.bitcoind.rpc.users.<name>.rpcwhitelist

List of allowed rpc calls for each user. If empty list, rpcwhitelist is disabled for that user.

Type: list of string

Default:

[ ]

Declared by:

services.bitcoind.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.bitcoind.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.bitcoind.txindex

Enable the transaction index.

Type: boolean

Default:

false

Declared by:

services.bitcoind.user

The user as which to run bitcoind.

Type: string

Default:

"bitcoin"

Declared by:

services.bitcoind.whitelistedPort

See listenWhitelisted.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8335

Declared by:

services.bitcoind.zmqpubrawblock

ZMQ address for zmqpubrawblock notifications

Type: null or string

Default:

null

Example:

"tcp://127.0.0.1:28332"

Declared by:

services.bitcoind.zmqpubrawtx

ZMQ address for zmqpubrawtx notifications

Type: null or string

Default:

null

Example:

"tcp://127.0.0.1:28333"

Declared by:

services.btcpayserver.enable

Whether to enable btcpayserver, a self-hosted Bitcoin payment processor.

Type: boolean

Default:

false

Example:

true

Declared by:

services.btcpayserver.package

The package providing btcpayserver binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.btcpayserver"

Declared by:

services.btcpayserver.address

Address to listen on.

Type: string

Default:

"127.0.0.1"

Declared by:

services.btcpayserver.dataDir

The data directory for btcpayserver.

Type: absolute path

Default:

"/var/lib/btcpayserver"

Declared by:

services.btcpayserver.group

The group as which to run btcpayserver.

Type: string

Default:

"btcpayserver"

Declared by:

services.btcpayserver.lightningBackend

The lightning node implementation to use.

With clightning, BTCPay Server has full control of the Lightning node, including its funds. It uses lightningd’s RPC socket, which allows every method, like pay, withdraw and fundchannel. With lnd, BTCPay Server gets its own macaroon, which can’t send funds or open or close channels. Use lnd when you want BTCPay Server limited. Neither backend limits a hot wallet in BTCPay Server. Switching away from clightning stops Core Lightning unless services.clightning.enable is set, and then lnd needs another port than Core Lightning. See docs/service/btcpayserver.md, “Lightning backend”.

Type: null or one of “clightning”, “lnd”

Default:

null

Declared by:

services.btcpayserver.port

Port to listen on.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

23000

Declared by:

services.btcpayserver.rootpath

The prefix for root-relative btcpayserver URLs.

Type: null or string

Default:

null

Example:

"btcpayserver"

Declared by:

services.btcpayserver.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.btcpayserver.user

The user as which to run btcpayserver.

Type: string

Default:

"btcpayserver"

Declared by:

services.cdk-mintd.enable

Whether to enable cdk-mintd, a Cashu ecash mint.

Type: boolean

Default:

false

Example:

true

Declared by:

services.cdk-mintd.package

Package providing the cdk-mintd binary.

Type: package

Default:

"config.nix-bitcoin.pkgs.cashu-cdk"

Declared by:

services.cdk-mintd.address

HTTP listen address. Use a reverse proxy for public HTTPS access.

Type: string

Default:

"127.0.0.1"

Declared by:

services.cdk-mintd.allowNewMint

Allow initializing an empty database after a mint has already been initialized on this node. Only use this to deliberately replace a mint with a new signing seed, never to recover missing mint data. Reusing a seed without its spent-proof database can allow double spending. Set back to false after initialization. The first mint needs no override.

Type: boolean

Default:

false

Declared by:

services.cdk-mintd.backend

Local Lightning backend, enabled automatically. LND uses a restricted macaroon; Core Lightning uses its Unix RPC socket, with full RPC access.

Type: one of “lnd”, “clightning”

Default:

"lnd"

Declared by:

services.cdk-mintd.dataDir

Persistent mint database, configuration state and optional BDK wallet.

Type: absolute path

Default:

"/var/lib/cdk-mintd"

Declared by:

services.cdk-mintd.group

Group running the mint.

Type: string

Default:

"config.services.cdk-mintd.user"

Declared by:

services.cdk-mintd.onchain.enable

Whether to enable on-chain minting and melting using a separate BDK wallet and local Bitcoin Core.

Type: boolean

Default:

false

Example:

true

Declared by:

services.cdk-mintd.onchain.allowNewWallet

Allow a configuration change to create a missing BDK wallet database. Needed when adding on-chain support to an existing mint, but not for a new mint. Set back to false after a successful start. For recovery, restore the original wallet database instead whenever possible; see the CDK mint service guide before using mnemonic-only recovery.

Type: boolean

Default:

false

Declared by:

services.cdk-mintd.onchain.mnemonicFile

Absolute path to the BDK wallet’s BIP39 mnemonic. The default is generated when secret generation is enabled. A custom file must be readable by the service user. Keep it separate from the mint seed.

Type: string

Default:

"\${config.nix-bitcoin.secretsDir}/cdk-mintd-bdk-mnemonic"

Declared by:

services.cdk-mintd.port

HTTP listen port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8085

Declared by:

services.cdk-mintd.seedFile

Absolute path to the mint’s raw signing seed, read byte-for-byte (not hex-decoded). The default is generated with 256 bits of entropy when secret generation is enabled. Preserve its exact contents, including whitespace. A custom file must be readable by the service user.

Type: string

Default:

"\${config.nix-bitcoin.secretsDir}/cdk-mintd-seed"

Declared by:

services.cdk-mintd.settings

Additional CDK TOML settings, such as mint metadata, payment limits and fees. See the upstream example.config.toml for the packaged version. Never put secret values here: this document is public in the Nix store. The module manages the listener, signing seed, SQLite database, backend selection and backend connection settings. Those values take precedence over this option. Remote signing is disabled. Nix configuration changes replace the stored CDK configuration before startup; changes made through CDK’s management tools are not declarative.

Type: TOML value

Default:

{ }

Example:

{
  info = {
    input_fee_ppk = 100;
  };
  mint_info = {
    name = "My mint";
  };
}

Declared by:

services.cdk-mintd.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.cdk-mintd.user

User running the mint.

Type: string

Default:

"cdk-mintd"

Declared by:

services.charge-lnd.enable

Whether to enable charge-lnd, policy-based fee manager.

Type: boolean

Default:

false

Example:

true

Declared by:

services.charge-lnd.extraFlags

Extra flags to pass to the charge-lnd command.

Type: list of string

Default:

[ ]

Example:

[
  "--verbose"
  "--dry-run"
]

Declared by:

services.charge-lnd.interval

Systemd calendar expression when to adjust fees.

See systemd.time(7) for possible values.

Default is once a day.

Type: string

Default:

"*-*-* 04:00:00"

Example:

"hourly"

Declared by:

services.charge-lnd.policies

Policy definitions in INI format.

See https://github.com/accumulator/charge-lnd/blob/master/README.md#usage for possible properties and parameters.

Policies are evaluated from top to bottom. The first matching policy (or default) is applied.

Type: strings concatenated with “\n”

Default:

""

Example:

''
  [discourage-routing-out-of-balance]
  chan.max_ratio = 0.1
  chan.min_capacity = 250000
  strategy = static
  base_fee_msat = 10000
  fee_ppm = 500
  
  [encourage-routing-to-balance]
  chan.min_ratio = 0.9
  chan.min_capacity = 250000
  strategy = static
  base_fee_msat = 1
  fee_ppm = 2
  
  [default]
  strategy = ignore
''

Declared by:

services.charge-lnd.randomDelay

Random delay to add to scheduled time.

Type: string

Default:

"1h"

Declared by:

services.clightning.enable

Whether to enable Core Lightning (CLN), a specification compliant Lightning Network implementation in C.

Type: boolean

Default:

false

Example:

true

Declared by:

services.clightning.package

The package providing Core Lightning binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.clightning"

Declared by:

services.clightning.address

Address to listen for peer connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.clightning.always-use-proxy

Always use the proxy, even to connect to normal IP addresses. You can still connect to Unix domain sockets manually. This also disables all DNS lookups, to avoid leaking address information.

Type: boolean

Default:

false

Declared by:

services.clightning.cli

Binary to connect with the Core Lightning instance.

Type: unspecified value (read only)

Default:

"(See source)"

Declared by:

services.clightning.dataDir

The data directory for Core Lightning.

Type: absolute path

Default:

"/var/lib/clightning"

Declared by:

services.clightning.extraConfig

Extra lines appended to the configuration file.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

See all available options at https://github.com/ElementsProject/lightning/blob/master/doc/lightningd-config.5.md or by running lightningd --help.

Type: strings concatenated with “\n”

Default:

""

Example:

''
  alias=mynode
''

Declared by:

services.clightning.getPublicAddressCmd

Bash expression which outputs the public service address to announce to peers. If left empty, no address is announced. The service fails to start when the command fails or prints nothing.

Type: string

Default:

""

Declared by:

services.clightning.group

The group as which to run Core Lightning.

Type: string

Default:

"clightning"

Declared by:

services.clightning.networkDir

The network data directory.

Type: unspecified value (read only)

Default:

"/var/lib/clightning/bitcoin"

Declared by:

services.clightning.plugins.clboss.enable

Whether to enable CLBOSS (Core Lightning plugin). See also: https://github.com/ksedgwic/clboss#operating

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.clboss.package

The package providing clboss binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.clboss"

Declared by:

services.clightning.plugins.clboss.max-channel

The maximum size (in satoshi) of channels created by CLBOSS.

Type: positive integer, meaning >0

Default:

16777215

Declared by:

services.clightning.plugins.clboss.min-channel

The minimum size (in satoshi) of channels created by CLBOSS.

Type: positive integer, meaning >0

Default:

500000

Declared by:

services.clightning.plugins.clboss.min-onchain

Target amount (in satoshi) that CLBOSS will leave on-chain. clboss will only open new channels if the funds in your Core Lightning wallet are larger than this amount.

Type: positive integer, meaning >0

Default:

30000

Declared by:

services.clightning.plugins.clboss.zerobasefee

require: set base_fee to 0. allow: set base_fee according to the CLBOSS heuristics, which may include value 0. disallow: set base_fee to according to the CLBOSS heuristics, with a minimum value of 1.

Type: one of “require”, “allow”, “disallow”

Default:

"allow"

Declared by:

services.clightning.plugins.clnrest.enable

Enable clnrest (Core Lightning plugin).

clnrest provides a Core Lightning REST API, using Core Lightning RPC calls as its backend. It also broadcasts Core Lightning notifications to listeners connected to its websocket server.

See here for all available options: https://docs.corelightning.org/docs/rest Extra options can be set via services.clightning.extraConfig.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.clnrest.package

The package providing clnrest binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.clightning-plugins.clnrest"

Declared by:

services.clightning.plugins.clnrest.address

Address to listen for REST connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.clightning.plugins.clnrest.createAdminRune

Create a rune with admin permissions at path ${config.services.clightning.networkDir}/admin-rune.

Type: boolean

Default:

true

Declared by:

services.clightning.plugins.clnrest.lnconnect.enable

Add a lnconnect-clnrest binary to the system environment which prints connection info for Core Lightning clients. See: https://github.com/LN-Zap/lndconnect

Usage:

  # Print QR code
  lnconnect-clnrest

  # Print URL
  lnconnect-clnrest --url

This does not change the listen address of the clnrest server (services.clightning.plugins.clnrest.address), which is localhost by default. To connect a client, enable services.clightning.plugins.clnrest.lnconnect.onion, use the WireGuard preset, or set the address yourself.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.clnrest.lnconnect.onion

Create an onion service for the clnrest server, which is used by lnconnect.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.clnrest.port

REST server port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

3010

Declared by:

services.clightning.plugins.currencyrate.enable

Whether to enable Currencyrate (Core Lightning plugin).

Type: boolean

Default:

false

Example:

true

Declared by:

services.clightning.plugins.feeadjuster.enable

Enable feeadjuster (Core Lightning plugin). This plugin auto-updates channel fees to keep channels balanced.

See here for all available options: https://github.com/lightningd/plugins/blob/master/feeadjuster/feeadjuster.py Extra options can be set via services.clightning.extraConfig.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.feeadjuster.adjustDaily

Automatically update fees daily.

Type: boolean

Default:

true

Declared by:

services.clightning.plugins.feeadjuster.adjustOnForward

Automatically update fees on forward events.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.feeadjuster.fuzz

Enable update threshold randomization and hysteresis.

Type: boolean

Default:

true

Declared by:

services.clightning.plugins.feeadjuster.method

Adjustment method to calculate channel fees. soft: less difference when adjusting fees. hard: greater difference when adjusting fees.

Type: one of “soft”, “default”, “hard”

Default:

"default"

Declared by:

services.clightning.plugins.monitor.enable

Whether to enable Monitor (Core Lightning plugin).

Type: boolean

Default:

false

Example:

true

Declared by:

services.clightning.plugins.rebalance.enable

Whether to enable Rebalance (Core Lightning plugin).

Type: boolean

Default:

false

Example:

true

Declared by:

services.clightning.plugins.trustedcoin.enable

Whether to enable Trustedcoin (Core Lightning plugin). Warning: With tor.proxy disabled, trustedcoin fetches block data over clearnet, so option services.clightning.tor.enforce is automatically disabled for the whole clightning service.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.trustedcoin.package

The package providing trustedcoin binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.trustedcoin"

Declared by:

services.clightning.plugins.trustedcoin.tor.proxy

Whether to proxy outgoing connections with Tor. Warning: When disabled, option services.clightning.tor.enforce is automatically disabled for the whole clightning service, because trustedcoin needs clearnet HTTPS connections to its block explorers.

Type: boolean

Default:

false

Declared by:

services.clightning.plugins.zmq.enable

Whether to enable ZMQ (Core Lightning plugin).

Type: boolean

Default:

false

Example:

true

Declared by:

services.clightning.plugins.zmq.channel-opened

Endpoint for channel-opened

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.connect

Endpoint for connect

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.disconnect

Endpoint for disconnect

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.forward-event

Endpoint for forward-event

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.invoice-payment

Endpoint for invoice-payment

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.sendpay-failure

Endpoint for sendpay-failure

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.sendpay-success

Endpoint for sendpay-success

Type: null or string

Default:

null

Declared by:

services.clightning.plugins.zmq.warning

Endpoint for warning

Type: null or string

Default:

null

Declared by:

services.clightning.port

Port to listen for peer connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

9735

Declared by:

services.clightning.proxy

Socks proxy for connecting to Tor nodes (or for all connections if option always-use-proxy is set).

Type: null or string

Default:

null

Declared by:

services.clightning.replication.enable

Enable live replication of the Core Lightning database. This prevents losing off-chain funds when the primary wallet file becomes inaccessible.

For setting the destination, you can either define option sshfs.destination or local.directory.

The replica filename is lightningd-signet.sqlite3 on signet, lightningd-testnet4.sqlite3 on testnet4, and lightningd.sqlite3 on mainnet and regtest. Use separate destinations for mainnet and regtest. With encrypt, the destination holds a lightningd-db directory containing the encrypted files and gocryptfs metadata.

See also: https://docs.corelightning.org/docs/backup

Type: boolean

Default:

false

Declared by:

services.clightning.replication.encrypt

Whether to encrypt the replicated database with gocryptfs. The encryption password is automatically generated and stored in file $secretsDir/clightning-replication-password.

Type: boolean

Default:

false

Declared by:

services.clightning.replication.local.directory

This option can be specified instead of sshfs.destination to enable replication to a local directory.

If local.setupDirectory is disabled, the directory

  • must already exist when clightning.service (or clightning-replication-mounts.service if encrypt is true) starts.
  • must have write permissions for the clightning user.

This option is also useful if you want to use a custom remote destination, like a NFS or SMB share.

clightning.service requires the mounts for this directory, and so does clightning-replication-mounts.service if encrypt is true. They don’t start while a mount is missing. systemd can only wait for the mounts it knows, so declare the disk or share in fileSystems. It also doesn’t follow symlinks, so set this to the mount point or a directory below it.

Type: null or absolute path

Default:

null

Example:

"/var/backup/clightning"

Declared by:

services.clightning.replication.local.setupDirectory

Create local.directory if it doesn’t exist and set write permissions for the clightning user.

Type: boolean

Default:

true

Declared by:

services.clightning.replication.sshfs.destination

The SSH destination for which a SSHFS will be mounted. directory is relative to the home of user.

An SSH key is automatically generated and stored in file $secretsDir/clightning-replication-ssh-key. The SSH server must allow logins via this key. I.e., the authorized_keys file of user must contain $secretsDir/clightning-replication-ssh-key.pub.

The host key of the SSH server must be known in advance, e.g. via programs.ssh.knownHosts. Otherwise mounting fails. Don’t set StrictHostKeyChecking=no in sshOptions: it allows any host on the network path to impersonate the server and receive the replicated database.

Type: null or string

Default:

null

Example:

"user@10.0.0.1:directory"

Declared by:

services.clightning.replication.sshfs.port

SSH port of the remote server.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

22

Declared by:

services.clightning.replication.sshfs.sshOptions

SSH options used for mounting the SSHFS.

Type: list of string

Default:

[
  "reconnect"
  "ServerAliveInterval=50"
]

Declared by:

services.clightning.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.clightning.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.clightning.useBcliPlugin

Use bitcoind (via plugin bcli) for getting block data. This option is disabled by plugins that use other sources for fetching block data, like trustedcoin.

Type: boolean

Default:

true

Declared by:

services.clightning.user

The user as which to run Core Lightning.

Type: string

Default:

"clightning"

Declared by:

services.clightning.wallet

Wallet data scheme (sqlite3 or postgres) and location/connection parameters, as fully qualified data source name.

This value is written to the world-readable Nix store. Any local user can read it, so don’t put a password in it.

Type: null or string

Default:

null

Example:

"sqlite3:///var/lib/clightning/bitcoin/lightningd.sqlite3"

Declared by:

services.electrs.enable

Whether to enable electrs, an Electrum server implemented in Rust.

Type: boolean

Default:

false

Example:

true

Declared by:

services.electrs.address

Address to listen for RPC connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.electrs.dataDir

The data directory for electrs.

Type: absolute path

Default:

"/var/lib/electrs"

Declared by:

services.electrs.extraArgs

Extra command line arguments passed to electrs.

Type: strings concatenated with “ “

Default:

""

Declared by:

services.electrs.group

The group as which to run electrs.

Type: string

Default:

"electrs"

Declared by:

services.electrs.monitoringPort

Prometheus monitoring port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

4224

Declared by:

services.electrs.port

Port to listen for RPC connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

50001

Declared by:

services.electrs.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.electrs.user

The user as which to run electrs.

Type: string

Default:

"electrs"

Declared by:

services.fulcrum.enable

Enable fulcrum, an Electrum server implemented in C++.

Compared to electrs, fulcrum has a 3x larger database size but can serve arbitrary address queries instantly.

fulcrum also enables txindex in bitcoind (this is a requirement), which increases the bitcoind datadir size by 8% of the blocks size.

This module disables peering (a distributed list of electrum servers that can be queried by clients), but you can manually enable it via option extraConfig.

Type: boolean

Default:

false

Declared by:

services.fulcrum.address

Address to listen for RPC connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.fulcrum.dataDir

The data directory for fulcrum.

Type: absolute path

Default:

"/var/lib/fulcrum"

Declared by:

services.fulcrum.extraConfig

Extra lines appended to the configuration file.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

See all available options at https://github.com/cculianu/Fulcrum/blob/master/doc/fulcrum-example-config.conf

Type: strings concatenated with “\n”

Default:

""

Example:

''
  peering = true
''

Declared by:

services.fulcrum.group

The group as which to run fulcrum.

Type: string

Default:

"fulcrum"

Declared by:

services.fulcrum.port

Port to listen for RPC connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

50001

Declared by:

services.fulcrum.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.fulcrum.user

The user as which to run fulcrum.

Type: string

Default:

"fulcrum"

Declared by:

services.hardware-wallets.group

Group the hardware wallet udev rules apply to.

Type: string

Default:

"hardware-wallets"

Declared by:

services.hardware-wallets.ledger

If enabled, the ledger udev rules will be installed.

Type: boolean

Default:

false

Declared by:

services.hardware-wallets.trezor

If enabled, the trezor udev rules will be installed.

Type: boolean

Default:

false

Declared by:

services.hardware-wallets.trezorBridge

Run the Trezor Bridge (trezord) for apps that reach the Trezor through it. Requires services.hardware-wallets.trezor. HWI and trezorctl open the device directly and don’t need the bridge.

The bridge serves an HTTP API without authentication on 127.0.0.1:21325. Every local user and service can then use the Trezor through it, not only members of services.hardware-wallets.group. For example, they can read its public keys while it’s unlocked.

Type: boolean

Default:

false

Declared by:

services.lnd.enable

Whether to enable Lightning Network daemon, a Lightning Network implementation in Go.

Type: boolean

Default:

false

Example:

true

Declared by:

services.lnd.package

The package providing lnd binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.lnd"

Declared by:

services.lnd.address

Address to listen for peer connections

Type: string

Default:

"127.0.0.1"

Declared by:

services.lnd.certPath

LND TLS certificate path.

Type: unspecified value (read only)

Default:

"/etc/nix-bitcoin-secrets/lnd-cert"

Declared by:

services.lnd.certificate.extraDomains

Extra subjectAltName domain names added to the certificate. This works the same as lnd option tlsextradomain.

Type: list of string

Default:

[ ]

Example:

[
  "example.com"
]

Declared by:

services.lnd.certificate.extraIPs

Extra subjectAltName IPs added to the certificate. This works the same as lnd option tlsextraip.

Type: list of string

Default:

[ ]

Example:

[
  "60.100.0.1"
]

Declared by:

services.lnd.cli

Binary to connect with the lnd instance.

Type: unspecified value

Default:

"(See source)"

Declared by:

services.lnd.dataDir

The data directory for LND.

Type: absolute path

Default:

"/var/lib/lnd"

Declared by:

services.lnd.extraConfig

Extra lines appended to lnd.conf.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

See here for all available options: https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf

Type: strings concatenated with “\n”

Default:

""

Example:

''
  autopilot.active=1
''

Declared by:

services.lnd.getPublicAddressCmd

Bash expression which outputs the public service address to announce to peers. If left empty, no address is announced. The service fails to start when the command fails or prints nothing.

Type: string

Default:

""

Declared by:

services.lnd.group

The group as which to run LND.

Type: string

Default:

"lnd"

Declared by:

services.lnd.lndconnect.enable

Add a lndconnect binary to the system environment which prints connection info for lnd clients. See: https://github.com/LN-Zap/lndconnect

Usage:

  # Print QR code
  lndconnect

  # Print URL
  lndconnect --url

This does not change the listen address of the lnd REST server (services.lnd.restAddress), which is localhost by default. To connect a client, enable services.lnd.lndconnect.onion, use the WireGuard preset, or set services.lnd.restAddress yourself.

Type: boolean

Default:

false

Declared by:

services.lnd.lndconnect.onion

Create an onion service for the lnd REST server, which is used by lndconnect. The onion service forwards to the Unix socket /run/lnd-rest/rest.sock, where lnd also serves REST. lnd keeps listening on services.lnd.restAddress.

Type: boolean

Default:

false

Declared by:

services.lnd.macaroons

Extra macaroons, created at /run/lnd/<name>.macaroon when lnd starts.

Type: attribute set of (submodule)

Default:

{ }

Declared by:

services.lnd.macaroons.<name>.optionalPermissions

List of uri permissions that the macaroon gets only when lnd has their RPC. Some RPCs, like those of walletrpc, exist only when lnd’s package has their build tag. When lnd lacks the RPC, the macaroon doesn’t get the permission, and lnd’s start logs a warning.

Type: string

Default:

""

Example:

''
  {"entity":"uri","action":"/walletrpc.WalletKit/ListUnspent"}
''

Declared by:

services.lnd.macaroons.<name>.permissions

List of granted macaroon permissions. lnd’s start fails when lnd lacks the RPC of a uri permission.

Type: string

Example:

''
  {"entity":"info","action":"read"},{"entity":"onchain","action":"read"}
''

Declared by:

services.lnd.macaroons.<name>.rootKeyId

The ID of the macaroon’s own lnd root key. A change of the name, user, permissions or optional permissions gives a new ID, which revokes the copies of the previous macaroon.

Type: string (read only)

Default: Derived from the name, user and both lists of permissions

Declared by:

services.lnd.macaroons.<name>.user

User who owns the macaroon. Only this user can read it.

Type: string

Declared by:

services.lnd.networkDir

The network data directory.

Type: unspecified value (read only)

Default:

"/var/lib/lnd/chain/bitcoin/mainnet"

Declared by:

services.lnd.port

Port to listen for peer connections

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

9735

Declared by:

services.lnd.restAddress

Address to listen for REST connections.

Type: string

Default:

"127.0.0.1"

Declared by:

services.lnd.restPort

Port to listen for REST connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8080

Declared by:

services.lnd.rpcAddress

Address to listen for RPC connections. Use a non-empty address without whitespace. IPv6 addresses may be given with or without brackets.

Type: string

Default:

"127.0.0.1"

Declared by:

services.lnd.rpcPort

Port to listen for gRPC connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

10009

Declared by:

services.lnd.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.lnd.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.lnd.tor-socks

Socks proxy for connecting to Tor nodes

Type: null or string

Default:

null

Declared by:

services.lnd.user

The user as which to run LND.

Type: string

Default:

"lnd"

Declared by:

services.mempool.enable

Enable Mempool, a fully featured Bitcoin visualizer, explorer, and API service.

Note: Mempool enables txindex in bitcoind (this is a requirement).

This module has two components:

  • A backend service (systemd service mempool)

  • An optional web interface run by nginx, defined by options services.mempool.frontend.*. The frontend is enabled by default when mempool is enabled. For details, see services.mempool.frontend.enable.

Type: boolean

Default:

false

Declared by:

services.mempool.package

The package providing mempool binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.mempool-backend"

Declared by:

services.mempool.address

Mempool backend address.

Type: string

Default:

"127.0.0.1"

Declared by:

services.mempool.database.name

Database name.

Type: string

Default:

"mempool"

Declared by:

services.mempool.electrumServer

The Electrum server to use for fetching address information.

Possible options:

  • electrs: Small database size, slow when querying new addresses.
  • fulcrum: Large database size, quickly serves arbitrary address queries.

Type: one of “electrs”, “fulcrum”

Default:

"electrs"

Declared by:

services.mempool.frontend.enable

Enable the mempool frontend (web interface). This starts a simple nginx instance, configured for local usage with settings similar to the mempool/frontend Docker image.

IMPORTANT: If you want to expose the mempool frontend to the internet, you should create a custom nginx config that includes TLS, backend caching, rate limiting and performance tuning. For this task, reuse the config snippets from option services.mempool.frontend.nginxConfig. Historical example: https://github.com/fort-nix/nixbitcoin.org/blob/master/website/mempool.nix contains a mempool nginx config for public hosting from the predecessor project.

Type: boolean

Default:

false

Declared by:

services.mempool.frontend.address

HTTP server address.

Type: string

Default:

"127.0.0.1"

Declared by:

services.mempool.frontend.nginxConfig

        An attrset of nginx config snippets for assembling a custom
        mempool nginx config.
        For details, see the source comments at the point of definition.

Type: unspecified value (read only)

Default:

"(See source)"

Declared by:

services.mempool.frontend.port

HTTP server port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

60845

Declared by:

services.mempool.frontend.settings

Mempool frontend settings. See here for available options: https://github.com/mempool/mempool/blob/master/frontend/src/app/services/state.service.ts (interface Env and defaultEnv)

Type: attribute set of anything

Default:

{ }

Example:

{
  MEMPOOL_WEBSITE_URL = "mempool.mynode.org";
  TESTNET_ENABLED = true;
}

Declared by:

services.mempool.frontend.staticContentRoot

        Path of the static frontend content root.

Type: absolute path

Default:

"config.nix-bitcoin.pkgs.mempool-frontend"

Declared by:

services.mempool.group

The group as which to run Mempool.

Type: string

Default:

"mempool"

Declared by:

services.mempool.port

Mempool backend port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8999

Declared by:

services.mempool.settings

Mempool backend settings. See here for available options: https://github.com/mempool/mempool/blob/master/backend/src/config.ts

CORE_RPC.PASSWORD can’t be set here because these settings are copied to the world-readable Nix store. mempool reads the password at startup from bitcoin-rpcpassword-mempool in the secrets dir (nix-bitcoin.secretsDir).

Type: attribute set of attribute set of anything

Default:

{ }

Example:

{
  MEMPOOL = {
    POLL_RATE_MS = 3000;
    STDOUT_LOG_MIN_PRIORITY = "debug";
  };
  PRICE_DATA_SERVER = {
    CLEARNET_URL = "https://myserver.org/prices";
  };
}

Declared by:

services.mempool.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.mempool.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.mempool.user

The user as which to run Mempool.

Type: string

Default:

"mempool"

Declared by:

services.nbxplorer.package

The package providing nbxplorer binaries.

Type: package

Default:

"config.nix-bitcoin.pkgs.nbxplorer"

Declared by:

services.nbxplorer.address

Address to listen on.

Type: string

Default:

"127.0.0.1"

Declared by:

services.nbxplorer.dataDir

The data directory for nbxplorer.

Type: absolute path

Default:

"/var/lib/nbxplorer"

Declared by:

services.nbxplorer.group

The group as which to run nbxplorer.

Type: string

Default:

"nbxplorer"

Declared by:

services.nbxplorer.port

Port to listen on.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

24444

Declared by:

services.nbxplorer.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.nbxplorer.user

The user as which to run nbxplorer.

Type: string

Default:

"nbxplorer"

Declared by:

services.orchard.enable

Whether to enable Orchard, a web dashboard for the local CDK Cashu mint.

Type: boolean

Default:

false

Example:

true

Declared by:

services.orchard.package

Package providing the cashu-orchard binary.

Type: package

Default:

"config.nix-bitcoin.pkgs.cashu-orchard"

Declared by:

services.orchard.address

HTTP listen address. Use an SSH tunnel, onion service or HTTPS reverse proxy for remote access.

Type: string

Default:

"127.0.0.1"

Declared by:

services.orchard.dataDir

Orchard’s user database, settings encryption key and runtime configuration. Keep these together when backing up.

Type: absolute path

Default:

"/var/lib/orchard"

Declared by:

services.orchard.group

Group running Orchard.

Type: string

Default:

"config.services.orchard.user"

Declared by:

services.orchard.mintRpcPort

CDK management RPC port. The module enables mutual TLS and binds it to loopback, or the mint’s private address with network namespace isolation. Orchard can change mint metadata, fees and keysets through this API. Quote payment overrides remain disabled. Nix configuration changes can replace changes made in Orchard.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8086

Declared by:

services.orchard.port

HTTP listen port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

3321

Declared by:

services.orchard.setupKeyFile

Absolute path to the secret authorizing creation of the first admin account. The default is generated when secret generation is enabled. A custom file must be readable by the service user. Use a string path so Nix does not copy the secret to the store.

Type: string

Default:

"\${config.nix-bitcoin.secretsDir}/orchard-setup-key"

Declared by:

services.orchard.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.orchard.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.orchard.user

User running Orchard.

Type: string

Default:

"orchard"

Declared by:

services.rtl.enable

Whether to enable Ride The Lightning, a web interface for LND and Core Lightning.

Type: boolean

Default:

false

Example:

true

Declared by:

services.rtl.address

IP address of the web interface.

Type: string

Default:

"127.0.0.1"

Declared by:

services.rtl.dataDir

The data directory for RTL.

Type: absolute path

Default:

"/var/lib/rtl"

Declared by:

services.rtl.extraCurrency

Currency code (ISO 4217) of the extra currency used for displaying balances. When set, this option enables online currency rate fetching. Warning: Rate fetching requires outgoing clearnet connections, so option tor.enforce is automatically disabled.

Type: null or string

Default:

null

Example:

"USD"

Declared by:

services.rtl.group

The group as which to run RTL.

Type: string

Default:

"rtl"

Declared by:

services.rtl.nightTheme

Enable the Night UI Theme.

Type: boolean

Default:

false

Declared by:

services.rtl.nodes.clightning.enable

Enable the Core Lightning node interface.

Type: boolean

Default:

false

Declared by:

services.rtl.nodes.clightning.extraConfig

Extra Core Lightning node configuration.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

See here for all available options: https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md

Type: attribute set of anything

Default:

{ }

Example:

{
  Settings = {
    logLevel = "DEBUG";
    userPersona = "MERCHANT";
  };
}

Declared by:

services.rtl.nodes.lnd.enable

Enable the lnd node interface.

Type: boolean

Default:

false

Declared by:

services.rtl.nodes.lnd.extraConfig

Extra lnd node configuration.

User-supplied extraConfig options are unsupported by bitcoinix. They may override managed settings or bypass security checks. You take full responsibility for their correctness, security and compatibility with bitcoinix. Prefer dedicated NixOS options when available.

See here for all available options: https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md

Type: attribute set of anything

Default:

{ }

Example:

{
  Settings = {
    logLevel = "DEBUG";
    userPersona = "MERCHANT";
  };
}

Declared by:

services.rtl.nodes.reverseOrder

Reverse the order of nodes shown in the UI. By default, Core Lightning is shown before LND.

Type: boolean

Default:

false

Declared by:

services.rtl.port

Port of the web interface.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

3000

Declared by:

services.rtl.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.rtl.user

The user as which to run RTL.

Type: string

Default:

"rtl"

Declared by:

services.unbeholden-lnurl.enable

Whether to enable Unbeholden LNURL, a Lightning Address server.

Type: boolean

Default:

false

Example:

true

Declared by:

services.unbeholden-lnurl.package

The package providing Unbeholden LNURL.

Type: package

Default:

"config.nix-bitcoin.pkgs.unbeholden-lnurl"

Declared by:

services.unbeholden-lnurl.address

HTTP server address.

Type: string

Default:

"127.0.0.1"

Declared by:

services.unbeholden-lnurl.backend

The local Lightning node that creates invoices and pays vouchers.

Type: one of “lnd”, “clightning”

Default:

"lnd"

Declared by:

services.unbeholden-lnurl.dataDir

The data directory, holding settlement cursors, voucher claims and zap receipts.

Type: absolute path

Default:

"/var/lib/unbeholden-lnurl"

Declared by:

services.unbeholden-lnurl.group

The group as which to run Unbeholden LNURL.

Type: string

Default:

"config.services.unbeholden-lnurl.user"

Declared by:

services.unbeholden-lnurl.port

HTTP server port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

8081

Declared by:

services.unbeholden-lnurl.settings

Unbeholden LNURL configuration. See the example config. listen, state_dir and the node connection are set by this module. The config is world-readable in the Nix store: put secrets in files.

Type: open submodule of (YAML 1.1 value)

Default:

{ }

Declared by:

services.unbeholden-lnurl.settings.addresses

Lightning Addresses by user name, or * for any name.

Type: attribute set of (open submodule of (YAML 1.1 value))

Default:

{ }

Declared by:

services.unbeholden-lnurl.settings.addresses.<name>.max_sendable

Maximum amount in millisatoshis.

Type: positive integer, meaning >0

Declared by:

services.unbeholden-lnurl.settings.addresses.<name>.min_sendable

Minimum amount in millisatoshis.

Type: positive integer, meaning >0

Declared by:

services.unbeholden-lnurl.settings.nostr

Nostr zap receipts. Set to {} to enable them.

Type: null or (open submodule of (YAML 1.1 value))

Default:

null

Declared by:

services.unbeholden-lnurl.settings.nostr.private_key_file

File with the Nostr private key.

Type: string

Default:

"\${config.nix-bitcoin.secretsDir}/unbeholden-lnurl-nostr"

Declared by:

services.unbeholden-lnurl.settings.notifications.ntfy

ntfy settlement notifications. Set token_file instead of token, so that the token stays out of the Nix store.

Type: null or (attribute set of (YAML 1.1 value))

Default:

null

Declared by:

services.unbeholden-lnurl.settings.outbound_proxy

SOCKS5 proxy for ntfy notifications and Nostr publishing.

Type: null or string

Default:

null

Declared by:

services.unbeholden-lnurl.settings.trusted_proxies

IP addresses or CIDRs of reverse proxies whose X-Forwarded-* headers are trusted.

Type: list of string

Default:

[ ]

Declared by:

services.unbeholden-lnurl.settings.verify_key_file

File with the key for verify URLs. Changing it invalidates old verify URLs.

Type: string

Default:

"\${config.nix-bitcoin.secretsDir}/unbeholden-lnurl-verify"

Declared by:

services.unbeholden-lnurl.settings.withdraw

Withdrawal vouchers.

Type: list of attribute set of (YAML 1.1 value)

Default:

[ ]

Declared by:

services.unbeholden-lnurl.settings.withdraw_secret_file

File with the voucher secret. Changing it changes every voucher URL.

Type: null or string

Default:

"\${config.nix-bitcoin.secretsDir}/unbeholden-lnurl-withdraw, or null if `withdraw_secret` is set"

Declared by:

services.unbeholden-lnurl.tor.enforce

Whether to enforce Tor on this service by only allowing connections from and to localhost and, with netns-isolation, the network namespace addresses 169.254.<addressblock>.0/24. The service also can’t reach the local name-resolution sockets (nscd, systemd-resolved, D-Bus, Avahi), so glibc resolves names itself: from /etc/hosts, and through a resolver only if one listens on an allowed address.

Type: boolean

Default:

false

Declared by:

services.unbeholden-lnurl.tor.proxy

Whether to proxy outgoing connections with Tor.

Type: boolean

Default:

false

Declared by:

services.unbeholden-lnurl.user

The user as which to run Unbeholden LNURL.

Type: string

Default:

"unbeholden-lnurl"

Declared by:

services.unbeholden-wallet.enable

Enable Unbeholden Wallet, a watch-only Bitcoin wallet that runs in the browser and hands transactions to an air-gapped signer.

The service serves the wallet and relays its WebSocket connection at /electrum to the Electrum server set by services.unbeholden-wallet.electrumServer.

Browsers only allow the camera, which scans signed transactions, on localhost or over https. For access from other devices, put an https reverse proxy in front of the service.

Type: boolean

Default:

false

Declared by:

services.unbeholden-wallet.package

The package providing the wallet and its server.

Type: package

Default:

"config.nix-bitcoin.pkgs.unbeholden-wallet"

Declared by:

services.unbeholden-wallet.address

HTTP server address.

Type: string

Default:

"127.0.0.1"

Declared by:

services.unbeholden-wallet.allowedClients

IP addresses or networks, in addition to localhost, that can connect to the service, e.g. an https reverse proxy on another host. Set services.unbeholden-wallet.address to a non-local address too. systemd ignores entries it can’t parse. The service can also open connections to these addresses. This doesn’t open the firewall port. Not supported with netns-isolation.

Type: list of string

Default:

[ ]

Example:

[
  "192.0.2.10"
  "192.0.2.0/24"
]

Declared by:

services.unbeholden-wallet.allowedHosts

Names under which the server answers, in addition to localhost and IP addresses. Give host names without a port: wallet.example.com:8443 never matches. Add the name of an https reverse proxy in front of the service. Other names are refused, so a website can’t reach the Electrum relay through DNS rebinding.

Type: list of string

Default:

[ ]

Example:

[
  "wallet.example.com"
]

Declared by:

services.unbeholden-wallet.electrumServer

The Electrum server that the wallet connects to.

Possible options:

  • electrs: Small database size, slow when querying new addresses.
  • fulcrum: Large database size, quickly serves arbitrary address queries.

Type: one of “electrs”, “fulcrum”

Default:

"electrs"

Declared by:

services.unbeholden-wallet.group

The group as which to run Unbeholden Wallet.

Type: string

Default:

"unbeholden-wallet"

Declared by:

services.unbeholden-wallet.port

HTTP server port.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

60846

Declared by:

services.unbeholden-wallet.user

The user as which to run Unbeholden Wallet.

Type: string

Default:

"unbeholden-wallet"

Declared by:

FAQ

Why does Core Lightning fail on my pruned node?

You may see lightning-cli: Connecting to 'lightning-rpc': Connection refused. Check the log with journalctl -eu clightning. Core Lightning needs every block since it last ran. When Bitcoin Core has already pruned one of them, the bcli plugin asks Bitcoin Core to fetch it from a peer with getblockfrompeer. This needs connected peers that still serve the block.

getblockfrompeer is unavailable when services.clightning.useBcliPlugin is off, e.g. with the trustedcoin plugin, which fetches blocks from public block explorers instead.

If the node is new and holds no funds or channels, you can start over:

systemctl stop clightning
find /var/lib/clightning -mindepth 1 -delete
systemctl start clightning

Never do this on a node with funds or channels. /var/lib/clightning holds hsm_secret and the channel database.

How do I free disk space used by Nix?

Each deployment keeps the previous system generations, so you can roll back. Run nix-collect-garbage -d as root to delete the old generations and everything that only they use. You can’t roll back to the deleted generations afterwards.

To clean up automatically, set the NixOS option nix.gc.automatic, e.g. with nix.gc.options = "--delete-older-than 30d".

Where is sudo?

The secure-node.nix preset disables sudo and enables OpenBSD’s doas, which is much smaller. It also adds the shell alias sudo for doas. This followed CVE-2021-3156 in sudo.

To run commands as root, add your user to the wheel group, e.g. users.users.operator.extraGroups = [ "wheel" ];. doas asks members of wheel for their password, and the operator user has none by default. Set one as root with passwd operator.

How do I see my node’s onion addresses?

Set nix-bitcoin.nodeinfo.enable = true; (the secure-node.nix preset does) and run nodeinfo as root or as the operator user. It lists the enabled services with their local and onion addresses. The operator can also read the onion addresses of all active onion services in /var/lib/onion-addresses/<operator name>/. See nodeinfo.

How do I run a command in a service’s network namespace?

With nix-bitcoin.netns-isolation.enable = true;, each entry of nix-bitcoin.netns-isolation.services runs in a network namespace named nb-<entry>. Run the command as root with ip netns exec nb-<entry> <command>, e.g. ip netns exec nb-bitcoind ss -tlnp. The mempool frontend is served by nginx, so it runs in nb-nginx, not nb-mempool. The netns-exec wrapper has been removed.

Why can’t I run bitcoin-cli, lightning-cli or lncli as my user?

These commands work as root and as the operator user. Enable it with nix-bitcoin.operator.enable = true; (the secure-node.nix preset does). To use your existing user, also set nix-bitcoin.operator.name = "<your user>";. The operator joins the groups of the enabled services, and runs lncli as the lnd user through doas or sudo. Root runs bitcoin-cli as the bitcoin user and lightning-cli as the clightning user.